From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4fSt-0003z8-M9 for qemu-devel@nongnu.org; Sun, 22 May 2016 22:19:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b4fSs-0003rd-NN for qemu-devel@nongnu.org; Sun, 22 May 2016 22:19:31 -0400 From: Fam Zheng Date: Mon, 23 May 2016 10:19:36 +0800 Message-Id: <1463969978-24970-3-git-send-email-famz@redhat.com> In-Reply-To: <1463969978-24970-1-git-send-email-famz@redhat.com> References: <1463969978-24970-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH v2 2/4] blockdev-backup: Don't move target AioContext if it's attached List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Max Reitz , Markus Armbruster , Stefan Hajnoczi , Paolo Bonzini , "Michael S. Tsirkin" , qemu-block@nongnu.org If the BDS is attached, it will want to stay on the AioContext where its BlockBackend is. Don't call bdrv_set_aio_context in this case. Signed-off-by: Fam Zheng --- blockdev.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/blockdev.c b/blockdev.c index 026ead0..85eb7d7 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3382,8 +3382,18 @@ void do_blockdev_backup(const char *device, const char *target, goto out; } + if (bdrv_get_aio_context(target_bs) != aio_context) { + if (!bdrv_has_blk(target_bs)) { + /* The target BDS is not attached, we can safely move it to another + * AioContext. */ + bdrv_set_aio_context(target_bs, aio_context); + } else { + error_setg(errp, "Target is attached to a different thread from " + "source."); + goto out; + } + } bdrv_ref(target_bs); - bdrv_set_aio_context(target_bs, aio_context); backup_start(bs, target_bs, speed, sync, NULL, on_source_error, on_target_error, block_job_cb, bs, txn, &local_err); if (local_err != NULL) { -- 2.8.2