qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 02/22] block: acquire AioContext in bdrv_close_all()


From: Stefan Hajnoczi
Subject: [Qemu-devel] [PATCH 02/22] block: acquire AioContext in bdrv_close_all()
Date: Thu, 1 May 2014 16:54:26 +0200

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 <address@hidden>
---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]