Received: from eggs.gnu.org ([2001:4830:134:3::10]:57287) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bom1v-0004Ke-Ep for qemu-devel@nongnu.org; Tue, 27 Sep 2016 02:38:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bom1t-0003bL-Hi for qemu-devel@nongnu.org; Tue, 27 Sep 2016 02:38:14 -0400 From: Fam Zheng Date: Tue, 27 Sep 2016 14:37:53 +0800 Message-Id: <1474958276-7715-3-git-send-email-famz@redhat.com> In-Reply-To: <1474958276-7715-1-git-send-email-famz@redhat.com> References: <1474958276-7715-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH v2 2/5] blockdev: Move BDS AioContext before inserting to BB List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , qemu-stable@nongnu.org, Max Reitz , stefanha@redhat.com, pbonzini@redhat.com 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 --- 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