From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAHxm-0002x4-2g for qemu-devel@nongnu.org; Tue, 07 Jun 2016 10:26:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAHxk-0006Za-9Y for qemu-devel@nongnu.org; Tue, 07 Jun 2016 10:26:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45713) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAHxk-0006ZW-46 for qemu-devel@nongnu.org; Tue, 07 Jun 2016 10:26:36 -0400 From: Stefan Hajnoczi Date: Tue, 7 Jun 2016 15:26:16 +0100 Message-Id: <1465309585-31551-4-git-send-email-stefanha@redhat.com> In-Reply-To: <1465309585-31551-1-git-send-email-stefanha@redhat.com> References: <1465309585-31551-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL 03/12] 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: Peter Maydell , Fam Zheng , Stefan Hajnoczi From: Fam Zheng 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 Message-id: 1463969978-24970-3-git-send-email-famz@redhat.com Signed-off-by: Stefan Hajnoczi --- blockdev.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/blockdev.c b/blockdev.c index ea7f397..6ccb8e1 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3371,7 +3371,17 @@ void do_blockdev_backup(const char *device, const char *target, goto out; } - bdrv_set_aio_context(target_bs, aio_context); + 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; + } + } 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.5.5