bdrv_close_all() closes all BlockDriverState instances. It is called from vl.c:main() and qemu-nbd when shutting down.
Some BlockDriverState instances may be running in another AioContext. Make sure to acquire the AioContext before closing the BlockDriverState. This will protect against race conditions once virtio-blk data-plane is using the BlockDriverState from another AioContext event loop. Signed-off-by: Stefan Hajnoczi <stefa...@redhat.com> --- block.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/block.c b/block.c index 94999e5..9381918 100644 --- a/block.c +++ b/block.c @@ -1755,7 +1755,11 @@ void bdrv_close_all(void) BlockDriverState *bs; QTAILQ_FOREACH(bs, &bdrv_states, device_list) { + AioContext *aio_context = bdrv_get_aio_context(bs); + + aio_context_acquire(aio_context); bdrv_close(bs); + aio_context_release(aio_context); } } -- 1.9.0