From nobody Sat May 4 17:05:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149157337288820.642701262194578; Fri, 7 Apr 2017 06:56:12 -0700 (PDT) Received: from localhost ([::1]:51013 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwUN1-00044l-Kj for importer@patchew.org; Fri, 07 Apr 2017 09:56:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44761) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwUF4-0005iW-AJ for qemu-devel@nongnu.org; Fri, 07 Apr 2017 09:47:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cwUF3-0003Mh-5m for qemu-devel@nongnu.org; Fri, 07 Apr 2017 09:47:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37600) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cwUEy-0003Kt-PA; Fri, 07 Apr 2017 09:47:52 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BA498EEF21; Fri, 7 Apr 2017 13:47:51 +0000 (UTC) Received: from noname.redhat.com (ovpn-117-140.ams2.redhat.com [10.36.117.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF035189DE; Fri, 7 Apr 2017 13:47:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BA498EEF21 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com BA498EEF21 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 7 Apr 2017 15:47:36 +0200 Message-Id: <1491572865-8549-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1491572865-8549-1-git-send-email-kwolf@redhat.com> References: <1491572865-8549-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 07 Apr 2017 13:47:51 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 01/10] block: Ignore guest dev permissions during incoming migration 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: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Usually guest devices don't like other writers to the same image, so they use blk_set_perm() to prevent this from happening. In the migration phase before the VM is actually running, though, they don't have a problem with writes to the image. On the other hand, storage migration needs to be able to write to the image in this phase, so the restrictive blk_set_perm() call of qdev devices breaks it. This patch flags all BlockBackends with a qdev device as blk->disable_perm during incoming migration, which means that the requested permissions are stored in the BlockBackend, but not actually applied to its root node yet. Once migration has finished and the VM should be resumed, the permissions are applied. If they cannot be applied (e.g. because the NBD server used for block migration hasn't been shut down), resuming the VM fails. Signed-off-by: Kevin Wolf Tested-by: Kashyap Chamarthy --- block/block-backend.c | 40 +++++++++++++++++++++++++++++++++++++++- include/block/block.h | 2 ++ migration/migration.c | 8 ++++++++ qmp.c | 6 ++++++ 4 files changed, 55 insertions(+), 1 deletion(-) diff --git a/block/block-backend.c b/block/block-backend.c index 0b63773..18ece99 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -61,6 +61,7 @@ struct BlockBackend { =20 uint64_t perm; uint64_t shared_perm; + bool disable_perm; =20 bool allow_write_beyond_eof; =20 @@ -578,7 +579,7 @@ int blk_set_perm(BlockBackend *blk, uint64_t perm, uint= 64_t shared_perm, { int ret; =20 - if (blk->root) { + if (blk->root && !blk->disable_perm) { ret =3D bdrv_child_try_set_perm(blk->root, perm, shared_perm, errp= ); if (ret < 0) { return ret; @@ -597,15 +598,52 @@ void blk_get_perm(BlockBackend *blk, uint64_t *perm, = uint64_t *shared_perm) *shared_perm =3D blk->shared_perm; } =20 +/* + * Notifies the user of all BlockBackends that migration has completed. qd= ev + * devices can tighten their permissions in response (specifically revoke + * shared write permissions that we needed for storage migration). + * + * If an error is returned, the VM cannot be allowed to be resumed. + */ +void blk_resume_after_migration(Error **errp) +{ + BlockBackend *blk; + Error *local_err =3D NULL; + + for (blk =3D blk_all_next(NULL); blk; blk =3D blk_all_next(blk)) { + if (!blk->disable_perm) { + continue; + } + + blk->disable_perm =3D false; + + blk_set_perm(blk, blk->perm, blk->shared_perm, &local_err); + if (local_err) { + error_propagate(errp, local_err); + blk->disable_perm =3D true; + return; + } + } +} + static int blk_do_attach_dev(BlockBackend *blk, void *dev) { if (blk->dev) { return -EBUSY; } + + /* While migration is still incoming, we don't need to apply the + * permissions of guest device BlockBackends. We might still have a bl= ock + * job or NBD server writing to the image for storage migration. */ + if (runstate_check(RUN_STATE_INMIGRATE)) { + blk->disable_perm =3D true; + } + blk_ref(blk); blk->dev =3D dev; blk->legacy_dev =3D false; blk_iostatus_reset(blk); + return 0; } =20 diff --git a/include/block/block.h b/include/block/block.h index 5149260..3e09222 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -366,6 +366,8 @@ void bdrv_invalidate_cache(BlockDriverState *bs, Error = **errp); void bdrv_invalidate_cache_all(Error **errp); int bdrv_inactivate_all(void); =20 +void blk_resume_after_migration(Error **errp); + /* Ensure contents are flushed to disk. */ int bdrv_flush(BlockDriverState *bs); int coroutine_fn bdrv_co_flush(BlockDriverState *bs); diff --git a/migration/migration.c b/migration/migration.c index 54060f7..ad4036f 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -349,6 +349,14 @@ static void process_incoming_migration_bh(void *opaque) exit(EXIT_FAILURE); } =20 + /* If we get an error here, just don't restart the VM yet. */ + blk_resume_after_migration(&local_err); + if (local_err) { + error_free(local_err); + local_err =3D NULL; + autostart =3D false; + } + /* * This must happen after all error conditions are dealt with and * we're sure the VM is going to be running on this host. diff --git a/qmp.c b/qmp.c index fa82b59..a744e44 100644 --- a/qmp.c +++ b/qmp.c @@ -207,6 +207,12 @@ void qmp_cont(Error **errp) } } =20 + blk_resume_after_migration(&local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + if (runstate_check(RUN_STATE_INMIGRATE)) { autostart =3D 1; } else { --=20 1.8.3.1 From nobody Sat May 4 17:05:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149157308536765.469360081829; Fri, 7 Apr 2017 06:51:25 -0700 (PDT) Received: from localhost ([::1]:50988 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwUIN-0008Hy-VD for importer@patchew.org; Fri, 07 Apr 2017 09:51:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44756) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwUF4-0005i8-2U for qemu-devel@nongnu.org; Fri, 07 Apr 2017 09:47:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cwUF3-0003Mm-9B for qemu-devel@nongnu.org; Fri, 07 Apr 2017 09:47:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45420) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cwUF1-0003La-42; Fri, 07 Apr 2017 09:47:55 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 15024C04B953; Fri, 7 Apr 2017 13:47:54 +0000 (UTC) Received: from noname.redhat.com (ovpn-117-140.ams2.redhat.com [10.36.117.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 16580189DE; Fri, 7 Apr 2017 13:47:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 15024C04B953 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 15024C04B953 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 7 Apr 2017 15:47:37 +0200 Message-Id: <1491572865-8549-3-git-send-email-kwolf@redhat.com> In-Reply-To: <1491572865-8549-1-git-send-email-kwolf@redhat.com> References: <1491572865-8549-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 07 Apr 2017 13:47:54 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 02/10] commit: Set commit_top_bs->aio_context 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: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The filter driver that is inserted by the commit job needs to use the same AioContext as its parent and child nodes. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Fam Zheng --- block/commit.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/commit.c b/block/commit.c index 2832482..4c38220 100644 --- a/block/commit.c +++ b/block/commit.c @@ -335,6 +335,7 @@ void commit_start(const char *job_id, BlockDriverState = *bs, if (commit_top_bs =3D=3D NULL) { goto fail; } + bdrv_set_aio_context(commit_top_bs, bdrv_get_aio_context(top)); =20 bdrv_set_backing_hd(commit_top_bs, top, &local_err); if (local_err) { @@ -482,6 +483,7 @@ int bdrv_commit(BlockDriverState *bs) error_report_err(local_err); goto ro_cleanup; } + bdrv_set_aio_context(commit_top_bs, bdrv_get_aio_context(backing_file_= bs)); =20 bdrv_set_backing_hd(commit_top_bs, backing_file_bs, &error_abort); bdrv_set_backing_hd(bs, commit_top_bs, &error_abort); --=20 1.8.3.1 From nobody Sat May 4 17:05:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491573513800365.31456363186726; Fri, 7 Apr 2017 06:58:33 -0700 (PDT) Received: from localhost ([::1]:51020 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwUPI-0006Hj-Mr for importer@patchew.org; Fri, 07 Apr 2017 09:58:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44782) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwUF5-0005kL-09 for qemu-devel@nongnu.org; Fri, 07 Apr 2017 09:47:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cwUF4-0003NR-BA for qemu-devel@nongnu.org; Fri, 07 Apr 2017 09:47:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60852) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cwUF2-0003Ly-CK; Fri, 07 Apr 2017 09:47:56 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 51F97C059746; Fri, 7 Apr 2017 13:47:55 +0000 (UTC) Received: from noname.redhat.com (ovpn-117-140.ams2.redhat.com [10.36.117.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6332088669; Fri, 7 Apr 2017 13:47:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 51F97C059746 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 51F97C059746 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 7 Apr 2017 15:47:38 +0200 Message-Id: <1491572865-8549-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1491572865-8549-1-git-send-email-kwolf@redhat.com> References: <1491572865-8549-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 07 Apr 2017 13:47:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 03/10] commit: Set commit_top_bs->total_sectors 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: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Like in the mirror filter driver, we also need to set the image size for the commit filter driver. This is less likely to be a problem in practice than for the mirror because we're not at the active layer here, but attaching new parents to a node in the middle of the chain is possible, so the size needs to be correct anyway. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Fam Zheng --- block/commit.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/commit.c b/block/commit.c index 4c38220..91d2c34 100644 --- a/block/commit.c +++ b/block/commit.c @@ -335,6 +335,7 @@ void commit_start(const char *job_id, BlockDriverState = *bs, if (commit_top_bs =3D=3D NULL) { goto fail; } + commit_top_bs->total_sectors =3D top->total_sectors; bdrv_set_aio_context(commit_top_bs, bdrv_get_aio_context(top)); =20 bdrv_set_backing_hd(commit_top_bs, top, &local_err); --=20 1.8.3.1 From nobody Sat May 4 17:05:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491573092985671.3692662912441; Fri, 7 Apr 2017 06:51:32 -0700 (PDT) Received: from localhost ([::1]:50990 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwUIV-0008OW-Sk for importer@patchew.org; Fri, 07 Apr 2017 09:51:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44818) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwUF7-0005n1-7J for qemu-devel@nongnu.org; Fri, 07 Apr 2017 09:48:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cwUF6-0003Pl-9m for qemu-devel@nongnu.org; Fri, 07 Apr 2017 09:48:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42372) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cwUF3-0003Mb-Ia; Fri, 07 Apr 2017 09:47:57 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 92C617EBA2; Fri, 7 Apr 2017 13:47:56 +0000 (UTC) Received: from noname.redhat.com (ovpn-117-140.ams2.redhat.com [10.36.117.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F958857AE; Fri, 7 Apr 2017 13:47:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 92C617EBA2 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 92C617EBA2 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 7 Apr 2017 15:47:39 +0200 Message-Id: <1491572865-8549-5-git-send-email-kwolf@redhat.com> In-Reply-To: <1491572865-8549-1-git-send-email-kwolf@redhat.com> References: <1491572865-8549-1-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 07 Apr 2017 13:47:56 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 04/10] block/mirror: Fix use-after-free 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: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Max Reitz If @bs does not have any parents, the only reference to @mirror_top_bs will be held by the BlockJob object after the bdrv_unref() following block_job_create(). However, if block_job_create() fails, this reference will not exist and @mirror_top_bs will have been deleted when we goto fail. The issue comes back at all later entries to the fail label: We delete the BlockJob object before rolling back our changes to the node graph. This means that we will delete @mirror_top_bs in the process. All in all, whenever @bs does not have any parents and we go down the fail path we will dereference @mirror_top_bs after it has been deleted. Fix this by invoking bdrv_unref() only when block_job_create() was successful and by bdrv_ref()'ing @mirror_top_bs in the fail path before deleting the BlockJob object. Finally, bdrv_unref() it at the end of the fail path after we actually no longer need it. Signed-off-by: Max Reitz Reviewed-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Kevin Wolf --- block/mirror.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index 9e2fecc..46ecd38 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1150,7 +1150,7 @@ static void mirror_start_job(const char *job_id, Bloc= kDriverState *bs, mirror_top_bs->total_sectors =3D bs->total_sectors; =20 /* bdrv_append takes ownership of the mirror_top_bs reference, need to= keep - * it alive until block_job_create() even if bs has no parent. */ + * it alive until block_job_create() succeeds even if bs has no parent= . */ bdrv_ref(mirror_top_bs); bdrv_drained_begin(bs); bdrv_append(mirror_top_bs, bs, &local_err); @@ -1168,10 +1168,12 @@ static void mirror_start_job(const char *job_id, Bl= ockDriverState *bs, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANG= ED | BLK_PERM_WRITE | BLK_PERM_GRAPH_MOD, speed, creation_flags, cb, opaque, errp); - bdrv_unref(mirror_top_bs); if (!s) { goto fail; } + /* The block job now has a reference to this node */ + bdrv_unref(mirror_top_bs); + s->source =3D bs; s->mirror_top_bs =3D mirror_top_bs; =20 @@ -1242,6 +1244,10 @@ static void mirror_start_job(const char *job_id, Blo= ckDriverState *bs, =20 fail: if (s) { + /* Make sure this BDS does not go away until we have completed the= graph + * changes below */ + bdrv_ref(mirror_top_bs); + g_free(s->replaces); blk_unref(s->target); block_job_unref(&s->common); @@ -1250,6 +1256,8 @@ fail: bdrv_child_try_set_perm(mirror_top_bs->backing, 0, BLK_PERM_ALL, &error_abort); bdrv_replace_node(mirror_top_bs, backing_bs(mirror_top_bs), &error_abo= rt); + + bdrv_unref(mirror_top_bs); } =20 void mirror_start(const char *job_id, BlockDriverState *bs, --=20 1.8.3.1 From nobody Sat May 4 17:05:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491573249802418.3275608707197; Fri, 7 Apr 2017 06:54:09 -0700 (PDT) Received: from localhost ([::1]:51002 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwUL2-0002GR-Hl for importer@patchew.org; Fri, 07 Apr 2017 09:54:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44852) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwUFB-0005rU-DN for qemu-devel@nongnu.org; Fri, 07 Apr 2017 09:48:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cwUF7-0003Sr-Ki for qemu-devel@nongnu.org; Fri, 07 Apr 2017 09:48:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48364) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cwUF4-0003NP-V7; Fri, 07 Apr 2017 09:47:59 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E217F3DBC4; Fri, 7 Apr 2017 13:47:57 +0000 (UTC) Received: from noname.redhat.com (ovpn-117-140.ams2.redhat.com [10.36.117.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id E23F3857AE; Fri, 7 Apr 2017 13:47:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E217F3DBC4 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E217F3DBC4 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 7 Apr 2017 15:47:40 +0200 Message-Id: <1491572865-8549-6-git-send-email-kwolf@redhat.com> In-Reply-To: <1491572865-8549-1-git-send-email-kwolf@redhat.com> References: <1491572865-8549-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 07 Apr 2017 13:47:58 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 05/10] iotests: Add mirror tests for orphaned source 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: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Max Reitz Signed-off-by: Max Reitz Reviewed-by: John Snow Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- tests/qemu-iotests/041 | 46 +++++++++++++++++++++++++++++++++++++++= ++++ tests/qemu-iotests/041.out | 4 ++-- tests/qemu-iotests/iotests.py | 15 ++++++++++++++ 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041 index bc6cf78..2f54986 100755 --- a/tests/qemu-iotests/041 +++ b/tests/qemu-iotests/041 @@ -966,5 +966,51 @@ class TestRepairQuorum(iotests.QMPTestCase): # to check that this file is really driven by quorum self.vm.shutdown() =20 +# Test mirroring with a source that does not have any parents (not even a +# BlockBackend) +class TestOrphanedSource(iotests.QMPTestCase): + def setUp(self): + blk0 =3D { 'node-name': 'src', + 'driver': 'null-co' } + + blk1 =3D { 'node-name': 'dest', + 'driver': 'null-co' } + + blk2 =3D { 'node-name': 'dest-ro', + 'driver': 'null-co', + 'read-only': 'on' } + + self.vm =3D iotests.VM() + self.vm.add_blockdev(self.qmp_to_opts(blk0)) + self.vm.add_blockdev(self.qmp_to_opts(blk1)) + self.vm.add_blockdev(self.qmp_to_opts(blk2)) + self.vm.launch() + + def tearDown(self): + self.vm.shutdown() + + def test_no_job_id(self): + self.assert_no_active_block_jobs() + + result =3D self.vm.qmp('blockdev-mirror', device=3D'src', sync=3D'= full', + target=3D'dest') + self.assert_qmp(result, 'error/class', 'GenericError') + + def test_success(self): + self.assert_no_active_block_jobs() + + result =3D self.vm.qmp('blockdev-mirror', job_id=3D'job', device= =3D'src', + sync=3D'full', target=3D'dest') + self.assert_qmp(result, 'return', {}) + + self.complete_and_wait('job') + + def test_failing_permissions(self): + self.assert_no_active_block_jobs() + + result =3D self.vm.qmp('blockdev-mirror', device=3D'src', sync=3D'= full', + target=3D'dest-ro') + self.assert_qmp(result, 'error/class', 'GenericError') + if __name__ =3D=3D '__main__': iotests.main(supported_fmts=3D['qcow2', 'qed']) diff --git a/tests/qemu-iotests/041.out b/tests/qemu-iotests/041.out index b67d050..e30fd3b 100644 --- a/tests/qemu-iotests/041.out +++ b/tests/qemu-iotests/041.out @@ -1,5 +1,5 @@ -..........................................................................= .. +..........................................................................= ..... ---------------------------------------------------------------------- -Ran 76 tests +Ran 79 tests =20 OK diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index bec8eb4..abcf3c1 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -177,6 +177,14 @@ class VM(qtest.QEMUQtestMachine): self._num_drives +=3D 1 return self =20 + def add_blockdev(self, opts): + self._args.append('-blockdev') + if isinstance(opts, str): + self._args.append(opts) + else: + self._args.append(','.join(opts)) + return self + def pause_drive(self, drive, event=3DNone): '''Pause drive r/w operations''' if not event: @@ -235,6 +243,13 @@ class QMPTestCase(unittest.TestCase): output[basestr[:-1]] =3D obj # Strip trailing '.' return output =20 + def qmp_to_opts(self, obj): + obj =3D self.flatten_qmp_object(obj) + output_list =3D list() + for key in obj: + output_list +=3D [key + '=3D' + obj[key]] + return ','.join(output_list) + def assert_qmp_absent(self, d, path): try: result =3D self.dictpath(d, path) --=20 1.8.3.1 From nobody Sat May 4 17:05:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491573021048153.97228620923477; Fri, 7 Apr 2017 06:50:21 -0700 (PDT) Received: from localhost ([::1]:50981 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwUHL-0007Lz-PR for importer@patchew.org; Fri, 07 Apr 2017 09:50:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44877) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwUFC-0005sN-BX for qemu-devel@nongnu.org; Fri, 07 Apr 2017 09:48:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cwUFB-0003Vt-KG for qemu-devel@nongnu.org; Fri, 07 Apr 2017 09:48:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54940) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cwUF6-0003P7-AM; Fri, 07 Apr 2017 09:48:00 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4226A635D2; Fri, 7 Apr 2017 13:47:59 +0000 (UTC) Received: from noname.redhat.com (ovpn-117-140.ams2.redhat.com [10.36.117.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B314189DE; Fri, 7 Apr 2017 13:47:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4226A635D2 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4226A635D2 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 7 Apr 2017 15:47:41 +0200 Message-Id: <1491572865-8549-7-git-send-email-kwolf@redhat.com> In-Reply-To: <1491572865-8549-1-git-send-email-kwolf@redhat.com> References: <1491572865-8549-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 07 Apr 2017 13:47:59 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 06/10] qemu-img: img_create does not support image-opts, fix docs 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: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Jeff Cody The documentation and help for qemu-img claims that 'qemu-img create' will take the '--image-opts' argument. This is not true, so this patch removes those claims. Signed-off-by: Jeff Cody Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- qemu-img-cmds.hx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx index 9c9702c..8ac7822 100644 --- a/qemu-img-cmds.hx +++ b/qemu-img-cmds.hx @@ -22,9 +22,9 @@ STEXI ETEXI =20 DEF("create", img_create, - "create [-q] [--object objectdef] [--image-opts] [-f fmt] [-o options]= filename [size]") + "create [-q] [--object objectdef] [-f fmt] [-o options] filename [size= ]") STEXI -@item create [--object @var{objectdef}] [--image-opts] [-q] [-f @var{fmt}]= [-o @var{options}] @var{filename} [@var{size}] +@item create [--object @var{objectdef}] [-q] [-f @var{fmt}] [-o @var{optio= ns}] @var{filename} [@var{size}] ETEXI =20 DEF("commit", img_commit, --=20 1.8.3.1 From nobody Sat May 4 17:05:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491573651548725.3786529061329; Fri, 7 Apr 2017 07:00:51 -0700 (PDT) Received: from localhost ([::1]:51038 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwURW-0008Do-AW for importer@patchew.org; Fri, 07 Apr 2017 10:00:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44912) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwUFD-0005u2-O7 for qemu-devel@nongnu.org; Fri, 07 Apr 2017 09:48:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cwUFC-0003Wc-TM for qemu-devel@nongnu.org; Fri, 07 Apr 2017 09:48:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47300) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cwUF7-0003R6-Gj; Fri, 07 Apr 2017 09:48:01 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7B89919CF96; Fri, 7 Apr 2017 13:48:00 +0000 (UTC) Received: from noname.redhat.com (ovpn-117-140.ams2.redhat.com [10.36.117.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DC0288666; Fri, 7 Apr 2017 13:47:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7B89919CF96 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7B89919CF96 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 7 Apr 2017 15:47:42 +0200 Message-Id: <1491572865-8549-8-git-send-email-kwolf@redhat.com> In-Reply-To: <1491572865-8549-1-git-send-email-kwolf@redhat.com> References: <1491572865-8549-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 07 Apr 2017 13:48:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 07/10] block: Don't check permissions for copy on read 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: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The assertion is currently failing. We can't require callers to have write permissions when all they are doing is a read, so comment it out. Add a FIXME comment in the code so that the check is re-enabled when copy on read is refactored into its own filter driver. Reported-by: Richard W.M. Jones Signed-off-by: Kevin Wolf Reviewed-by: Richard W.M. Jones --- block/io.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/block/io.c b/block/io.c index 2709a70..7321dda 100644 --- a/block/io.c +++ b/block/io.c @@ -945,7 +945,14 @@ static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvC= hild *child, size_t skip_bytes; int ret; =20 - assert(child->perm & (BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE)); + /* FIXME We cannot require callers to have write permissions when all = they + * are doing is a read request. If we did things right, write permissi= ons + * would be obtained anyway, but internally by the copy-on-read code. = As + * long as it is implemented here rather than in a separat filter driv= er, + * the copy-on-read code doesn't have its own BdrvChild, however, for = which + * it could request permissions. Therefore we have to bypass the permi= ssion + * system for the moment. */ + // assert(child->perm & (BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE)); =20 /* Cover entire cluster so no additional backing file I/O is required = when * allocating cluster in the image file. --=20 1.8.3.1 From nobody Sat May 4 17:05:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491573233762841.7234840712936; Fri, 7 Apr 2017 06:53:53 -0700 (PDT) Received: from localhost ([::1]:51000 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwUKm-0001zi-Gg for importer@patchew.org; Fri, 07 Apr 2017 09:53:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44933) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwUFE-0005uN-JH for qemu-devel@nongnu.org; Fri, 07 Apr 2017 09:48:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cwUFD-0003XJ-VJ for qemu-devel@nongnu.org; Fri, 07 Apr 2017 09:48:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26824) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cwUF8-0003U1-Of; Fri, 07 Apr 2017 09:48:02 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B70B580086; Fri, 7 Apr 2017 13:48:01 +0000 (UTC) Received: from noname.redhat.com (ovpn-117-140.ams2.redhat.com [10.36.117.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id C8ED7857AE; Fri, 7 Apr 2017 13:48:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B70B580086 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B70B580086 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 7 Apr 2017 15:47:43 +0200 Message-Id: <1491572865-8549-9-git-send-email-kwolf@redhat.com> In-Reply-To: <1491572865-8549-1-git-send-email-kwolf@redhat.com> References: <1491572865-8549-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 07 Apr 2017 13:48:01 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 08/10] block: Fix unpaired aio_disable_external in external snapshot 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: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Fam Zheng bdrv_replace_child_noperm tries to hand over the quiesce_counter state from old bs to the new one, but if they are not on the same aio context this causes unbalance. Fix this by setting the correct aio context before calling bdrv_append(). Reported-by: Ed Swierk Reviewed-by: Eric Blake Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf --- blockdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blockdev.c b/blockdev.c index 040c152..4927914 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1772,6 +1772,8 @@ static void external_snapshot_prepare(BlkActionState = *common, return; } =20 + bdrv_set_aio_context(state->new_bs, state->aio_context); + /* This removes our old bs and adds the new bs. This is an operation t= hat * can fail, so we need to do it in .prepare; undoing it for abort is * always possible. */ @@ -1789,8 +1791,6 @@ static void external_snapshot_commit(BlkActionState *= common) ExternalSnapshotState *state =3D DO_UPCAST(ExternalSnapshotState, common, comm= on); =20 - bdrv_set_aio_context(state->new_bs, state->aio_context); - /* We don't need (or want) to use the transactional * bdrv_reopen_multiple() across all the entries at once, because we * don't want to abort all of them if one of them fails the reopen */ --=20 1.8.3.1 From nobody Sat May 4 17:05:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149157352674128.496561896984986; Fri, 7 Apr 2017 06:58:46 -0700 (PDT) Received: from localhost ([::1]:51022 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwUPV-0006Tq-KG for importer@patchew.org; Fri, 07 Apr 2017 09:58:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44905) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwUFD-0005te-CA for qemu-devel@nongnu.org; Fri, 07 Apr 2017 09:48:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cwUFC-0003WT-L4 for qemu-devel@nongnu.org; Fri, 07 Apr 2017 09:48:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37348) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cwUFA-0003VB-7u; Fri, 07 Apr 2017 09:48:04 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2DBF275726; Fri, 7 Apr 2017 13:48:03 +0000 (UTC) Received: from noname.redhat.com (ovpn-117-140.ams2.redhat.com [10.36.117.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 10EB588669; Fri, 7 Apr 2017 13:48:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2DBF275726 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2DBF275726 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 7 Apr 2017 15:47:44 +0200 Message-Id: <1491572865-8549-10-git-send-email-kwolf@redhat.com> In-Reply-To: <1491572865-8549-1-git-send-email-kwolf@redhat.com> References: <1491572865-8549-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 07 Apr 2017 13:48:03 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 09/10] block: Assert attached child node has right aio context 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: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Fam Zheng Suggested-by: Kevin Wolf Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf --- block.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/block.c b/block.c index 927ba89..b8a3011 100644 --- a/block.c +++ b/block.c @@ -1752,6 +1752,9 @@ static void bdrv_replace_child_noperm(BdrvChild *chil= d, { BlockDriverState *old_bs =3D child->bs; =20 + if (old_bs && new_bs) { + assert(bdrv_get_aio_context(old_bs) =3D=3D bdrv_get_aio_context(ne= w_bs)); + } if (old_bs) { if (old_bs->quiesce_counter && child->role->drained_end) { child->role->drained_end(child); @@ -1852,6 +1855,7 @@ BdrvChild *bdrv_attach_child(BlockDriverState *parent= _bs, bdrv_get_cumulative_perm(parent_bs, &perm, &shared_perm); =20 assert(parent_bs->drv); + assert(bdrv_get_aio_context(parent_bs) =3D=3D bdrv_get_aio_context(chi= ld_bs)); parent_bs->drv->bdrv_child_perm(parent_bs, NULL, child_role, perm, shared_perm, &perm, &shared_perm= ); =20 --=20 1.8.3.1 From nobody Sat May 4 17:05:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491573390607640.0011897386196; Fri, 7 Apr 2017 06:56:30 -0700 (PDT) Received: from localhost ([::1]:51015 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwUNJ-0004La-7l for importer@patchew.org; Fri, 07 Apr 2017 09:56:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44928) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwUFE-0005uM-7t for qemu-devel@nongnu.org; Fri, 07 Apr 2017 09:48:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cwUFD-0003Wz-Iw for qemu-devel@nongnu.org; Fri, 07 Apr 2017 09:48:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47368) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cwUFB-0003VT-Ht; Fri, 07 Apr 2017 09:48:05 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 81B652E6050; Fri, 7 Apr 2017 13:48:04 +0000 (UTC) Received: from noname.redhat.com (ovpn-117-140.ams2.redhat.com [10.36.117.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8007C857AE; Fri, 7 Apr 2017 13:48:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 81B652E6050 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 81B652E6050 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 7 Apr 2017 15:47:45 +0200 Message-Id: <1491572865-8549-11-git-send-email-kwolf@redhat.com> In-Reply-To: <1491572865-8549-1-git-send-email-kwolf@redhat.com> References: <1491572865-8549-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 07 Apr 2017 13:48:04 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 10/10] mirror: Fix aio context of mirror_top_bs 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: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Fam Zheng It should be moved to the same context as source, before inserting to the graph. Reviewed-by: Eric Blake Reviewed-by: Kevin Wolf Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf --- block/mirror.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/mirror.c b/block/mirror.c index 46ecd38..164438f 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1148,6 +1148,7 @@ static void mirror_start_job(const char *job_id, Bloc= kDriverState *bs, return; } mirror_top_bs->total_sectors =3D bs->total_sectors; + bdrv_set_aio_context(mirror_top_bs, bdrv_get_aio_context(bs)); =20 /* bdrv_append takes ownership of the mirror_top_bs reference, need to= keep * it alive until block_job_create() succeeds even if bs has no parent= . */ --=20 1.8.3.1