qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH v2 2/5] blockdev: Move BDS AioContext before inserti


From: Fam Zheng
Subject: [Qemu-devel] [PATCH v2 2/5] blockdev: Move BDS AioContext before inserting to BB
Date: Tue, 27 Sep 2016 14:37:53 +0800

The callers made sure the BDS has no BB attached before, so blk is
becoming the sole owner. It is necessary to move the BDS to the right
AioContext before inserting it, to keep them in sync.

Signed-off-by: Fam Zheng <address@hidden>
---
 blockdev.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/blockdev.c b/blockdev.c
index a4960b9..9700dee 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2478,6 +2478,7 @@ out:
 static void qmp_blockdev_insert_anon_medium(BlockBackend *blk,
                                             BlockDriverState *bs, Error **errp)
 {
+    AioContext *ctx;
     bool has_device;
 
     /* For BBs without a device, we can exchange the BDS tree at will */
@@ -2498,6 +2499,12 @@ static void qmp_blockdev_insert_anon_medium(BlockBackend 
*blk,
         return;
     }
 
+    ctx = blk_get_aio_context(blk);
+    if (ctx != bdrv_get_aio_context(bs)) {
+        aio_context_acquire(ctx);
+        bdrv_set_aio_context(bs, ctx);
+        aio_context_release(ctx);
+    }
     blk_insert_bs(blk, bs);
 
     if (!blk_dev_has_tray(blk)) {
-- 
2.7.4




reply via email to

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