On 17/04/2017 05:33, Fam Zheng wrote: > BDRV_POLL_WHILE in both IOThread and main loop has aio_context_acquire(ctx) > around it; in the branch where main loop calls aio_poll(ctx, false), > there is also no aio_context_release(ctx). So I thinki it is protected by the > AioContext lock, and is safe. > > I tested your suggested "aio_poll(qemu_get_aio_context(), false)", but it > doesn't work.
Right, that's because "aio_poll(qemu_get_aio_context(), false)" relies on bdrv_wakeup on the I/O thread side (which in turn is triggered by bdrv_inc_in_flight/bdrv_dec_in_flight), but the bottom half does not have bdrv_inc_in_flight/bdrv_dec_in_flight around it. Paolo