From patchwork Mon May 23 02:19:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 9131083 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3875F607D3 for ; Mon, 23 May 2016 02:24:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2452C28117 for ; Mon, 23 May 2016 02:24:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19050281EB; Mon, 23 May 2016 02:24:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C014528117 for ; Mon, 23 May 2016 02:24:01 +0000 (UTC) Received: from localhost ([::1]:45243 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4fXE-0007W8-QX for patchwork-qemu-devel@patchwork.kernel.org; Sun, 22 May 2016 22:24:00 -0400 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 Received: from mx1.redhat.com ([209.132.183.28]:49929) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4fSn-0003qx-8x; Sun, 22 May 2016 22:19:25 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E44A44DB13; Mon, 23 May 2016 02:19:24 +0000 (UTC) Received: from lemon.redhat.com (vpn1-7-186.pek2.redhat.com [10.72.7.186]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4N2JDgL010152; Sun, 22 May 2016 22:19:21 -0400 From: Fam Zheng To: qemu-devel@nongnu.org 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> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 23 May 2016 02:19:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 2/4] blockdev-backup: Don't move target AioContext if it's attached X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, "Michael S. Tsirkin" , Markus Armbruster , Max Reitz , Stefan Hajnoczi , Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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) {