From: Fam Zheng Date: Mon, 23 May 2016 02:19:36 +0000 (+0800) Subject: blockdev-backup: Don't move target AioContext if it's attached X-Git-Tag: qemu-xen-4.8.0-rc1~228^2~9 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=efd7556708bdfb61dab259e08bd71fbe5680ddcd;p=qemu-xen.git blockdev-backup: Don't move target AioContext if it's attached 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 --- diff --git a/blockdev.c b/blockdev.c index ea7f3974e2..6ccb8e1f84 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) {