/* Note that completion of an asynchronous I/O operation can trigger any number of other I/O operations on other devices */
void bdrv_drain_all(void)
/* Note that completion of an asynchronous I/O operation can trigger any number of other I/O operations on other devices */
void bdrv_drain_all(void)
{
    bool busy = true;
    BlockDriverState *bs;
    while (busy) {
        QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
            bdrv_start_throttled_reqs(bs);
        }
        busy = bdrv_requests_pending_all();
        busy |= aio_poll(qemu_get_aio_context(), busy);
    }
}