From nobody Fri May 3 04:16:50 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.zohomail.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 1506342722778159.5032986269906; Mon, 25 Sep 2017 05:32:02 -0700 (PDT) Received: from localhost ([::1]:42276 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwSYM-00079H-3f for importer@patchew.org; Mon, 25 Sep 2017 08:32:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47218) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwSUn-0003VG-KQ for qemu-devel@nongnu.org; Mon, 25 Sep 2017 08:28:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dwSUm-000655-Iv for qemu-devel@nongnu.org; Mon, 25 Sep 2017 08:28:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59094) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dwSUg-00061q-MX; Mon, 25 Sep 2017 08:28:14 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B938B4ACA4; Mon, 25 Sep 2017 12:28:13 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-119.ams2.redhat.com [10.36.116.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D7E960E3E; Mon, 25 Sep 2017 12:28:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B938B4ACA4 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=fail smtp.mailfrom=kwolf@redhat.com From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 25 Sep 2017 14:28:04 +0200 Message-Id: <20170925122808.14561-2-kwolf@redhat.com> In-Reply-To: <20170925122808.14561-1-kwolf@redhat.com> References: <20170925122808.14561-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 25 Sep 2017 12:28:13 +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] [PATCH 1/5] block: Introduce BdrvChildRole.update_filename 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, mreitz@redhat.com 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" There is no good reason for bdrv_drop_intermediate() to know the active layer above the subchain it is operating on - even more so, because the assumption that there is a single active layer above it is not generally true. In order to prepare removal of the active parameter, use a BdrvChildRole callback to update the backing file string in the overlay image instead of directly calling bdrv_change_backing_file(). Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- include/block/block_int.h | 6 ++++++ block.c | 33 ++++++++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 99abe2ce74..e6d53cc15e 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -544,6 +544,12 @@ struct BdrvChildRole { =20 void (*attach)(BdrvChild *child); void (*detach)(BdrvChild *child); + + /* Notifies the parent that the filename of its child has changed (e.g. + * because the direct child was removed from the backing chain), so th= at it + * can update its reference. */ + int (*update_filename)(BdrvChild *child, BlockDriverState *new_base, + const char *filename, Error **errp); }; =20 extern const BdrvChildRole child_file; diff --git a/block.c b/block.c index 5c65fac672..7ac8cd521b 100644 --- a/block.c +++ b/block.c @@ -981,6 +981,21 @@ static void bdrv_backing_options(int *child_flags, QDi= ct *child_options, *child_flags =3D flags; } =20 +static int bdrv_backing_update_filename(BdrvChild *c, BlockDriverState *ba= se, + const char *filename, Error **errp) +{ + BlockDriverState *parent =3D c->opaque; + int ret; + + ret =3D bdrv_change_backing_file(parent, filename, + base->drv ? base->drv->format_name : ""= ); + if (ret < 0) { + error_setg_errno(errp, ret, "Could not update backing file link"); + } + + return ret; +} + const BdrvChildRole child_backing =3D { .get_parent_desc =3D bdrv_child_get_parent_desc, .attach =3D bdrv_backing_attach, @@ -989,6 +1004,7 @@ const BdrvChildRole child_backing =3D { .drained_begin =3D bdrv_child_cb_drained_begin, .drained_end =3D bdrv_child_cb_drained_end, .inactivate =3D bdrv_child_cb_inactivate, + .update_filename =3D bdrv_backing_update_filename, }; =20 static int bdrv_open_flags(BlockDriverState *bs, int flags) @@ -3470,6 +3486,8 @@ int bdrv_drop_intermediate(BlockDriverState *active, = BlockDriverState *top, Error *local_err =3D NULL; int ret =3D -EIO; =20 + bdrv_ref(top); + if (!top->drv || !base->drv) { goto exit; } @@ -3494,11 +3512,15 @@ int bdrv_drop_intermediate(BlockDriverState *active= , BlockDriverState *top, } =20 /* success - we can delete the intermediate states, and link top->base= */ - backing_file_str =3D backing_file_str ? backing_file_str : base->filen= ame; - ret =3D bdrv_change_backing_file(new_top_bs, backing_file_str, - base->drv ? base->drv->format_name : ""= ); - if (ret) { - goto exit; + if (new_top_bs->backing->role->update_filename) { + backing_file_str =3D backing_file_str ? backing_file_str : base->f= ilename; + ret =3D new_top_bs->backing->role->update_filename(new_top_bs->bac= king, + base, backing_fil= e_str, + &local_err); + if (ret < 0) { + bdrv_set_backing_hd(new_top_bs, top, &error_abort); + goto exit; + } } =20 bdrv_set_backing_hd(new_top_bs, base, &local_err); @@ -3510,6 +3532,7 @@ int bdrv_drop_intermediate(BlockDriverState *active, = BlockDriverState *top, =20 ret =3D 0; exit: + bdrv_unref(top); return ret; } =20 --=20 2.13.5 From nobody Fri May 3 04:16:50 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.zohomail.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 1506342627837806.9002282625476; Mon, 25 Sep 2017 05:30:27 -0700 (PDT) Received: from localhost ([::1]:42263 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwSWf-00052Q-Js for importer@patchew.org; Mon, 25 Sep 2017 08:30:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47221) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwSUn-0003VJ-OH for qemu-devel@nongnu.org; Mon, 25 Sep 2017 08:28:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dwSUm-00065G-L5 for qemu-devel@nongnu.org; Mon, 25 Sep 2017 08:28:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45286) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dwSUi-00062f-6w; Mon, 25 Sep 2017 08:28:16 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4CF4CC0587DE; Mon, 25 Sep 2017 12:28:15 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-119.ams2.redhat.com [10.36.116.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1370F70A10; Mon, 25 Sep 2017 12:28:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4CF4CC0587DE 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=fail smtp.mailfrom=kwolf@redhat.com From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 25 Sep 2017 14:28:05 +0200 Message-Id: <20170925122808.14561-3-kwolf@redhat.com> In-Reply-To: <20170925122808.14561-1-kwolf@redhat.com> References: <20170925122808.14561-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 25 Sep 2017 12:28:15 +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] [PATCH 2/5] commit: Support multiple roots above top node 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, mreitz@redhat.com 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" This changes the commit block job to support operation in a graph where there is more than a single active layer that references the top node. This involves inserting the commit filter node not only on the path between the given active node and the top node, but between the top node and all of its parents. On completion, bdrv_drop_intermediate() must consider all parents for updating the backing file link. These parents may be backing files themselves and such read-only; reopen them temporarily if necessary. Previously this was achieved by the bdrv_reopen() calls in the commit block job that made overlay_bs read-write for the whole duration of the block job, even though write access is only needed on completion. Now that we consider all parents, overlay_bs is meaningless. It is left in place in this commit, but we'll remove it soon. Signed-off-by: Kevin Wolf --- block.c | 68 ++++++++++++++++++++++++++++++++++--------------------= ---- block/commit.c | 2 +- 2 files changed, 41 insertions(+), 29 deletions(-) diff --git a/block.c b/block.c index 7ac8cd521b..e57fab501d 100644 --- a/block.c +++ b/block.c @@ -985,14 +985,26 @@ static int bdrv_backing_update_filename(BdrvChild *c,= BlockDriverState *base, const char *filename, Error **errp) { BlockDriverState *parent =3D c->opaque; + int orig_flags =3D bdrv_get_flags(parent); int ret; =20 + if (!(orig_flags & BDRV_O_RDWR)) { + ret =3D bdrv_reopen(parent, orig_flags | BDRV_O_RDWR, errp); + if (ret < 0) { + return ret; + } + } + ret =3D bdrv_change_backing_file(parent, filename, base->drv ? base->drv->format_name : ""= ); if (ret < 0) { error_setg_errno(errp, ret, "Could not update backing file link"); } =20 + if (!(orig_flags & BDRV_O_RDWR)) { + bdrv_reopen(parent, orig_flags, NULL); + } + return ret; } =20 @@ -3482,7 +3494,7 @@ BlockDriverState *bdrv_find_base(BlockDriverState *bs) int bdrv_drop_intermediate(BlockDriverState *active, BlockDriverState *top, BlockDriverState *base, const char *backing_fil= e_str) { - BlockDriverState *new_top_bs =3D NULL; + BdrvChild *c, *next; Error *local_err =3D NULL; int ret =3D -EIO; =20 @@ -3492,42 +3504,42 @@ int bdrv_drop_intermediate(BlockDriverState *active= , BlockDriverState *top, goto exit; } =20 - new_top_bs =3D bdrv_find_overlay(active, top); - - if (new_top_bs =3D=3D NULL) { - /* we could not find the image above 'top', this is an error */ - goto exit; - } - - /* special case of new_top_bs->backing->bs already pointing to base - = nothing - * to do, no intermediate images */ - if (backing_bs(new_top_bs) =3D=3D base) { - ret =3D 0; - goto exit; - } - /* Make sure that base is in the backing chain of top */ if (!bdrv_chain_contains(top, base)) { goto exit; } =20 /* success - we can delete the intermediate states, and link top->base= */ - if (new_top_bs->backing->role->update_filename) { - backing_file_str =3D backing_file_str ? backing_file_str : base->f= ilename; - ret =3D new_top_bs->backing->role->update_filename(new_top_bs->bac= king, - base, backing_fil= e_str, - &local_err); - if (ret < 0) { - bdrv_set_backing_hd(new_top_bs, top, &error_abort); + backing_file_str =3D backing_file_str ? backing_file_str : base->filen= ame; + + QLIST_FOREACH_SAFE(c, &top->parents, next_parent, next) { + /* Check whether we are allowed to switch c from top to base */ + GSList *ignore_children =3D g_slist_prepend(NULL, c); + bdrv_check_update_perm(base, NULL, c->perm, c->shared_perm, + ignore_children, &local_err); + if (local_err) { + ret =3D -EPERM; + error_report_err(local_err); goto exit; } - } + g_slist_free(ignore_children); =20 - bdrv_set_backing_hd(new_top_bs, base, &local_err); - if (local_err) { - ret =3D -EPERM; - error_report_err(local_err); - goto exit; + /* If so, update the backing file path in the image file */ + if (c->role->update_filename) { + ret =3D c->role->update_filename(c, base, backing_file_str, + &local_err); + if (ret < 0) { + bdrv_abort_perm_update(base); + error_report_err(local_err); + goto exit; + } + } + + /* Do the actual switch in the in-memory graph. + * Completes bdrv_check_update_perm() transaction internally. */ + bdrv_ref(base); + bdrv_replace_child(c, base); + bdrv_unref(top); } =20 ret =3D 0; diff --git a/block/commit.c b/block/commit.c index 8f0e83578a..610e1cd8f5 100644 --- a/block/commit.c +++ b/block/commit.c @@ -350,7 +350,7 @@ void commit_start(const char *job_id, BlockDriverState = *bs, error_propagate(errp, local_err); goto fail; } - bdrv_set_backing_hd(overlay_bs, commit_top_bs, &local_err); + bdrv_replace_node(top, commit_top_bs, &local_err); if (local_err) { bdrv_unref(commit_top_bs); commit_top_bs =3D NULL; --=20 2.13.5 From nobody Fri May 3 04:16:50 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.zohomail.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 1506342633831702.4782056279643; Mon, 25 Sep 2017 05:30:33 -0700 (PDT) Received: from localhost ([::1]:42264 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwSWp-0005AA-0u for importer@patchew.org; Mon, 25 Sep 2017 08:30:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47284) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwSUs-0003eO-4Y for qemu-devel@nongnu.org; Mon, 25 Sep 2017 08:28:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dwSUm-000650-Gy for qemu-devel@nongnu.org; Mon, 25 Sep 2017 08:28:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45324) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dwSUj-00063R-TB; Mon, 25 Sep 2017 08:28:18 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D5269C0587DE; Mon, 25 Sep 2017 12:28:16 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-119.ams2.redhat.com [10.36.116.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9AF2A70A10; Mon, 25 Sep 2017 12:28:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D5269C0587DE 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=fail smtp.mailfrom=kwolf@redhat.com From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 25 Sep 2017 14:28:06 +0200 Message-Id: <20170925122808.14561-4-kwolf@redhat.com> In-Reply-To: <20170925122808.14561-1-kwolf@redhat.com> References: <20170925122808.14561-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 25 Sep 2017 12:28:16 +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] [PATCH 3/5] qemu-iotests: Allow QMP pretty printing in common.qemu 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, mreitz@redhat.com 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" QMP responses to certain commands can become quite long, which doesn't only make reading them hard, but also means that the maximum line length in patch emails can be exceeded. Allow tests to switch to QMP pretty printing, which results in more, but shorter lines. We also need to make sure to keep indentation in the response for this to work as expected. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- tests/qemu-iotests/common.qemu | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/qemu-iotests/common.qemu b/tests/qemu-iotests/common.qemu index 7645f1dc72..92739a1eac 100644 --- a/tests/qemu-iotests/common.qemu +++ b/tests/qemu-iotests/common.qemu @@ -55,13 +55,13 @@ function _timed_wait_for() shift =20 QEMU_STATUS[$h]=3D0 - while read -t ${QEMU_COMM_TIMEOUT} resp <&${QEMU_OUT[$h]} + while IFS=3D read -t ${QEMU_COMM_TIMEOUT} resp <&${QEMU_OUT[$h]} do if [ -z "${silent}" ]; then echo "${resp}" | _filter_testdir | _filter_qemu \ | _filter_qemu_io | _filter_qmp | _filter_hmp fi - grep -q "${*}" < <(echo ${resp}) + grep -q "${*}" < <(echo "${resp}") if [ $? -eq 0 ]; then return fi @@ -129,6 +129,7 @@ function _send_qemu_cmd() # $qemu_comm_method: set this variable to 'monitor' (case insensitive) # to use the QEMU HMP monitor for communication. # Otherwise, the default of QMP is used. +# $qmp_pretty: Set this variable to 'y' to enable QMP pretty printing. # $keep_stderr: Set this variable to 'y' to keep QEMU's stderr output on s= tderr. # If this variable is empty, stderr will be redirected to st= dout. # Returns: @@ -145,7 +146,11 @@ function _launch_qemu() comm=3D"-monitor stdio" else local qemu_comm_method=3D"qmp" - comm=3D"-monitor none -qmp stdio" + if [ "$qmp_pretty" =3D "y" ]; then + comm=3D"-monitor none -qmp-pretty stdio" + else + comm=3D"-monitor none -qmp stdio" + fi fi =20 fifo_out=3D${QEMU_FIFO_OUT}_${_QEMU_HANDLE} @@ -192,6 +197,9 @@ function _launch_qemu() then # Don't print response, since it has version information in it silent=3Dyes _timed_wait_for ${_QEMU_HANDLE} "capabilities" + if [ "$qmp_pretty" =3D "y" ]; then + silent=3Dyes _timed_wait_for ${_QEMU_HANDLE} "^}" + fi fi QEMU_HANDLE=3D${_QEMU_HANDLE} let _QEMU_HANDLE++ --=20 2.13.5 From nobody Fri May 3 04:16:50 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.zohomail.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 1506342846438651.2892867647927; Mon, 25 Sep 2017 05:34:06 -0700 (PDT) Received: from localhost ([::1]:42281 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwSaL-0000f2-LL for importer@patchew.org; Mon, 25 Sep 2017 08:34:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47314) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwSUw-0003k0-PU for qemu-devel@nongnu.org; Mon, 25 Sep 2017 08:28:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dwSUr-00067t-Un for qemu-devel@nongnu.org; Mon, 25 Sep 2017 08:28:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46302) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dwSUl-000642-M7; Mon, 25 Sep 2017 08:28:20 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BC47D7E42A; Mon, 25 Sep 2017 12:28:18 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-119.ams2.redhat.com [10.36.116.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2ECAF709F2; Mon, 25 Sep 2017 12:28:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BC47D7E42A 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=fail smtp.mailfrom=kwolf@redhat.com From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 25 Sep 2017 14:28:07 +0200 Message-Id: <20170925122808.14561-5-kwolf@redhat.com> In-Reply-To: <20170925122808.14561-1-kwolf@redhat.com> References: <20170925122808.14561-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 25 Sep 2017 12:28:18 +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] [PATCH 4/5] qemu-iotests: Test commit block job where top has two parents 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, mreitz@redhat.com 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" Signed-off-by: Kevin Wolf --- tests/qemu-iotests/191 | 152 +++++++++ tests/qemu-iotests/191.out | 827 +++++++++++++++++++++++++++++++++++++++++= ++++ tests/qemu-iotests/group | 1 + 3 files changed, 980 insertions(+) create mode 100755 tests/qemu-iotests/191 create mode 100644 tests/qemu-iotests/191.out diff --git a/tests/qemu-iotests/191 b/tests/qemu-iotests/191 new file mode 100755 index 0000000000..a4e0d691fa --- /dev/null +++ b/tests/qemu-iotests/191 @@ -0,0 +1,152 @@ +#!/bin/bash +# +# Test commit block job where top has two parents +# +# Copyright (C) 2017 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# creator +owner=3Dkwolf@redhat.com + +seq=3D`basename $0` +echo "QA output created by $seq" + +here=3D`pwd` +status=3D1 # failure is the default! + +MIG_SOCKET=3D"${TEST_DIR}/migrate" + +_cleanup() +{ + rm -f "${TEST_IMG}.mid" + rm -f "${TEST_IMG}.ovl2" + rm -f "${TEST_IMG}.ovl3" + _cleanup_test_img + _cleanup_qemu +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.qemu + +_supported_fmt qcow2 +_supported_proto file +_supported_os Linux + +size=3D64M + +echo +echo =3D=3D=3D Preparing and starting VM =3D=3D=3D +echo + +TEST_IMG=3D"${TEST_IMG}.base" _make_test_img $size +TEST_IMG=3D"${TEST_IMG}.mid" _make_test_img -b "${TEST_IMG}.base" +_make_test_img -b "${TEST_IMG}.mid" +TEST_IMG=3D"${TEST_IMG}.ovl2" _make_test_img -b "${TEST_IMG}.mid" + +$QEMU_IO -c 'write -P 0x55 1M 64k' "${TEST_IMG}.mid" | _filter_qemu_io + +qemu_comm_method=3D"qmp" +qmp_pretty=3D"y" + +_launch_qemu \ + -blockdev "driver=3D${IMGFMT},file.driver=3Dfile,file.filename=3D${TES= T_IMG}.base,node-name=3Dbase" \ + -blockdev "driver=3D${IMGFMT},file.driver=3Dfile,file.filename=3D${TES= T_IMG}.mid,node-name=3Dmid,backing=3Dbase" \ + -blockdev "driver=3D${IMGFMT},file.driver=3Dfile,file.filename=3D${TES= T_IMG},node-name=3Dtop,backing=3Dmid" \ + -blockdev "driver=3D${IMGFMT},file.driver=3Dfile,file.filename=3D${TES= T_IMG}.ovl2,node-name=3Dtop2,backing=3Dmid" +h=3D$QEMU_HANDLE +_send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" '^}' + +echo +echo =3D=3D=3D Perform commit job =3D=3D=3D +echo + +_send_qemu_cmd $h \ + "{ 'execute': 'block-commit', + 'arguments': { 'job-id': 'commit0', + 'device': 'top', + 'base':'$TEST_IMG.base', + 'top': '$TEST_IMG.mid' } }" \ + "BLOCK_JOB_COMPLETED" +_send_qemu_cmd $h "" "^}" + +echo +echo =3D=3D=3D Check that both top and top2 point to base now =3D=3D=3D +echo + +_send_qemu_cmd $h "{ 'execute': 'query-named-block-nodes' }" "^}" | + _filter_generated_node_ids + +_send_qemu_cmd $h "{ 'execute': 'quit' }" "^}" +wait=3D1 _cleanup_qemu + +_img_info +TEST_IMG=3D"$TEST_IMG.ovl2" _img_info + + +echo +echo =3D=3D=3D Preparing and starting VM with -drive =3D=3D=3D +echo + +TEST_IMG=3D"${TEST_IMG}.base" _make_test_img $size +TEST_IMG=3D"${TEST_IMG}.mid" _make_test_img -b "${TEST_IMG}.base" +_make_test_img -b "${TEST_IMG}.mid" +TEST_IMG=3D"${TEST_IMG}.ovl2" _make_test_img -b "${TEST_IMG}.mid" +TEST_IMG=3D"${TEST_IMG}.ovl3" _make_test_img -b "${TEST_IMG}.ovl2" + +$QEMU_IO -c 'write -P 0x55 1M 64k' "${TEST_IMG}.mid" | _filter_qemu_io + +qemu_comm_method=3D"qmp" +qmp_pretty=3D"y" + +_launch_qemu \ + -drive "driver=3D${IMGFMT},file=3D${TEST_IMG},node-name=3Dtop,backing.= node-name=3Dmid" \ + -drive "driver=3D${IMGFMT},file=3D${TEST_IMG}.ovl3,node-name=3Dtop2,ba= cking.backing=3Dmid" +h=3D$QEMU_HANDLE +_send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" '^}' + +echo +echo =3D=3D=3D Perform commit job =3D=3D=3D +echo + +_send_qemu_cmd $h \ + "{ 'execute': 'block-commit', + 'arguments': { 'job-id': 'commit0', + 'device': 'top', + 'base':'$TEST_IMG.base', + 'top': '$TEST_IMG.mid' } }" \ + "BLOCK_JOB_COMPLETED" +_send_qemu_cmd $h "" "^}" + +echo +echo =3D=3D=3D Check that both top and top2 point to base now =3D=3D=3D +echo + +_send_qemu_cmd $h "{ 'execute': 'query-named-block-nodes' }" "^}" | + _filter_generated_node_ids + +_send_qemu_cmd $h "{ 'execute': 'quit' }" "^}" +wait=3D1 _cleanup_qemu + +_img_info +TEST_IMG=3D"$TEST_IMG.ovl2" _img_info + +# success, all done +echo "*** done" +rm -f $seq.full +status=3D0 diff --git a/tests/qemu-iotests/191.out b/tests/qemu-iotests/191.out new file mode 100644 index 0000000000..7bfcd2d5d8 --- /dev/null +++ b/tests/qemu-iotests/191.out @@ -0,0 +1,827 @@ +QA output created by 191 + +=3D=3D=3D Preparing and starting VM =3D=3D=3D + +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D67108864 +Formatting 'TEST_DIR/t.IMGFMT.mid', fmt=3DIMGFMT size=3D67108864 backing_f= ile=3DTEST_DIR/t.IMGFMT.base +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 backing_file= =3DTEST_DIR/t.IMGFMT.mid +Formatting 'TEST_DIR/t.IMGFMT.ovl2', fmt=3DIMGFMT size=3D67108864 backing_= file=3DTEST_DIR/t.IMGFMT.mid +wrote 65536/65536 bytes at offset 1048576 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +{ + "return": { + } +} + +=3D=3D=3D Perform commit job =3D=3D=3D + +{ + "return": { + } +} +{ + "timestamp": { + "seconds": TIMESTAMP, + "microseconds": TIMESTAMP + }, + "event": "BLOCK_JOB_COMPLETED", + "data": { + "device": "commit0", + "len": 67108864, + "offset": 67108864, + "speed": 0, + "type": "commit" + } +} + +=3D=3D=3D Check that both top and top2 point to base now =3D=3D=3D + +{ + "return": [ + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "backing-image": { + "virtual-size": 67108864, + "filename": "TEST_DIR/t.qcow2.base", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 397312, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "refcount-bits": 16, + "corrupt": false + } + }, + "dirty-flag": false + }, + "backing-filename-format": "qcow2", + "virtual-size": 67108864, + "filename": "TEST_DIR/t.qcow2.ovl2", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 200704, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "refcount-bits": 16, + "corrupt": false + } + }, + "full-backing-filename": "TEST_DIR/t.qcow2.base", + "backing-filename": "TEST_DIR/t.qcow2.base", + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "top2", + "backing_file_depth": 1, + "drv": "qcow2", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "backing_file": "TEST_DIR/t.qcow2.base", + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "TEST_DIR/t.qcow2.ovl2", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 197120, + "filename": "TEST_DIR/t.qcow2.ovl2", + "format": "file", + "actual-size": 200704, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "NODE_NAME", + "backing_file_depth": 0, + "drv": "file", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "TEST_DIR/t.qcow2.ovl2", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "backing-image": { + "virtual-size": 67108864, + "filename": "TEST_DIR/t.qcow2.base", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 397312, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "refcount-bits": 16, + "corrupt": false + } + }, + "dirty-flag": false + }, + "backing-filename-format": "qcow2", + "virtual-size": 67108864, + "filename": "TEST_DIR/t.qcow2", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 200704, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "refcount-bits": 16, + "corrupt": false + } + }, + "full-backing-filename": "TEST_DIR/t.qcow2.base", + "backing-filename": "TEST_DIR/t.qcow2.base", + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "top", + "backing_file_depth": 1, + "drv": "qcow2", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "backing_file": "TEST_DIR/t.qcow2.base", + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "TEST_DIR/t.qcow2", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 197120, + "filename": "TEST_DIR/t.qcow2", + "format": "file", + "actual-size": 200704, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "NODE_NAME", + "backing_file_depth": 0, + "drv": "file", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "TEST_DIR/t.qcow2", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "backing-image": { + "virtual-size": 67108864, + "filename": "TEST_DIR/t.qcow2.base", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 397312, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "refcount-bits": 16, + "corrupt": false + } + }, + "dirty-flag": false + }, + "backing-filename-format": "qcow2", + "virtual-size": 67108864, + "filename": "TEST_DIR/t.qcow2.mid", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 397312, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "refcount-bits": 16, + "corrupt": false + } + }, + "full-backing-filename": "TEST_DIR/t.qcow2.base", + "backing-filename": "TEST_DIR/t.qcow2.base", + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "mid", + "backing_file_depth": 1, + "drv": "qcow2", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "backing_file": "TEST_DIR/t.qcow2.base", + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "TEST_DIR/t.qcow2.mid", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 393216, + "filename": "TEST_DIR/t.qcow2.mid", + "format": "file", + "actual-size": 397312, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "NODE_NAME", + "backing_file_depth": 0, + "drv": "file", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "TEST_DIR/t.qcow2.mid", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 67108864, + "filename": "TEST_DIR/t.qcow2.base", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 397312, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "refcount-bits": 16, + "corrupt": false + } + }, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "base", + "backing_file_depth": 0, + "drv": "qcow2", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "TEST_DIR/t.qcow2.base", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 393216, + "filename": "TEST_DIR/t.qcow2.base", + "format": "file", + "actual-size": 397312, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "NODE_NAME", + "backing_file_depth": 0, + "drv": "file", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "TEST_DIR/t.qcow2.base", + "encryption_key_missing": false + } + ] +} +{ + "return": { + } +} +{ + "timestamp": { + "seconds": TIMESTAMP, + "microseconds": TIMESTAMP + }, + "event": "SHUTDOWN", + "data": { + "guest": false + } +} +image: TEST_DIR/t.IMGFMT +file format: IMGFMT +virtual size: 64M (67108864 bytes) +cluster_size: 65536 +backing file: TEST_DIR/t.IMGFMT.base +backing file format: IMGFMT +image: TEST_DIR/t.IMGFMT.ovl2 +file format: IMGFMT +virtual size: 64M (67108864 bytes) +cluster_size: 65536 +backing file: TEST_DIR/t.IMGFMT.base +backing file format: IMGFMT + +=3D=3D=3D Preparing and starting VM with -drive =3D=3D=3D + +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D67108864 +Formatting 'TEST_DIR/t.IMGFMT.mid', fmt=3DIMGFMT size=3D67108864 backing_f= ile=3DTEST_DIR/t.IMGFMT.base +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 backing_file= =3DTEST_DIR/t.IMGFMT.mid +Formatting 'TEST_DIR/t.IMGFMT.ovl2', fmt=3DIMGFMT size=3D67108864 backing_= file=3DTEST_DIR/t.IMGFMT.mid +Formatting 'TEST_DIR/t.IMGFMT.ovl3', fmt=3DIMGFMT size=3D67108864 backing_= file=3DTEST_DIR/t.IMGFMT.ovl2 +wrote 65536/65536 bytes at offset 1048576 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +{ + "return": { + } +} + +=3D=3D=3D Perform commit job =3D=3D=3D + +{ + "return": { + } +} +{ + "timestamp": { + "seconds": TIMESTAMP, + "microseconds": TIMESTAMP + }, + "event": "BLOCK_JOB_COMPLETED", + "data": { + "device": "commit0", + "len": 67108864, + "offset": 67108864, + "speed": 0, + "type": "commit" + } +} + +=3D=3D=3D Check that both top and top2 point to base now =3D=3D=3D + +{ + "return": [ + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "backing-image": { + "virtual-size": 67108864, + "filename": "TEST_DIR/t.qcow2.base", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 397312, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "refcount-bits": 16, + "corrupt": false + } + }, + "dirty-flag": false + }, + "backing-filename-format": "qcow2", + "virtual-size": 67108864, + "filename": "TEST_DIR/t.qcow2.ovl2", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 200704, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "refcount-bits": 16, + "corrupt": false + } + }, + "full-backing-filename": "TEST_DIR/t.qcow2.base", + "backing-filename": "TEST_DIR/t.qcow2.base", + "dirty-flag": false + }, + "iops_wr": 0, + "ro": true, + "node-name": "NODE_NAME", + "backing_file_depth": 1, + "drv": "qcow2", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "backing_file": "TEST_DIR/t.qcow2.base", + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "TEST_DIR/t.qcow2.ovl2", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 197120, + "filename": "TEST_DIR/t.qcow2.ovl2", + "format": "file", + "actual-size": 200704, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": true, + "node-name": "NODE_NAME", + "backing_file_depth": 0, + "drv": "file", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "TEST_DIR/t.qcow2.ovl2", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "backing-image": { + "backing-image": { + "virtual-size": 67108864, + "filename": "TEST_DIR/t.qcow2.base", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 397312, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "refcount-bits": 16, + "corrupt": false + } + }, + "dirty-flag": false + }, + "backing-filename-format": "qcow2", + "virtual-size": 67108864, + "filename": "TEST_DIR/t.qcow2.ovl2", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 200704, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "refcount-bits": 16, + "corrupt": false + } + }, + "full-backing-filename": "TEST_DIR/t.qcow2.base", + "backing-filename": "TEST_DIR/t.qcow2.base", + "dirty-flag": false + }, + "backing-filename-format": "qcow2", + "virtual-size": 67108864, + "filename": "TEST_DIR/t.qcow2.ovl3", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 200704, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "refcount-bits": 16, + "corrupt": false + } + }, + "full-backing-filename": "TEST_DIR/t.qcow2.ovl2", + "backing-filename": "TEST_DIR/t.qcow2.ovl2", + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "top2", + "backing_file_depth": 2, + "drv": "qcow2", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "backing_file": "TEST_DIR/t.qcow2.ovl2", + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "TEST_DIR/t.qcow2.ovl3", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 197120, + "filename": "TEST_DIR/t.qcow2.ovl3", + "format": "file", + "actual-size": 200704, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "NODE_NAME", + "backing_file_depth": 0, + "drv": "file", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "TEST_DIR/t.qcow2.ovl3", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 67108864, + "filename": "TEST_DIR/t.qcow2.base", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 397312, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "refcount-bits": 16, + "corrupt": false + } + }, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": true, + "node-name": "NODE_NAME", + "backing_file_depth": 0, + "drv": "qcow2", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "TEST_DIR/t.qcow2.base", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 393216, + "filename": "TEST_DIR/t.qcow2.base", + "format": "file", + "actual-size": 397312, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": true, + "node-name": "NODE_NAME", + "backing_file_depth": 0, + "drv": "file", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "TEST_DIR/t.qcow2.base", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "backing-image": { + "virtual-size": 67108864, + "filename": "TEST_DIR/t.qcow2.base", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 397312, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "refcount-bits": 16, + "corrupt": false + } + }, + "dirty-flag": false + }, + "backing-filename-format": "qcow2", + "virtual-size": 67108864, + "filename": "TEST_DIR/t.qcow2", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 200704, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "refcount-bits": 16, + "corrupt": false + } + }, + "full-backing-filename": "TEST_DIR/t.qcow2.base", + "backing-filename": "TEST_DIR/t.qcow2.base", + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "top", + "backing_file_depth": 1, + "drv": "qcow2", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "backing_file": "TEST_DIR/t.qcow2.base", + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "TEST_DIR/t.qcow2", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 197120, + "filename": "TEST_DIR/t.qcow2", + "format": "file", + "actual-size": 200704, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "NODE_NAME", + "backing_file_depth": 0, + "drv": "file", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "TEST_DIR/t.qcow2", + "encryption_key_missing": false + } + ] +} +{ + "return": { + } +} +{ + "timestamp": { + "seconds": TIMESTAMP, + "microseconds": TIMESTAMP + }, + "event": "SHUTDOWN", + "data": { + "guest": false + } +} +image: TEST_DIR/t.IMGFMT +file format: IMGFMT +virtual size: 64M (67108864 bytes) +cluster_size: 65536 +backing file: TEST_DIR/t.IMGFMT.base +backing file format: IMGFMT +image: TEST_DIR/t.IMGFMT.ovl2 +file format: IMGFMT +virtual size: 64M (67108864 bytes) +cluster_size: 65536 +backing file: TEST_DIR/t.IMGFMT.base +backing file format: IMGFMT +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 108339cd03..63d4ee052c 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -187,6 +187,7 @@ 188 rw auto quick 189 rw auto 190 rw auto quick +191 rw auto 192 rw auto quick 194 rw auto migration quick 195 rw auto quick --=20 2.13.5 From nobody Fri May 3 04:16:50 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.zohomail.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 1506342778114903.4664175296457; Mon, 25 Sep 2017 05:32:58 -0700 (PDT) Received: from localhost ([::1]:42277 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwSZ9-0008La-A5 for importer@patchew.org; Mon, 25 Sep 2017 08:32:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwSUw-0003kM-Uv for qemu-devel@nongnu.org; Mon, 25 Sep 2017 08:28:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dwSUt-00068b-9Z for qemu-devel@nongnu.org; Mon, 25 Sep 2017 08:28:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45472) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dwSUn-00065D-6E; Mon, 25 Sep 2017 08:28:21 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 51D7BC0587EF; Mon, 25 Sep 2017 12:28:20 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-119.ams2.redhat.com [10.36.116.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 15A9460E3E; Mon, 25 Sep 2017 12:28:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 51D7BC0587EF 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=fail smtp.mailfrom=kwolf@redhat.com From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 25 Sep 2017 14:28:08 +0200 Message-Id: <20170925122808.14561-6-kwolf@redhat.com> In-Reply-To: <20170925122808.14561-1-kwolf@redhat.com> References: <20170925122808.14561-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 25 Sep 2017 12:28:20 +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] [PATCH 5/5] commit: Remove overlay_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, mreitz@redhat.com 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" We don't need to make any assumptions about the graph layout above the top node of the commit operation any more. Remove the use of bdrv_find_overlay() and related variables from the commit job code. bdrv_drop_intermediate() doesn't use the 'active' parameter any more, so we can just drop it. The overlay node was previously added to the block job to get a BLK_PERM_GRAPH_MOD. We really need to respect those permissions in bdrv_drop_intermediate() now, but as long as we haven't figured out yet how BLK_PERM_GRAPH_MOD is actually supposed to work, just leave a TODO comment there. With this change, it is now possible to perform another block job on an overlay node without conflicts. qemu-iotests 030 is changed accordingly. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- include/block/block.h | 3 +-- block.c | 6 +++-- block/commit.c | 62 ++++++++++++----------------------------------= ---- tests/qemu-iotests/030 | 4 ---- 4 files changed, 20 insertions(+), 55 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index 3c3af462e4..d5c2731a03 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -315,8 +315,7 @@ int bdrv_commit(BlockDriverState *bs); int bdrv_change_backing_file(BlockDriverState *bs, const char *backing_file, const char *backing_fmt); void bdrv_register(BlockDriver *bdrv); -int bdrv_drop_intermediate(BlockDriverState *active, BlockDriverState *top, - BlockDriverState *base, +int bdrv_drop_intermediate(BlockDriverState *top, BlockDriverState *base, const char *backing_file_str); BlockDriverState *bdrv_find_overlay(BlockDriverState *active, BlockDriverState *bs); diff --git a/block.c b/block.c index e57fab501d..5f2d7222a5 100644 --- a/block.c +++ b/block.c @@ -3491,8 +3491,8 @@ BlockDriverState *bdrv_find_base(BlockDriverState *bs) * if active =3D=3D top, that is considered an error * */ -int bdrv_drop_intermediate(BlockDriverState *active, BlockDriverState *top, - BlockDriverState *base, const char *backing_fil= e_str) +int bdrv_drop_intermediate(BlockDriverState *top, BlockDriverState *base, + const char *backing_file_str) { BdrvChild *c, *next; Error *local_err =3D NULL; @@ -3510,6 +3510,8 @@ int bdrv_drop_intermediate(BlockDriverState *active, = BlockDriverState *top, } =20 /* success - we can delete the intermediate states, and link top->base= */ + /* TODO Check graph modification op blockers (BLK_PERM_GRAPH_MOD) once + * we've figured out how they should work. */ backing_file_str =3D backing_file_str ? backing_file_str : base->filen= ame; =20 QLIST_FOREACH_SAFE(c, &top->parents, next_parent, next) { diff --git a/block/commit.c b/block/commit.c index 610e1cd8f5..5036eec434 100644 --- a/block/commit.c +++ b/block/commit.c @@ -36,13 +36,11 @@ enum { typedef struct CommitBlockJob { BlockJob common; RateLimit limit; - BlockDriverState *active; BlockDriverState *commit_top_bs; BlockBackend *top; BlockBackend *base; BlockdevOnError on_error; int base_flags; - int orig_overlay_flags; char *backing_file_str; } CommitBlockJob; =20 @@ -81,18 +79,15 @@ static void commit_complete(BlockJob *job, void *opaque) { CommitBlockJob *s =3D container_of(job, CommitBlockJob, common); CommitCompleteData *data =3D opaque; - BlockDriverState *active =3D s->active; BlockDriverState *top =3D blk_bs(s->top); BlockDriverState *base =3D blk_bs(s->base); - BlockDriverState *overlay_bs =3D bdrv_find_overlay(active, s->commit_t= op_bs); + BlockDriverState *commit_top_bs =3D s->commit_top_bs; int ret =3D data->ret; bool remove_commit_top_bs =3D false; =20 - /* Make sure overlay_bs and top stay around until bdrv_set_backing_hd(= ) */ + /* Make sure commit_top_bs and top stay around until bdrv_replace_node= () */ bdrv_ref(top); - if (overlay_bs) { - bdrv_ref(overlay_bs); - } + bdrv_ref(commit_top_bs); =20 /* Remove base node parent that still uses BLK_PERM_WRITE/RESIZE before * the normal backing chain can be restored. */ @@ -100,9 +95,9 @@ static void commit_complete(BlockJob *job, void *opaque) =20 if (!block_job_is_cancelled(&s->common) && ret =3D=3D 0) { /* success */ - ret =3D bdrv_drop_intermediate(active, s->commit_top_bs, base, + ret =3D bdrv_drop_intermediate(s->commit_top_bs, base, s->backing_file_str); - } else if (overlay_bs) { + } else { /* XXX Can (or should) we somehow keep 'consistent read' blocked e= ven * after the failed/cancelled commit job is gone? If we already wr= ote * something to base, the intermediate images aren't valid any mor= e. */ @@ -115,9 +110,6 @@ static void commit_complete(BlockJob *job, void *opaque) if (s->base_flags !=3D bdrv_get_flags(base)) { bdrv_reopen(base, s->base_flags, NULL); } - if (overlay_bs && s->orig_overlay_flags !=3D bdrv_get_flags(overlay_bs= )) { - bdrv_reopen(overlay_bs, s->orig_overlay_flags, NULL); - } g_free(s->backing_file_str); blk_unref(s->top); =20 @@ -134,10 +126,13 @@ static void commit_complete(BlockJob *job, void *opaq= ue) * filter driver from the backing chain. Do this as the final step so = that * the 'consistent read' permission can be granted. */ if (remove_commit_top_bs) { - bdrv_set_backing_hd(overlay_bs, top, &error_abort); + bdrv_child_try_set_perm(commit_top_bs->backing, 0, BLK_PERM_ALL, + &error_abort); + bdrv_replace_node(commit_top_bs, backing_bs(commit_top_bs), + &error_abort); } =20 - bdrv_unref(overlay_bs); + bdrv_unref(commit_top_bs); bdrv_unref(top); } =20 @@ -283,10 +278,8 @@ void commit_start(const char *job_id, BlockDriverState= *bs, { CommitBlockJob *s; BlockReopenQueue *reopen_queue =3D NULL; - int orig_overlay_flags; int orig_base_flags; BlockDriverState *iter; - BlockDriverState *overlay_bs; BlockDriverState *commit_top_bs =3D NULL; Error *local_err =3D NULL; int ret; @@ -297,31 +290,19 @@ void commit_start(const char *job_id, BlockDriverStat= e *bs, return; } =20 - overlay_bs =3D bdrv_find_overlay(bs, top); - - if (overlay_bs =3D=3D NULL) { - error_setg(errp, "Could not find overlay image for %s:", top->file= name); - return; - } - s =3D block_job_create(job_id, &commit_job_driver, bs, 0, BLK_PERM_ALL, speed, BLOCK_JOB_DEFAULT, NULL, NULL, errp); if (!s) { return; } =20 - orig_base_flags =3D bdrv_get_flags(base); - orig_overlay_flags =3D bdrv_get_flags(overlay_bs); - - /* convert base & overlay_bs to r/w, if necessary */ + /* convert base to r/w, if necessary */ + orig_base_flags =3D bdrv_get_flags(base); if (!(orig_base_flags & BDRV_O_RDWR)) { reopen_queue =3D bdrv_reopen_queue(reopen_queue, base, NULL, orig_base_flags | BDRV_O_RDWR); } - if (!(orig_overlay_flags & BDRV_O_RDWR)) { - reopen_queue =3D bdrv_reopen_queue(reopen_queue, overlay_bs, NULL, - orig_overlay_flags | BDRV_O_RDWR); - } + if (reopen_queue) { bdrv_reopen_multiple(bdrv_get_aio_context(bs), reopen_queue, &loca= l_err); if (local_err !=3D NULL) { @@ -382,14 +363,6 @@ void commit_start(const char *job_id, BlockDriverState= *bs, goto fail; } =20 - /* overlay_bs must be blocked because it needs to be modified to - * update the backing image string. */ - ret =3D block_job_add_bdrv(&s->common, "overlay of top", overlay_bs, - BLK_PERM_GRAPH_MOD, BLK_PERM_ALL, errp); - if (ret < 0) { - goto fail; - } - s->base =3D blk_new(BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE | BLK_PERM_RESIZE, @@ -408,13 +381,8 @@ void commit_start(const char *job_id, BlockDriverState= *bs, goto fail; } =20 - s->active =3D bs; - - s->base_flags =3D orig_base_flags; - s->orig_overlay_flags =3D orig_overlay_flags; - + s->base_flags =3D orig_base_flags; s->backing_file_str =3D g_strdup(backing_file_str); - s->on_error =3D on_error; =20 trace_commit_start(bs, base, top, s); @@ -429,7 +397,7 @@ fail: blk_unref(s->top); } if (commit_top_bs) { - bdrv_set_backing_hd(overlay_bs, top, &error_abort); + bdrv_replace_node(commit_top_bs, top, &error_abort); } block_job_early_fail(&s->common); } diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030 index d745cb4cde..18838948fa 100755 --- a/tests/qemu-iotests/030 +++ b/tests/qemu-iotests/030 @@ -287,10 +287,6 @@ class TestParallelOps(iotests.QMPTestCase): result =3D self.vm.qmp('block-stream', device=3D'node6', base=3Dse= lf.imgs[4], job_id=3D'stream-node6-v2') self.assert_qmp(result, 'error/class', 'GenericError') =20 - # This fails because block-commit needs to block node6, the overla= y of the 'top' image - result =3D self.vm.qmp('block-stream', device=3D'node7', base=3Dse= lf.imgs[5], job_id=3D'stream-node6-v3') - self.assert_qmp(result, 'error/class', 'GenericError') - # This fails because block-commit currently blocks the active laye= r even if it's not used result =3D self.vm.qmp('block-stream', device=3D'drive0', base=3Ds= elf.imgs[5], job_id=3D'stream-drive0') self.assert_qmp(result, 'error/class', 'GenericError') --=20 2.13.5