From nobody Sun Apr 28 10:05:15 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 1511208803611757.3896067425922; Mon, 20 Nov 2017 12:13:23 -0800 (PST) Received: from localhost ([::1]:59504 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsRP-0001u0-Qe for importer@patchew.org; Mon, 20 Nov 2017 15:13:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34668) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsOa-0007mn-1o for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:10:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGsOY-0006in-Vj for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:10:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42768) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGsOV-0006gS-8l; Mon, 20 Nov 2017 15:10:15 -0500 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 5BCFD72FEF; Mon, 20 Nov 2017 20:10:14 +0000 (UTC) Received: from localhost (ovpn-204-75.brq.redhat.com [10.40.204.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 75DC460BEC; Mon, 20 Nov 2017 20:10:11 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 20 Nov 2017 21:09:40 +0100 Message-Id: <20171120201004.14999-2-mreitz@redhat.com> In-Reply-To: <20171120201004.14999-1-mreitz@redhat.com> References: <20171120201004.14999-1-mreitz@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, 20 Nov 2017 20:10:14 +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 v7 for-2.12 01/25] block/mirror: Small absolute-paths simplification X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , John Snow , qemu-devel@nongnu.org, Max Reitz 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" When invoking drive-mirror in absolute-paths mode, the target's backing BDS is assigned to it in mirror_exit(). The current logic only does so if the target does not have that backing BDS already; but it actually cannot have a backing BDS at all (the BDS is opened with O_NO_BACKING in qmp_drive_mirror()), so just assert that and assign the new backing BDS unconditionally. Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia --- block/mirror.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index 307b6391a8..f995924032 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -523,12 +523,12 @@ static void mirror_exit(BlockJob *job, void *opaque) &error_abort); if (s->backing_mode =3D=3D MIRROR_SOURCE_BACKING_CHAIN) { BlockDriverState *backing =3D s->is_none_mode ? src : s->base; - if (backing_bs(target_bs) !=3D backing) { - bdrv_set_backing_hd(target_bs, backing, &local_err); - if (local_err) { - error_report_err(local_err); - data->ret =3D -EPERM; - } + + assert(!target_bs->backing); + bdrv_set_backing_hd(target_bs, backing, &local_err); + if (local_err) { + error_report_err(local_err); + data->ret =3D -EPERM; } } =20 --=20 2.13.6 From nobody Sun Apr 28 10:05:15 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 1511208886894936.3642144886774; Mon, 20 Nov 2017 12:14:46 -0800 (PST) Received: from localhost ([::1]:59511 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsSr-0003Bn-RD for importer@patchew.org; Mon, 20 Nov 2017 15:14:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34739) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsOh-0007sn-QM for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:10:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGsOg-0006n0-Qc for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:10:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39314) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGsOa-0006kT-9F; Mon, 20 Nov 2017 15:10:20 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 797106A7CE; Mon, 20 Nov 2017 20:10:19 +0000 (UTC) Received: from localhost (ovpn-204-75.brq.redhat.com [10.40.204.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5DB8C5EDEA; Mon, 20 Nov 2017 20:10:16 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 20 Nov 2017 21:09:41 +0100 Message-Id: <20171120201004.14999-3-mreitz@redhat.com> In-Reply-To: <20171120201004.14999-1-mreitz@redhat.com> References: <20171120201004.14999-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 20 Nov 2017 20:10:19 +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 v7 for-2.12 02/25] block: Use children list in bdrv_refresh_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: Kevin Wolf , Alberto Garcia , John Snow , qemu-devel@nongnu.org, Max Reitz 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" bdrv_refresh_filename() should invoke itself recursively on all children, not just on file. With that change, we can remove the manual invocations in blkverify, quorum, commit, and mirror. Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia --- block.c | 9 +++++---- block/blkverify.c | 3 --- block/commit.c | 1 - block/mirror.c | 1 - block/quorum.c | 1 - 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/block.c b/block.c index 6c8ef98dfa..4aebf590d8 100644 --- a/block.c +++ b/block.c @@ -4965,16 +4965,17 @@ static bool append_open_options(QDict *d, BlockDriv= erState *bs) void bdrv_refresh_filename(BlockDriverState *bs) { BlockDriver *drv =3D bs->drv; + BdrvChild *child; QDict *opts; =20 if (!drv) { return; } =20 - /* This BDS's file name will most probably depend on its file's name, = so - * refresh that first */ - if (bs->file) { - bdrv_refresh_filename(bs->file->bs); + /* This BDS's file name may depend on any of its children's file names= , so + * refresh those first */ + QLIST_FOREACH(child, &bs->children, next) { + bdrv_refresh_filename(child->bs); } =20 if (drv->bdrv_refresh_filename) { diff --git a/block/blkverify.c b/block/blkverify.c index 06369f9eac..b2ed8cd70d 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -281,9 +281,6 @@ static void blkverify_refresh_filename(BlockDriverState= *bs, QDict *options) { BDRVBlkverifyState *s =3D bs->opaque; =20 - /* bs->file->bs has already been refreshed */ - bdrv_refresh_filename(s->test_file->bs); - if (bs->file->bs->full_open_options && s->test_file->bs->full_open_options) { diff --git a/block/commit.c b/block/commit.c index 5036eec434..cb529cc2aa 100644 --- a/block/commit.c +++ b/block/commit.c @@ -241,7 +241,6 @@ static int coroutine_fn bdrv_commit_top_preadv(BlockDri= verState *bs, =20 static void bdrv_commit_top_refresh_filename(BlockDriverState *bs, QDict *= opts) { - bdrv_refresh_filename(bs->backing->bs); pstrcpy(bs->exact_filename, sizeof(bs->exact_filename), bs->backing->bs->filename); } diff --git a/block/mirror.c b/block/mirror.c index f995924032..f059981f19 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1061,7 +1061,6 @@ static void bdrv_mirror_top_refresh_filename(BlockDri= verState *bs, QDict *opts) * bdrv_set_backing_hd */ return; } - bdrv_refresh_filename(bs->backing->bs); pstrcpy(bs->exact_filename, sizeof(bs->exact_filename), bs->backing->bs->filename); } diff --git a/block/quorum.c b/block/quorum.c index 272f9a5b77..2f1a628449 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -1074,7 +1074,6 @@ static void quorum_refresh_filename(BlockDriverState = *bs, QDict *options) int i; =20 for (i =3D 0; i < s->num_children; i++) { - bdrv_refresh_filename(s->children[i]->bs); if (!s->children[i]->bs->full_open_options) { return; } --=20 2.13.6 From nobody Sun Apr 28 10:05:15 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1511208972731710.0059861962956; Mon, 20 Nov 2017 12:16:12 -0800 (PST) Received: from localhost ([::1]:59520 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsU2-0004HE-N3 for importer@patchew.org; Mon, 20 Nov 2017 15:15:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsOk-0007v3-Ly for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:10:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGsOj-0006oG-8v for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:10:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44132) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGsOg-0006mP-7d; Mon, 20 Nov 2017 15:10:26 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6CA5DC0587F7; Mon, 20 Nov 2017 20:10:25 +0000 (UTC) Received: from localhost (ovpn-204-75.brq.redhat.com [10.40.204.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8CFFC4F9A5; Mon, 20 Nov 2017 20:10:21 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 20 Nov 2017 21:09:42 +0100 Message-Id: <20171120201004.14999-4-mreitz@redhat.com> In-Reply-To: <20171120201004.14999-1-mreitz@redhat.com> References: <20171120201004.14999-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 20 Nov 2017 20:10:25 +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 v7 for-2.12 03/25] block: Add BDS.backing_overridden X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , John Snow , qemu-devel@nongnu.org, Max Reitz 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" If the backing file is overridden, this most probably does change the guest-visible data of a BDS. Therefore, we will need to consider this in bdrv_refresh_filename(). Adding a new field to the BDS is not nice, but it is very simple and exactly keeps track of whether the backing file has been overridden. This commit adds a FIXME which will be remedied by a follow-up commit. Until then, the respective piece of code will not result in any behavior that is worse than what we currently have. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Alberto Garcia --- include/block/block_int.h | 1 + block.c | 13 +++++++++++++ block/mirror.c | 4 ++++ blockdev.c | 16 ++++++++++++++++ 4 files changed, 34 insertions(+) diff --git a/include/block/block_int.h b/include/block/block_int.h index a5482775ec..5e9734d8b5 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -619,6 +619,7 @@ struct BlockDriverState { char backing_file[PATH_MAX]; /* if non zero, the image is a diff of this file image */ char backing_format[16]; /* if non-zero and backing_file exists */ + bool backing_overridden; /* backing file has been specified by the use= r */ =20 QDict *full_open_options; char exact_filename[PATH_MAX]; diff --git a/block.c b/block.c index 4aebf590d8..eb67dfbcc0 100644 --- a/block.c +++ b/block.c @@ -2233,6 +2233,11 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDi= ct *parent_options, reference =3D qdict_get_try_str(parent_options, bdref_key); if (reference || qdict_haskey(options, "file.filename")) { backing_filename[0] =3D '\0'; + + /* FIXME: Should also be set to true if @options contains other ru= ntime + * options which control the data that is read from the bac= king + * BDS */ + bs->backing_overridden =3D true; } else if (bs->backing_file[0] =3D=3D '\0' && qdict_size(options) =3D= =3D 0) { QDECREF(options); goto free_exit; @@ -2434,6 +2439,9 @@ static BlockDriverState *bdrv_append_temp_snapshot(Bl= ockDriverState *bs, goto out; } =20 + bs_snapshot->backing_overridden =3D true; + bdrv_refresh_filename(bs_snapshot); + out: QDECREF(snapshot_options); g_free(tmp_filename); @@ -2564,6 +2572,7 @@ static BlockDriverState *bdrv_open_inherit(const char= *filename, backing =3D qdict_get_try_str(options, "backing"); if (backing && *backing =3D=3D '\0') { flags |=3D BDRV_O_NO_BACKING; + bs->backing_overridden =3D true; qdict_del(options, "backing"); } =20 @@ -4976,6 +4985,10 @@ void bdrv_refresh_filename(BlockDriverState *bs) * refresh those first */ QLIST_FOREACH(child, &bs->children, next) { bdrv_refresh_filename(child->bs); + + if (child->role =3D=3D &child_backing && child->bs->backing_overri= dden) { + bs->backing_overridden =3D true; + } } =20 if (drv->bdrv_refresh_filename) { diff --git a/block/mirror.c b/block/mirror.c index f059981f19..d6e487fb2e 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -530,6 +530,10 @@ static void mirror_exit(BlockJob *job, void *opaque) error_report_err(local_err); data->ret =3D -EPERM; } + + /* The target image's file already has been created with the backi= ng + * file we just set, so there is no need to set backing_overridden= or + * call bdrv_refresh_filename(). */ } =20 if (s->to_replace) { diff --git a/blockdev.c b/blockdev.c index 56a6b24a0b..b0393e1786 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1781,6 +1781,8 @@ static void external_snapshot_commit(BlkActionState *= common) { ExternalSnapshotState *state =3D DO_UPCAST(ExternalSnapshotState, common, comm= on); + TransactionAction *action =3D common->action; + bool image_was_existing =3D false; =20 /* We don't need (or want) to use the transactional * bdrv_reopen_multiple() across all the entries at once, because we @@ -1789,6 +1791,20 @@ static void external_snapshot_commit(BlkActionState = *common) bdrv_reopen(state->old_bs, state->old_bs->open_flags & ~BDRV_O_RDW= R, NULL); } + + if (action->type =3D=3D TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC= ) { + BlockdevSnapshotSync *s =3D action->u.blockdev_snapshot_sync.data; + if (s->has_mode && s->mode =3D=3D NEW_IMAGE_MODE_EXISTING) { + image_was_existing =3D true; + } + } else { + image_was_existing =3D true; + } + + if (image_was_existing) { + state->new_bs->backing_overridden =3D true; + bdrv_refresh_filename(state->new_bs); + } } =20 static void external_snapshot_abort(BlkActionState *common) --=20 2.13.6 From nobody Sun Apr 28 10:05:15 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 1511209071218516.0042347389376; Mon, 20 Nov 2017 12:17:51 -0800 (PST) Received: from localhost ([::1]:59533 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsVk-000667-AO for importer@patchew.org; Mon, 20 Nov 2017 15:17:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34859) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsOs-0007zu-FD for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:10:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGsOr-0006rr-AK for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:10:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42938) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGsOl-0006on-5o; Mon, 20 Nov 2017 15:10:31 -0500 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 63CCCD9621; Mon, 20 Nov 2017 20:10:30 +0000 (UTC) Received: from localhost (ovpn-204-75.brq.redhat.com [10.40.204.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BB62160476; Mon, 20 Nov 2017 20:10:27 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 20 Nov 2017 21:09:43 +0100 Message-Id: <20171120201004.14999-5-mreitz@redhat.com> In-Reply-To: <20171120201004.14999-1-mreitz@redhat.com> References: <20171120201004.14999-1-mreitz@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]); Mon, 20 Nov 2017 20:10:30 +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 v7 for-2.12 04/25] iotests: Drop explicit base blockdev in 191 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , John Snow , qemu-devel@nongnu.org, Max Reitz 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" Overriding the backing image should result in a json:{} pseudo-filename. Then, you can no longer use the commit block job with filename parameters. Therefore, do not explicitly add the base and override the middle image in iotest 191, since we do not need to anyway. This will allow us to continue to use the middle image's filename to identify it. In the long run, we want block-commit to accept node names for base and top (just like block-stream does). Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia --- tests/qemu-iotests/191 | 3 +- tests/qemu-iotests/191.out | 70 +++++++++++++++++++++++-------------------= ---- 2 files changed, 36 insertions(+), 37 deletions(-) diff --git a/tests/qemu-iotests/191 b/tests/qemu-iotests/191 index ad785e10b1..92805e9ca2 100755 --- a/tests/qemu-iotests/191 +++ b/tests/qemu-iotests/191 @@ -67,8 +67,7 @@ qemu_comm_method=3D"qmp" qmp_pretty=3D"y" =20 _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}.mid,node-name=3Dmid" \ -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 diff --git a/tests/qemu-iotests/191.out b/tests/qemu-iotests/191.out index 73c0ed454c..26ff0a315d 100644 --- a/tests/qemu-iotests/191.out +++ b/tests/qemu-iotests/191.out @@ -220,26 +220,8 @@ wrote 65536/65536 bytes at offset 1048576 "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": SIZE, - "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", + "filename": "TEST_DIR/t.qcow2.base", "cluster-size": 65536, "format": "qcow2", "actual-size": SIZE, @@ -252,19 +234,16 @@ wrote 65536/65536 bytes at offset 1048576 "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, + "ro": true, + "node-name": "NODE_NAME", + "backing_file_depth": 0, "drv": "qcow2", "iops": 0, "bps_wr": 0, "write_threshold": 0, - "backing_file": "TEST_DIR/t.qcow2.base", "encrypted": false, "bps": 0, "bps_rd": 0, @@ -273,7 +252,7 @@ wrote 65536/65536 bytes at offset 1048576 "direct": false, "writeback": true }, - "file": "TEST_DIR/t.qcow2.mid", + "file": "TEST_DIR/t.qcow2.base", "encryption_key_missing": false }, { @@ -281,13 +260,13 @@ wrote 65536/65536 bytes at offset 1048576 "detect_zeroes": "off", "image": { "virtual-size": 393216, - "filename": "TEST_DIR/t.qcow2.mid", + "filename": "TEST_DIR/t.qcow2.base", "format": "file", "actual-size": SIZE, "dirty-flag": false }, "iops_wr": 0, - "ro": false, + "ro": true, "node-name": "NODE_NAME", "backing_file_depth": 0, "drv": "file", @@ -302,15 +281,33 @@ wrote 65536/65536 bytes at offset 1048576 "direct": false, "writeback": true }, - "file": "TEST_DIR/t.qcow2.mid", + "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": SIZE, + "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.base", + "filename": "TEST_DIR/t.qcow2.mid", "cluster-size": 65536, "format": "qcow2", "actual-size": SIZE, @@ -323,16 +320,19 @@ wrote 65536/65536 bytes at offset 1048576 "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": "base", - "backing_file_depth": 0, + "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, @@ -341,7 +341,7 @@ wrote 65536/65536 bytes at offset 1048576 "direct": false, "writeback": true }, - "file": "TEST_DIR/t.qcow2.base", + "file": "TEST_DIR/t.qcow2.mid", "encryption_key_missing": false }, { @@ -349,7 +349,7 @@ wrote 65536/65536 bytes at offset 1048576 "detect_zeroes": "off", "image": { "virtual-size": 393216, - "filename": "TEST_DIR/t.qcow2.base", + "filename": "TEST_DIR/t.qcow2.mid", "format": "file", "actual-size": SIZE, "dirty-flag": false @@ -370,7 +370,7 @@ wrote 65536/65536 bytes at offset 1048576 "direct": false, "writeback": true }, - "file": "TEST_DIR/t.qcow2.base", + "file": "TEST_DIR/t.qcow2.mid", "encryption_key_missing": false } ] --=20 2.13.6 From nobody Sun Apr 28 10:05:15 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 151120925805965.17582207504643; Mon, 20 Nov 2017 12:20:58 -0800 (PST) Received: from localhost ([::1]:59548 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsYm-000054-Dl for importer@patchew.org; Mon, 20 Nov 2017 15:20:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsP0-00085P-5U for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:10:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGsOv-0006u5-KT for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:10:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39554) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGsOq-0006r6-LQ; Mon, 20 Nov 2017 15:10:36 -0500 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 D73036A7DF; Mon, 20 Nov 2017 20:10:35 +0000 (UTC) Received: from localhost (ovpn-204-75.brq.redhat.com [10.40.204.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6CD2660C90; Mon, 20 Nov 2017 20:10:32 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 20 Nov 2017 21:09:44 +0100 Message-Id: <20171120201004.14999-6-mreitz@redhat.com> In-Reply-To: <20171120201004.14999-1-mreitz@redhat.com> References: <20171120201004.14999-1-mreitz@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, 20 Nov 2017 20:10:35 +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 v7 for-2.12 05/25] block: Respect backing bs in bdrv_refresh_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: Kevin Wolf , Alberto Garcia , John Snow , qemu-devel@nongnu.org, Max Reitz 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" Basically, bdrv_refresh_filename() should respect all children of a BlockDriverState. However, generally those children are driver-specific, so this function cannot handle the general case. On the other hand, there are only few drivers which use other children than @file and @backing (that being vmdk, quorum, and blkverify). Most block drivers only use @file and/or @backing (if they use any children at all). Both can be implemented directly in bdrv_refresh_filename. The user overriding the file's filename is already handled, however, the user overriding the backing file is not. If this is done, opening the BDS with the plain filename of its file will not be correct, so we may not set bs->exact_filename in that case. iotests 051 and 191 contain test cases for overwriting the backing file, and so their output changes with this patch applied (which I consider a good thing). Note that in the case of 191, the implicitly opened (non-overridden) base file is included in the json:{} filename as well -- this will be remedied by a later patch. Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia --- block.c | 12 +++++++++++- tests/qemu-iotests/051.out | 8 ++++---- tests/qemu-iotests/051.pc.out | 8 ++++---- tests/qemu-iotests/191.out | 24 ++++++++++++------------ 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/block.c b/block.c index eb67dfbcc0..2dc06cb9cb 100644 --- a/block.c +++ b/block.c @@ -5016,6 +5016,7 @@ void bdrv_refresh_filename(BlockDriverState *bs) =20 opts =3D qdict_new(); has_open_options =3D append_open_options(opts, bs); + has_open_options |=3D bs->backing_overridden; =20 /* If no specific options have been given for this BDS, the filena= me of * the underlying file should suffice for this one as well */ @@ -5027,11 +5028,20 @@ void bdrv_refresh_filename(BlockDriverState *bs) * file BDS. The full options QDict of that file BDS should somehow * contain a representation of the filename, therefore the followi= ng * suffices without querying the (exact_)filename of this BDS. */ - if (bs->file->bs->full_open_options) { + if (bs->file->bs->full_open_options && + (!bs->backing || bs->backing->bs->full_open_options)) + { qdict_put_str(opts, "driver", drv->format_name); QINCREF(bs->file->bs->full_open_options); qdict_put(opts, "file", bs->file->bs->full_open_options); =20 + if (bs->backing) { + QINCREF(bs->backing->bs->full_open_options); + qdict_put(opts, "backing", bs->backing->bs->full_open_opti= ons); + } else if (bs->backing_overridden && !bs->backing) { + qdict_put(opts, "backing", qstring_new()); + } + bs->full_open_options =3D opts; } else { QDECREF(opts); diff --git a/tests/qemu-iotests/051.out b/tests/qemu-iotests/051.out index e3c6eaba57..50d5cd07c8 100644 --- a/tests/qemu-iotests/051.out +++ b/tests/qemu-iotests/051.out @@ -59,7 +59,7 @@ QEMU X.Y.Z monitor - type 'help' for more information Testing: -drive file=3DTEST_DIR/t.qcow2,driver=3Dqcow2,backing.file.filena= me=3DTEST_DIR/t.qcow2.orig,if=3Dnone,id=3Ddrive0 -nodefaults QEMU X.Y.Z monitor - type 'help' for more information (qemu) info block -drive0 (NODE_NAME): TEST_DIR/t.qcow2 (qcow2) +drive0 (NODE_NAME): json:{"backing": {"driver": "qcow2", "file": {"driver"= : "file", "filename": "TEST_DIR/t.qcow2.orig"}}, "driver": "qcow2", "file":= {"driver": "file", "filename": "TEST_DIR/t.qcow2"}} (qcow2) Removable device: not locked, tray closed Cache mode: writeback Backing file: TEST_DIR/t.qcow2.orig (chain depth: 1) @@ -148,7 +148,7 @@ QEMU_PROG: -drive driver=3Dnull-co,cache=3Dinvalid_valu= e: invalid cache option Testing: -drive file=3DTEST_DIR/t.qcow2,cache=3Dwriteback,backing.file.fil= ename=3DTEST_DIR/t.qcow2.base,backing.cache.no-flush=3Don,backing.node-name= =3Dbacking,backing.file.node-name=3Dbacking-file,file.node-name=3Dfile,if= =3Dnone,id=3Ddrive0 -nodefaults QEMU X.Y.Z monitor - type 'help' for more information (qemu) info block -drive0 (NODE_NAME): TEST_DIR/t.qcow2 (qcow2) +drive0 (NODE_NAME): json:{"backing": {"driver": "qcow2", "file": {"driver"= : "file", "filename": "TEST_DIR/t.qcow2.base"}}, "driver": "qcow2", "file":= {"driver": "file", "filename": "TEST_DIR/t.qcow2"}} (qcow2) Removable device: not locked, tray closed Cache mode: writeback Backing file: TEST_DIR/t.qcow2.base (chain depth: 1) @@ -168,7 +168,7 @@ backing-file: TEST_DIR/t.qcow2.base (file, read-only) Testing: -drive file=3DTEST_DIR/t.qcow2,cache=3Dwritethrough,backing.file.= filename=3DTEST_DIR/t.qcow2.base,backing.cache.no-flush=3Don,backing.node-n= ame=3Dbacking,backing.file.node-name=3Dbacking-file,file.node-name=3Dfile,i= f=3Dnone,id=3Ddrive0 -nodefaults QEMU X.Y.Z monitor - type 'help' for more information (qemu) info block -drive0 (NODE_NAME): TEST_DIR/t.qcow2 (qcow2) +drive0 (NODE_NAME): json:{"backing": {"driver": "qcow2", "file": {"driver"= : "file", "filename": "TEST_DIR/t.qcow2.base"}}, "driver": "qcow2", "file":= {"driver": "file", "filename": "TEST_DIR/t.qcow2"}} (qcow2) Removable device: not locked, tray closed Cache mode: writethrough Backing file: TEST_DIR/t.qcow2.base (chain depth: 1) @@ -188,7 +188,7 @@ backing-file: TEST_DIR/t.qcow2.base (file, read-only) Testing: -drive file=3DTEST_DIR/t.qcow2,cache=3Dunsafe,backing.file.filena= me=3DTEST_DIR/t.qcow2.base,backing.cache.no-flush=3Don,backing.node-name=3D= backing,backing.file.node-name=3Dbacking-file,file.node-name=3Dfile,if=3Dno= ne,id=3Ddrive0 -nodefaults QEMU X.Y.Z monitor - type 'help' for more information (qemu) info block -drive0 (NODE_NAME): TEST_DIR/t.qcow2 (qcow2) +drive0 (NODE_NAME): json:{"backing": {"driver": "qcow2", "file": {"driver"= : "file", "filename": "TEST_DIR/t.qcow2.base"}}, "driver": "qcow2", "file":= {"driver": "file", "filename": "TEST_DIR/t.qcow2"}} (qcow2) Removable device: not locked, tray closed Cache mode: writeback, ignore flushes Backing file: TEST_DIR/t.qcow2.base (chain depth: 1) diff --git a/tests/qemu-iotests/051.pc.out b/tests/qemu-iotests/051.pc.out index f2c5622cee..406f83780b 100644 --- a/tests/qemu-iotests/051.pc.out +++ b/tests/qemu-iotests/051.pc.out @@ -59,7 +59,7 @@ QEMU X.Y.Z monitor - type 'help' for more information Testing: -drive file=3DTEST_DIR/t.qcow2,driver=3Dqcow2,backing.file.filena= me=3DTEST_DIR/t.qcow2.orig,if=3Dnone,id=3Ddrive0 -nodefaults QEMU X.Y.Z monitor - type 'help' for more information (qemu) info block -drive0 (NODE_NAME): TEST_DIR/t.qcow2 (qcow2) +drive0 (NODE_NAME): json:{"backing": {"driver": "qcow2", "file": {"driver"= : "file", "filename": "TEST_DIR/t.qcow2.orig"}}, "driver": "qcow2", "file":= {"driver": "file", "filename": "TEST_DIR/t.qcow2"}} (qcow2) Removable device: not locked, tray closed Cache mode: writeback Backing file: TEST_DIR/t.qcow2.orig (chain depth: 1) @@ -240,7 +240,7 @@ QEMU_PROG: -drive driver=3Dnull-co,cache=3Dinvalid_valu= e: invalid cache option Testing: -drive file=3DTEST_DIR/t.qcow2,cache=3Dwriteback,backing.file.fil= ename=3DTEST_DIR/t.qcow2.base,backing.cache.no-flush=3Don,backing.node-name= =3Dbacking,backing.file.node-name=3Dbacking-file,file.node-name=3Dfile,if= =3Dnone,id=3Ddrive0 -nodefaults QEMU X.Y.Z monitor - type 'help' for more information (qemu) info block -drive0 (NODE_NAME): TEST_DIR/t.qcow2 (qcow2) +drive0 (NODE_NAME): json:{"backing": {"driver": "qcow2", "file": {"driver"= : "file", "filename": "TEST_DIR/t.qcow2.base"}}, "driver": "qcow2", "file":= {"driver": "file", "filename": "TEST_DIR/t.qcow2"}} (qcow2) Removable device: not locked, tray closed Cache mode: writeback Backing file: TEST_DIR/t.qcow2.base (chain depth: 1) @@ -260,7 +260,7 @@ backing-file: TEST_DIR/t.qcow2.base (file, read-only) Testing: -drive file=3DTEST_DIR/t.qcow2,cache=3Dwritethrough,backing.file.= filename=3DTEST_DIR/t.qcow2.base,backing.cache.no-flush=3Don,backing.node-n= ame=3Dbacking,backing.file.node-name=3Dbacking-file,file.node-name=3Dfile,i= f=3Dnone,id=3Ddrive0 -nodefaults QEMU X.Y.Z monitor - type 'help' for more information (qemu) info block -drive0 (NODE_NAME): TEST_DIR/t.qcow2 (qcow2) +drive0 (NODE_NAME): json:{"backing": {"driver": "qcow2", "file": {"driver"= : "file", "filename": "TEST_DIR/t.qcow2.base"}}, "driver": "qcow2", "file":= {"driver": "file", "filename": "TEST_DIR/t.qcow2"}} (qcow2) Removable device: not locked, tray closed Cache mode: writethrough Backing file: TEST_DIR/t.qcow2.base (chain depth: 1) @@ -280,7 +280,7 @@ backing-file: TEST_DIR/t.qcow2.base (file, read-only) Testing: -drive file=3DTEST_DIR/t.qcow2,cache=3Dunsafe,backing.file.filena= me=3DTEST_DIR/t.qcow2.base,backing.cache.no-flush=3Don,backing.node-name=3D= backing,backing.file.node-name=3Dbacking-file,file.node-name=3Dfile,if=3Dno= ne,id=3Ddrive0 -nodefaults QEMU X.Y.Z monitor - type 'help' for more information (qemu) info block -drive0 (NODE_NAME): TEST_DIR/t.qcow2 (qcow2) +drive0 (NODE_NAME): json:{"backing": {"driver": "qcow2", "file": {"driver"= : "file", "filename": "TEST_DIR/t.qcow2.base"}}, "driver": "qcow2", "file":= {"driver": "file", "filename": "TEST_DIR/t.qcow2"}} (qcow2) Removable device: not locked, tray closed Cache mode: writeback, ignore flushes Backing file: TEST_DIR/t.qcow2.base (chain depth: 1) diff --git a/tests/qemu-iotests/191.out b/tests/qemu-iotests/191.out index 26ff0a315d..c1ce99985e 100644 --- a/tests/qemu-iotests/191.out +++ b/tests/qemu-iotests/191.out @@ -61,7 +61,7 @@ wrote 65536/65536 bytes at offset 1048576 }, "backing-filename-format": "qcow2", "virtual-size": 67108864, - "filename": "TEST_DIR/t.qcow2.ovl2", + "filename": "json:{"backing": {"backing": {"driver": "qcow= 2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.base"}}, "driv= er": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.mid"= }}, "driver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.q= cow2.ovl2"}}", "cluster-size": 65536, "format": "qcow2", "actual-size": SIZE, @@ -95,7 +95,7 @@ wrote 65536/65536 bytes at offset 1048576 "direct": false, "writeback": true }, - "file": "TEST_DIR/t.qcow2.ovl2", + "file": "json:{"backing": {"backing": {"driver": "qcow2", "fil= e": {"driver": "file", "filename": "TEST_DIR/t.qcow2.base"}}, "driver": "qc= ow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.mid"}}, "dri= ver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.ovl= 2"}}", "encryption_key_missing": false }, { @@ -150,7 +150,7 @@ wrote 65536/65536 bytes at offset 1048576 }, "backing-filename-format": "qcow2", "virtual-size": 67108864, - "filename": "TEST_DIR/t.qcow2", + "filename": "json:{"backing": {"backing": {"driver": "qcow= 2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.base"}}, "driv= er": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.mid"= }}, "driver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.q= cow2"}}", "cluster-size": 65536, "format": "qcow2", "actual-size": SIZE, @@ -184,7 +184,7 @@ wrote 65536/65536 bytes at offset 1048576 "direct": false, "writeback": true }, - "file": "TEST_DIR/t.qcow2", + "file": "json:{"backing": {"backing": {"driver": "qcow2", "fil= e": {"driver": "file", "filename": "TEST_DIR/t.qcow2.base"}}, "driver": "qc= ow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.mid"}}, "dri= ver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2"}}", "encryption_key_missing": false }, { @@ -464,7 +464,7 @@ wrote 65536/65536 bytes at offset 1048576 }, "backing-filename-format": "qcow2", "virtual-size": 67108864, - "filename": "TEST_DIR/t.qcow2.ovl2", + "filename": "json:{"backing": {"backing": {"driver": "qcow= 2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.base"}}, "driv= er": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.mid"= }}, "driver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.q= cow2.ovl2"}}", "cluster-size": 65536, "format": "qcow2", "actual-size": SIZE, @@ -498,7 +498,7 @@ wrote 65536/65536 bytes at offset 1048576 "direct": false, "writeback": true }, - "file": "TEST_DIR/t.qcow2.ovl2", + "file": "json:{"backing": {"backing": {"driver": "qcow2", "fil= e": {"driver": "file", "filename": "TEST_DIR/t.qcow2.base"}}, "driver": "qc= ow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.mid"}}, "dri= ver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.ovl= 2"}}", "encryption_key_missing": false }, { @@ -554,7 +554,7 @@ wrote 65536/65536 bytes at offset 1048576 }, "backing-filename-format": "qcow2", "virtual-size": 67108864, - "filename": "TEST_DIR/t.qcow2.ovl2", + "filename": "json:{"backing": {"backing": {"driver": "= qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.base"}}, "= driver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.= mid"}}, "driver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR= /t.qcow2.ovl2"}}", "cluster-size": 65536, "format": "qcow2", "actual-size": SIZE, @@ -573,7 +573,7 @@ wrote 65536/65536 bytes at offset 1048576 }, "backing-filename-format": "qcow2", "virtual-size": 67108864, - "filename": "TEST_DIR/t.qcow2.ovl3", + "filename": "json:{"backing": {"backing": {"backing": {"dr= iver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.ba= se"}}, "driver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/= t.qcow2.mid"}}, "driver": "qcow2", "file": {"driver": "file", "filename": "= TEST_DIR/t.qcow2.ovl2"}}, "driver": "qcow2", "file": {"driver": "file", "fi= lename": "TEST_DIR/t.qcow2.ovl3"}}", "cluster-size": 65536, "format": "qcow2", "actual-size": SIZE, @@ -586,8 +586,8 @@ wrote 65536/65536 bytes at offset 1048576 "corrupt": false } }, - "full-backing-filename": "TEST_DIR/t.qcow2.ovl2", - "backing-filename": "TEST_DIR/t.qcow2.ovl2", + "full-backing-filename": "json:{"backing": {"backing": {"d= river": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.b= ase"}}, "driver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR= /t.qcow2.mid"}}, "driver": "qcow2", "file": {"driver": "file", "filename": = "TEST_DIR/t.qcow2.ovl2"}}", + "backing-filename": "json:{"backing": {"backing": {"driver= ": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.base"}= }, "driver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qc= ow2.mid"}}, "driver": "qcow2", "file": {"driver": "file", "filename": "TEST= _DIR/t.qcow2.ovl2"}}", "dirty-flag": false }, "iops_wr": 0, @@ -598,7 +598,7 @@ wrote 65536/65536 bytes at offset 1048576 "iops": 0, "bps_wr": 0, "write_threshold": 0, - "backing_file": "TEST_DIR/t.qcow2.ovl2", + "backing_file": "json:{"backing": {"backing": {"driver": "qcow= 2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.base"}}, "driv= er": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.mid"= }}, "driver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.q= cow2.ovl2"}}", "encrypted": false, "bps": 0, "bps_rd": 0, @@ -607,7 +607,7 @@ wrote 65536/65536 bytes at offset 1048576 "direct": false, "writeback": true }, - "file": "TEST_DIR/t.qcow2.ovl3", + "file": "json:{"backing": {"backing": {"backing": {"driver": "= qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.base"}}, "= driver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.= mid"}}, "driver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR= /t.qcow2.ovl2"}}, "driver": "qcow2", "file": {"driver": "file", "filename":= "TEST_DIR/t.qcow2.ovl3"}}", "encryption_key_missing": false }, { --=20 2.13.6 From nobody Sun Apr 28 10:05:15 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 1511208762740707.364739962478; Mon, 20 Nov 2017 12:12:42 -0800 (PST) Received: from localhost ([::1]:59502 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsQn-0001LH-Pr for importer@patchew.org; Mon, 20 Nov 2017 15:12:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35000) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsP3-00087f-3X for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:10:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGsP1-0006xP-P2 for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:10:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46862) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGsOw-0006uT-PI; Mon, 20 Nov 2017 15:10:42 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 04DD280C14; Mon, 20 Nov 2017 20:10:42 +0000 (UTC) Received: from localhost (ovpn-204-75.brq.redhat.com [10.40.204.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1530F5EDF5; Mon, 20 Nov 2017 20:10:37 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 20 Nov 2017 21:09:45 +0100 Message-Id: <20171120201004.14999-7-mreitz@redhat.com> In-Reply-To: <20171120201004.14999-1-mreitz@redhat.com> References: <20171120201004.14999-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 20 Nov 2017 20:10:42 +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 v7 for-2.12 06/25] block: Make path_combine() return the path X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , John Snow , qemu-devel@nongnu.org, Max Reitz 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" Besides being safe for arbitrary path lengths, after some follow-up patches all callers will want a freshly allocated buffer anyway. In the meantime, path_combine_deprecated() is added which has the same interface as path_combine() had before this patch. All callers to that function will be converted in follow-up patches. Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia --- include/block/block.h | 4 +-- block.c | 85 ++++++++++++++++++++++++++++-------------------= ---- block/vmdk.c | 3 +- 3 files changed, 49 insertions(+), 43 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index c05cac57e5..4584893c78 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -490,9 +490,7 @@ void bdrv_get_full_backing_filename_from_filename(const= char *backed, =20 int path_has_protocol(const char *path); int path_is_absolute(const char *path); -void path_combine(char *dest, int dest_size, - const char *base_path, - const char *filename); +char *path_combine(const char *base_path, const char *filename); =20 int bdrv_readv_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t p= os); int bdrv_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t = pos); diff --git a/block.c b/block.c index 2dc06cb9cb..8786b9b520 100644 --- a/block.c +++ b/block.c @@ -147,53 +147,62 @@ int path_is_absolute(const char *path) #endif } =20 -/* if filename is absolute, just copy it to dest. Otherwise, build a +/* if filename is absolute, just return its duplicate. Otherwise, build a path to it by considering it is relative to base_path. URL are supported. */ -void path_combine(char *dest, int dest_size, - const char *base_path, - const char *filename) +char *path_combine(const char *base_path, const char *filename) { + const char *protocol_stripped =3D NULL; const char *p, *p1; + char *result; int len; =20 - if (dest_size <=3D 0) - return; if (path_is_absolute(filename)) { - pstrcpy(dest, dest_size, filename); - } else { - const char *protocol_stripped =3D NULL; + return g_strdup(filename); + } =20 - if (path_has_protocol(base_path)) { - protocol_stripped =3D strchr(base_path, ':'); - if (protocol_stripped) { - protocol_stripped++; - } + if (path_has_protocol(base_path)) { + protocol_stripped =3D strchr(base_path, ':'); + if (protocol_stripped) { + protocol_stripped++; } - p =3D protocol_stripped ?: base_path; + } + p =3D protocol_stripped ?: base_path; =20 - p1 =3D strrchr(base_path, '/'); + p1 =3D strrchr(base_path, '/'); #ifdef _WIN32 - { - const char *p2; - p2 =3D strrchr(base_path, '\\'); - if (!p1 || p2 > p1) - p1 =3D p2; + { + const char *p2; + p2 =3D strrchr(base_path, '\\'); + if (!p1 || p2 > p1) { + p1 =3D p2; } + } #endif - if (p1) - p1++; - else - p1 =3D base_path; - if (p1 > p) - p =3D p1; - len =3D p - base_path; - if (len > dest_size - 1) - len =3D dest_size - 1; - memcpy(dest, base_path, len); - dest[len] =3D '\0'; - pstrcat(dest, dest_size, filename); + if (p1) { + p1++; + } else { + p1 =3D base_path; + } + if (p1 > p) { + p =3D p1; } + len =3D p - base_path; + + result =3D g_malloc(len + strlen(filename) + 1); + memcpy(result, base_path, len); + strcpy(result + len, filename); + + return result; +} + +static void path_combine_deprecated(char *dest, int dest_size, + const char *base_path, + const char *filename) +{ + char *combined =3D path_combine(base_path, filename); + pstrcpy(dest, dest_size, combined); + g_free(combined); } =20 /* @@ -292,7 +301,7 @@ void bdrv_get_full_backing_filename_from_filename(const= char *backed, error_setg(errp, "Cannot use relative backing file names for '%s'", backed); } else { - path_combine(dest, sz, backed, backing); + path_combine_deprecated(dest, sz, backed, backing); } } =20 @@ -4136,8 +4145,8 @@ BlockDriverState *bdrv_find_backing_image(BlockDriver= State *bs, } else { /* If not an absolute filename path, make it relative to the c= urrent * image's filename path */ - path_combine(filename_tmp, PATH_MAX, curr_bs->filename, - backing_file); + path_combine_deprecated(filename_tmp, PATH_MAX, curr_bs->filen= ame, + backing_file); =20 /* We are going to compare absolute pathnames */ if (!realpath(filename_tmp, filename_full)) { @@ -4146,8 +4155,8 @@ BlockDriverState *bdrv_find_backing_image(BlockDriver= State *bs, =20 /* We need to make sure the backing filename we are comparing = against * is relative to the current image filename (or absolute) */ - path_combine(filename_tmp, PATH_MAX, curr_bs->filename, - curr_bs->backing_file); + path_combine_deprecated(filename_tmp, PATH_MAX, curr_bs->filen= ame, + curr_bs->backing_file); =20 if (!realpath(filename_tmp, backing_file_full)) { continue; diff --git a/block/vmdk.c b/block/vmdk.c index c665bcc977..5397a4345e 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -857,8 +857,7 @@ static int vmdk_parse_extents(const char *desc, BlockDr= iverState *bs, return -EINVAL; } =20 - extent_path =3D g_malloc0(PATH_MAX); - path_combine(extent_path, PATH_MAX, desc_file_path, fname); + extent_path =3D path_combine(desc_file_path, fname); =20 ret =3D snprintf(extent_opt_prefix, 32, "extents.%d", s->num_exten= ts); assert(ret < 32); --=20 2.13.6 From nobody Sun Apr 28 10:05:15 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 1511208911866814.2370622486644; Mon, 20 Nov 2017 12:15:11 -0800 (PST) Received: from localhost ([::1]:59514 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsTG-0003Xt-Vn for importer@patchew.org; Mon, 20 Nov 2017 15:15:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35011) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsP3-00088F-Pi for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:10:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGsP2-0006xw-Nx for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:10:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46894) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGsOz-0006wL-MM; Mon, 20 Nov 2017 15:10:45 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DCF97883A5; Mon, 20 Nov 2017 20:10:44 +0000 (UTC) Received: from localhost (ovpn-204-75.brq.redhat.com [10.40.204.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 22C305EDF5; Mon, 20 Nov 2017 20:10:43 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 20 Nov 2017 21:09:46 +0100 Message-Id: <20171120201004.14999-8-mreitz@redhat.com> In-Reply-To: <20171120201004.14999-1-mreitz@redhat.com> References: <20171120201004.14999-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 20 Nov 2017 20:10:44 +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 v7 for-2.12 07/25] block: bdrv_get_full_backing_filename_from_...'s ret. val. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , John Snow , qemu-devel@nongnu.org, Max Reitz 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" Make bdrv_get_full_backing_filename_from_filename() return an allocated string instead of placing the result in a caller-provided buffer. Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia --- include/block/block.h | 7 +++---- block.c | 51 +++++++++++++++++++++++++++++++++++------------= ---- block/vmdk.c | 9 ++++----- 3 files changed, 42 insertions(+), 25 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index 4584893c78..46c6190414 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -483,10 +483,9 @@ void bdrv_get_backing_filename(BlockDriverState *bs, char *filename, int filename_size); void bdrv_get_full_backing_filename(BlockDriverState *bs, char *dest, size_t sz, Error **errp); -void bdrv_get_full_backing_filename_from_filename(const char *backed, - const char *backing, - char *dest, size_t sz, - Error **errp); +char *bdrv_get_full_backing_filename_from_filename(const char *backed, + const char *backing, + Error **errp); =20 int path_has_protocol(const char *path); int path_is_absolute(const char *path); diff --git a/block.c b/block.c index 8786b9b520..f8b3edd5bb 100644 --- a/block.c +++ b/block.c @@ -288,20 +288,28 @@ int bdrv_set_read_only(BlockDriverState *bs, bool rea= d_only, Error **errp) return 0; } =20 -void bdrv_get_full_backing_filename_from_filename(const char *backed, - const char *backing, - char *dest, size_t sz, - Error **errp) +/* If @backing is empty, this function returns NULL without setting + * @errp. In all other cases, NULL will only be returned with @errp + * set. + * + * Therefore, a return value of NULL without @errp set means that + * there is no backing file; if @errp is set, there is one but its + * absolute filename cannot be generated. + */ +char *bdrv_get_full_backing_filename_from_filename(const char *backed, + const char *backing, + Error **errp) { - if (backing[0] =3D=3D '\0' || path_has_protocol(backing) || - path_is_absolute(backing)) - { - pstrcpy(dest, sz, backing); + if (backing[0] =3D=3D '\0') { + return NULL; + } else if (path_has_protocol(backing) || path_is_absolute(backing)) { + return g_strdup(backing); } else if (backed[0] =3D=3D '\0' || strstart(backed, "json:", NULL)) { error_setg(errp, "Cannot use relative backing file names for '%s'", backed); + return NULL; } else { - path_combine_deprecated(dest, sz, backed, backing); + return path_combine(backed, backing); } } =20 @@ -309,9 +317,20 @@ void bdrv_get_full_backing_filename(BlockDriverState *= bs, char *dest, size_t sz, Error **errp) { char *backed =3D bs->exact_filename[0] ? bs->exact_filename : bs->file= name; + char *full_name; + Error *local_error =3D NULL; =20 - bdrv_get_full_backing_filename_from_filename(backed, bs->backing_file, - dest, sz, errp); + full_name =3D bdrv_get_full_backing_filename_from_filename(backed, + bs->backing_f= ile, + &local_error); + if (full_name) { + pstrcpy(dest, sz, full_name); + g_free(full_name); + } else if (local_error) { + error_propagate(errp, local_error); + } else if (sz > 0) { + *dest =3D '\0'; + } } =20 void bdrv_register(BlockDriver *bdrv) @@ -4593,17 +4612,17 @@ void bdrv_img_create(const char *filename, const ch= ar *fmt, size =3D qemu_opt_get_size(opts, BLOCK_OPT_SIZE, img_size); if (backing_file && !(flags & BDRV_O_NO_BACKING)) { BlockDriverState *bs; - char *full_backing =3D g_new0(char, PATH_MAX); + char *full_backing; int back_flags; QDict *backing_options =3D NULL; =20 - bdrv_get_full_backing_filename_from_filename(filename, backing_fil= e, - full_backing, PATH_MA= X, - &local_err); + full_backing =3D + bdrv_get_full_backing_filename_from_filename(filename, backing= _file, + &local_err); if (local_err) { - g_free(full_backing); goto out; } + assert(full_backing); =20 /* backing files always opened read-only */ back_flags =3D flags; diff --git a/block/vmdk.c b/block/vmdk.c index 5397a4345e..c1dbcfe133 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2001,16 +2001,15 @@ static int vmdk_create(const char *filename, QemuOp= ts *opts, Error **errp) } if (backing_file) { BlockBackend *blk; - char *full_backing =3D g_new0(char, PATH_MAX); - bdrv_get_full_backing_filename_from_filename(filename, backing_fil= e, - full_backing, PATH_MA= X, - &local_err); + char *full_backing =3D + bdrv_get_full_backing_filename_from_filename(filename, backing= _file, + &local_err); if (local_err) { - g_free(full_backing); error_propagate(errp, local_err); ret =3D -ENOENT; goto exit; } + assert(full_backing); =20 blk =3D blk_new_open(full_backing, NULL, NULL, BDRV_O_NO_BACKING, errp); --=20 2.13.6 From nobody Sun Apr 28 10:05:15 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 1511209163315183.9131584448097; Mon, 20 Nov 2017 12:19:23 -0800 (PST) Received: from localhost ([::1]:59536 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsWv-00070J-Ir for importer@patchew.org; Mon, 20 Nov 2017 15:18:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35049) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsP6-0008BR-U2 for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:10:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGsP5-0006zQ-N6 for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:10:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43806) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGsP2-0006xg-Rb; Mon, 20 Nov 2017 15:10:49 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 16B0C7EA91; Mon, 20 Nov 2017 20:10:48 +0000 (UTC) Received: from localhost (ovpn-204-75.brq.redhat.com [10.40.204.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4E4265EDF5; Mon, 20 Nov 2017 20:10:47 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 20 Nov 2017 21:09:47 +0100 Message-Id: <20171120201004.14999-9-mreitz@redhat.com> In-Reply-To: <20171120201004.14999-1-mreitz@redhat.com> References: <20171120201004.14999-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 20 Nov 2017 20:10:48 +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 v7 for-2.12 08/25] block: bdrv_get_full_backing_filename's ret. val. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , John Snow , qemu-devel@nongnu.org, Max Reitz 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" Make bdrv_get_full_backing_filename() return an allocated string instead of placing the result in a caller-provided buffer. Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia --- include/block/block.h | 3 +-- block.c | 47 +++++++++++++++++------------------------------ block/qapi.c | 12 ++---------- 3 files changed, 20 insertions(+), 42 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index 46c6190414..3e2ea6c879 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -481,8 +481,7 @@ void bdrv_round_to_clusters(BlockDriverState *bs, const char *bdrv_get_encrypted_filename(BlockDriverState *bs); void bdrv_get_backing_filename(BlockDriverState *bs, char *filename, int filename_size); -void bdrv_get_full_backing_filename(BlockDriverState *bs, - char *dest, size_t sz, Error **errp); +char *bdrv_get_full_backing_filename(BlockDriverState *bs, Error **errp); char *bdrv_get_full_backing_filename_from_filename(const char *backed, const char *backing, Error **errp); diff --git a/block.c b/block.c index f8b3edd5bb..804adceafa 100644 --- a/block.c +++ b/block.c @@ -313,24 +313,13 @@ char *bdrv_get_full_backing_filename_from_filename(co= nst char *backed, } } =20 -void bdrv_get_full_backing_filename(BlockDriverState *bs, char *dest, size= _t sz, - Error **errp) +char *bdrv_get_full_backing_filename(BlockDriverState *bs, Error **errp) { char *backed =3D bs->exact_filename[0] ? bs->exact_filename : bs->file= name; - char *full_name; - Error *local_error =3D NULL; =20 - full_name =3D bdrv_get_full_backing_filename_from_filename(backed, - bs->backing_f= ile, - &local_error); - if (full_name) { - pstrcpy(dest, sz, full_name); - g_free(full_name); - } else if (local_error) { - error_propagate(errp, local_error); - } else if (sz > 0) { - *dest =3D '\0'; - } + return bdrv_get_full_backing_filename_from_filename(backed, + bs->backing_file, + errp); } =20 void bdrv_register(BlockDriver *bdrv) @@ -2226,7 +2215,7 @@ out: int bdrv_open_backing_file(BlockDriverState *bs, QDict *parent_options, const char *bdref_key, Error **errp) { - char *backing_filename =3D g_malloc0(PATH_MAX); + char *backing_filename =3D NULL; char *bdref_key_dot; const char *reference =3D NULL; int ret =3D 0; @@ -2260,7 +2249,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDic= t *parent_options, */ reference =3D qdict_get_try_str(parent_options, bdref_key); if (reference || qdict_haskey(options, "file.filename")) { - backing_filename[0] =3D '\0'; + /* keep backing_filename NULL */ =20 /* FIXME: Should also be set to true if @options contains other ru= ntime * options which control the data that is read from the bac= king @@ -2270,8 +2259,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDic= t *parent_options, QDECREF(options); goto free_exit; } else { - bdrv_get_full_backing_filename(bs, backing_filename, PATH_MAX, - &local_err); + backing_filename =3D bdrv_get_full_backing_filename(bs, &local_err= ); if (local_err) { ret =3D -EINVAL; error_propagate(errp, local_err); @@ -2292,9 +2280,8 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDic= t *parent_options, qdict_put_str(options, "driver", bs->backing_format); } =20 - backing_hd =3D bdrv_open_inherit(*backing_filename ? backing_filename = : NULL, - reference, options, 0, bs, &child_backi= ng, - errp); + backing_hd =3D bdrv_open_inherit(backing_filename, reference, options,= 0, bs, + &child_backing, errp); if (!backing_hd) { bs->open_flags |=3D BDRV_O_NO_BACKING; error_prepend(errp, "Could not open backing file: "); @@ -4128,7 +4115,6 @@ BlockDriverState *bdrv_find_backing_image(BlockDriver= State *bs, int is_protocol =3D 0; BlockDriverState *curr_bs =3D NULL; BlockDriverState *retval =3D NULL; - Error *local_error =3D NULL; =20 if (!bs || !bs->drv || !backing_file) { return NULL; @@ -4145,21 +4131,22 @@ BlockDriverState *bdrv_find_backing_image(BlockDriv= erState *bs, /* If either of the filename paths is actually a protocol, then * compare unmodified paths; otherwise make paths relative */ if (is_protocol || path_has_protocol(curr_bs->backing_file)) { + char *backing_file_full_ret; + if (strcmp(backing_file, curr_bs->backing_file) =3D=3D 0) { retval =3D curr_bs->backing->bs; break; } /* Also check against the full backing filename for the image = */ - bdrv_get_full_backing_filename(curr_bs, backing_file_full, PAT= H_MAX, - &local_error); - if (local_error =3D=3D NULL) { - if (strcmp(backing_file, backing_file_full) =3D=3D 0) { + backing_file_full_ret =3D bdrv_get_full_backing_filename(curr_= bs, + NULL); + if (backing_file_full_ret) { + bool equal =3D strcmp(backing_file, backing_file_full_ret)= =3D=3D 0; + g_free(backing_file_full_ret); + if (equal) { retval =3D curr_bs->backing->bs; break; } - } else { - error_free(local_error); - local_error =3D NULL; } } else { /* If not an absolute filename path, make it relative to the c= urrent diff --git a/block/qapi.c b/block/qapi.c index fc10f0a565..c7da9bd312 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -282,18 +282,10 @@ void bdrv_query_image_info(BlockDriverState *bs, =20 backing_filename =3D bs->backing_file; if (backing_filename[0] !=3D '\0') { - char *backing_filename2 =3D g_malloc0(PATH_MAX); + char *backing_filename2; info->backing_filename =3D g_strdup(backing_filename); info->has_backing_filename =3D true; - bdrv_get_full_backing_filename(bs, backing_filename2, PATH_MAX, &e= rr); - if (err) { - /* Can't reconstruct the full backing filename, so we must omit - * this field and apply a Best Effort to this query. */ - g_free(backing_filename2); - backing_filename2 =3D NULL; - error_free(err); - err =3D NULL; - } + backing_filename2 =3D bdrv_get_full_backing_filename(bs, NULL); =20 /* Always report the full_backing_filename if present, even if it'= s the * same as backing_filename. That they are same is useful info. */ --=20 2.13.6 From nobody Sun Apr 28 10:05:15 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 1511209436819100.73621379655606; Mon, 20 Nov 2017 12:23:56 -0800 (PST) Received: from localhost ([::1]:59566 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsbh-0002ew-3W for importer@patchew.org; Mon, 20 Nov 2017 15:23:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35110) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsPC-0008GE-1H for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:10:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGsPB-00073L-97 for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:10:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39728) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGsP5-0006zE-Mz; Mon, 20 Nov 2017 15:10:51 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E578E6A7DC; Mon, 20 Nov 2017 20:10:50 +0000 (UTC) Received: from localhost (ovpn-204-75.brq.redhat.com [10.40.204.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 60AA45EE11; Mon, 20 Nov 2017 20:10:50 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 20 Nov 2017 21:09:48 +0100 Message-Id: <20171120201004.14999-10-mreitz@redhat.com> In-Reply-To: <20171120201004.14999-1-mreitz@redhat.com> References: <20171120201004.14999-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 20 Nov 2017 20:10:50 +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 v7 for-2.12 09/25] block: Add bdrv_make_absolute_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: Kevin Wolf , Alberto Garcia , John Snow , qemu-devel@nongnu.org, Max Reitz 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 is a general function for making a filename that is relative to a certain BDS absolute. It calls bdrv_get_full_backing_filename_from_filename() for now, but that will be changed in a follow-up patch. Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia --- block.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/block.c b/block.c index 804adceafa..a11cebf0cb 100644 --- a/block.c +++ b/block.c @@ -313,13 +313,24 @@ char *bdrv_get_full_backing_filename_from_filename(co= nst char *backed, } } =20 -char *bdrv_get_full_backing_filename(BlockDriverState *bs, Error **errp) +/* If @filename is empty or NULL, this function returns NULL without + * setting @errp. In all other cases, NULL will only be returned with + * @errp set. + */ +static char *bdrv_make_absolute_filename(BlockDriverState *relative_to, + const char *filename, Error **err= p) { - char *backed =3D bs->exact_filename[0] ? bs->exact_filename : bs->file= name; + char *bs_filename =3D relative_to->exact_filename[0] + ? relative_to->exact_filename + : relative_to->filename; + + return bdrv_get_full_backing_filename_from_filename(bs_filename, + filename ?: "", er= rp); +} =20 - return bdrv_get_full_backing_filename_from_filename(backed, - bs->backing_file, - errp); +char *bdrv_get_full_backing_filename(BlockDriverState *bs, Error **errp) +{ + return bdrv_make_absolute_filename(bs, bs->backing_file, errp); } =20 void bdrv_register(BlockDriver *bdrv) --=20 2.13.6 From nobody Sun Apr 28 10:05:15 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1511209316812485.7611969433583; Mon, 20 Nov 2017 12:21:56 -0800 (PST) Received: from localhost ([::1]:59552 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsZd-0000qj-Va for importer@patchew.org; Mon, 20 Nov 2017 15:21:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35140) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsPE-0008Js-E4 for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:11:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGsPD-00076X-H2 for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:11:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41574) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGsPB-00071s-0J; Mon, 20 Nov 2017 15:10:57 -0500 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 4095E13AAB; Mon, 20 Nov 2017 20:10:56 +0000 (UTC) Received: from localhost (ovpn-204-75.brq.redhat.com [10.40.204.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 40A8660C80; Mon, 20 Nov 2017 20:10:53 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 20 Nov 2017 21:09:49 +0100 Message-Id: <20171120201004.14999-11-mreitz@redhat.com> In-Reply-To: <20171120201004.14999-1-mreitz@redhat.com> References: <20171120201004.14999-1-mreitz@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.29]); Mon, 20 Nov 2017 20:10:56 +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 v7 for-2.12 10/25] block: Fix bdrv_find_backing_image() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , John Snow , qemu-devel@nongnu.org, Max Reitz 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" bdrv_find_backing_image() should use bdrv_get_full_backing_filename() or bdrv_make_absolute_filename() instead of trying to do what those functions do by itself. path_combine_deprecated() can now be dropped, so let's do that. Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia --- block.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/block.c b/block.c index a11cebf0cb..ecea78dae0 100644 --- a/block.c +++ b/block.c @@ -196,15 +196,6 @@ char *path_combine(const char *base_path, const char *= filename) return result; } =20 -static void path_combine_deprecated(char *dest, int dest_size, - const char *base_path, - const char *filename) -{ - char *combined =3D path_combine(base_path, filename); - pstrcpy(dest, dest_size, combined); - g_free(combined); -} - /* * Helper function for bdrv_parse_filename() implementations to remove opt= ional * protocol prefixes (especially "file:") from a filename and for putting = the @@ -4133,7 +4124,6 @@ BlockDriverState *bdrv_find_backing_image(BlockDriver= State *bs, =20 filename_full =3D g_malloc(PATH_MAX); backing_file_full =3D g_malloc(PATH_MAX); - filename_tmp =3D g_malloc(PATH_MAX); =20 is_protocol =3D path_has_protocol(backing_file); =20 @@ -4162,22 +4152,23 @@ BlockDriverState *bdrv_find_backing_image(BlockDriv= erState *bs, } else { /* If not an absolute filename path, make it relative to the c= urrent * image's filename path */ - path_combine_deprecated(filename_tmp, PATH_MAX, curr_bs->filen= ame, - backing_file); - - /* We are going to compare absolute pathnames */ - if (!realpath(filename_tmp, filename_full)) { + filename_tmp =3D bdrv_make_absolute_filename(curr_bs, backing_= file, + NULL); + /* We are going to compare canonicalized absolute pathnames */ + if (!filename_tmp || !realpath(filename_tmp, filename_full)) { + g_free(filename_tmp); continue; } + g_free(filename_tmp); =20 /* We need to make sure the backing filename we are comparing = against * is relative to the current image filename (or absolute) */ - path_combine_deprecated(filename_tmp, PATH_MAX, curr_bs->filen= ame, - curr_bs->backing_file); - - if (!realpath(filename_tmp, backing_file_full)) { + filename_tmp =3D bdrv_get_full_backing_filename(curr_bs, NULL); + if (!filename_tmp || !realpath(filename_tmp, backing_file_full= )) { + g_free(filename_tmp); continue; } + g_free(filename_tmp); =20 if (strcmp(backing_file_full, filename_full) =3D=3D 0) { retval =3D curr_bs->backing->bs; @@ -4188,7 +4179,6 @@ BlockDriverState *bdrv_find_backing_image(BlockDriver= State *bs, =20 g_free(filename_full); g_free(backing_file_full); - g_free(filename_tmp); return retval; } =20 --=20 2.13.6 From nobody Sun Apr 28 10:05:15 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 1511209090295539.7310100771796; Mon, 20 Nov 2017 12:18:10 -0800 (PST) Received: from localhost ([::1]:59535 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsW7-0006NR-Hl for importer@patchew.org; Mon, 20 Nov 2017 15:18:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35197) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsPM-0008Qh-9q for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:11:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGsPH-00079X-Ve for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:11:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43360) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGsPF-00078B-BY; Mon, 20 Nov 2017 15:11:01 -0500 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 897D7680EE; Mon, 20 Nov 2017 20:11:00 +0000 (UTC) Received: from localhost (ovpn-204-75.brq.redhat.com [10.40.204.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 631D560171; Mon, 20 Nov 2017 20:10:58 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 20 Nov 2017 21:09:50 +0100 Message-Id: <20171120201004.14999-12-mreitz@redhat.com> In-Reply-To: <20171120201004.14999-1-mreitz@redhat.com> References: <20171120201004.14999-1-mreitz@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]); Mon, 20 Nov 2017 20:11: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] [PATCH v7 for-2.12 11/25] block: Add bdrv_dirname() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , John Snow , qemu-devel@nongnu.org, Max Reitz 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 function may be implemented by block drivers to derive a directory name from a BDS. Concatenating this g_free()-able string with a relative filename must result in a valid (not necessarily existing) filename, so this is a function that should generally be not implemented by format drivers, because this is protocol-specific. If a BDS's driver does not implement this function, bdrv_dirname() will fall through to the BDS's file if it exists. If it does not, the exact_filename field will be used to generate a directory name. Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia --- include/block/block.h | 1 + include/block/block_int.h | 7 +++++++ block.c | 26 ++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/include/block/block.h b/include/block/block.h index 3e2ea6c879..a053a27148 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -485,6 +485,7 @@ char *bdrv_get_full_backing_filename(BlockDriverState *= bs, Error **errp); char *bdrv_get_full_backing_filename_from_filename(const char *backed, const char *backing, Error **errp); +char *bdrv_dirname(BlockDriverState *bs, Error **errp); =20 int path_has_protocol(const char *path); int path_is_absolute(const char *path); diff --git a/include/block/block_int.h b/include/block/block_int.h index 5e9734d8b5..c07882962d 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -135,6 +135,13 @@ struct BlockDriver { =20 void (*bdrv_refresh_filename)(BlockDriverState *bs, QDict *options); =20 + /* + * Returns an allocated string which is the directory name of this BDS= : It + * will be used to make relative filenames absolute by prepending this + * function's return value to them. + */ + char *(*bdrv_dirname)(BlockDriverState *bs, Error **errp); + /* aio */ BlockAIOCB *(*bdrv_aio_readv)(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, diff --git a/block.c b/block.c index ecea78dae0..20e45c85c6 100644 --- a/block.c +++ b/block.c @@ -5098,6 +5098,32 @@ void bdrv_refresh_filename(BlockDriverState *bs) } } =20 +char *bdrv_dirname(BlockDriverState *bs, Error **errp) +{ + BlockDriver *drv =3D bs->drv; + + if (!drv) { + error_setg(errp, "Node '%s' is ejected", bs->node_name); + return NULL; + } + + if (drv->bdrv_dirname) { + return drv->bdrv_dirname(bs, errp); + } + + if (bs->file) { + return bdrv_dirname(bs->file->bs, errp); + } + + if (bs->exact_filename[0] !=3D '\0') { + return path_combine(bs->exact_filename, ""); + } + + error_setg(errp, "Cannot generate a base directory for %s nodes", + drv->format_name); + return NULL; +} + /* * Hot add/remove a BDS's child. So the user can take a child offline when * it is broken and take a new child online --=20 2.13.6 From nobody Sun Apr 28 10:05:15 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) 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 1511209606751180.7988574486999; Mon, 20 Nov 2017 12:26:46 -0800 (PST) Received: from localhost ([::1]:59581 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGseQ-00052n-2A for importer@patchew.org; Mon, 20 Nov 2017 15:26:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35227) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsPO-0008SX-9c for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:11:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGsPN-0007E7-DQ for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:11:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:19527) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGsPH-00079E-Pj; Mon, 20 Nov 2017 15:11:03 -0500 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 059F1883B9; Mon, 20 Nov 2017 20:11:03 +0000 (UTC) Received: from localhost (ovpn-204-75.brq.redhat.com [10.40.204.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 89F5D60BEC; Mon, 20 Nov 2017 20:11:02 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 20 Nov 2017 21:09:51 +0100 Message-Id: <20171120201004.14999-13-mreitz@redhat.com> In-Reply-To: <20171120201004.14999-1-mreitz@redhat.com> References: <20171120201004.14999-1-mreitz@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.26]); Mon, 20 Nov 2017 20:11: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] [PATCH v7 for-2.12 12/25] blkverify: Make bdrv_dirname() return NULL X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , John Snow , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" blkverify's BDSs have a file BDS, but we do not want this to be preferred over the raw node. There is no way to decide between the two (and not really a reason to, either), so just return NULL in blkverify's implementation of bdrv_dirname(). Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Alberto Garcia --- block/blkverify.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/block/blkverify.c b/block/blkverify.c index b2ed8cd70d..d5233eeaf9 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -309,6 +309,15 @@ static void blkverify_refresh_filename(BlockDriverStat= e *bs, QDict *options) } } =20 +static char *blkverify_dirname(BlockDriverState *bs, Error **errp) +{ + /* In general, there are two BDSs with different dirnames below this o= ne; + * so there is no unique dirname we could return (unless both are equa= l by + * chance). Therefore, to be consistent, just always return NULL. */ + error_setg(errp, "Cannot generate a base directory for blkverify nodes= "); + return NULL; +} + static BlockDriver bdrv_blkverify =3D { .format_name =3D "blkverify", .protocol_name =3D "blkverify", @@ -320,6 +329,7 @@ static BlockDriver bdrv_blkverify =3D { .bdrv_child_perm =3D bdrv_filter_default_perms, .bdrv_getlength =3D blkverify_getlength, .bdrv_refresh_filename =3D blkverify_refresh_filename, + .bdrv_dirname =3D blkverify_dirname, =20 .bdrv_co_preadv =3D blkverify_co_preadv, .bdrv_co_pwritev =3D blkverify_co_pwritev, --=20 2.13.6 From nobody Sun Apr 28 10:05:15 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 1511209264718762.7811267263168; Mon, 20 Nov 2017 12:21:04 -0800 (PST) Received: from localhost ([::1]:59550 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsYu-0000D9-0a for importer@patchew.org; Mon, 20 Nov 2017 15:21:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsPO-0008Sp-L5 for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:11:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGsPN-0007EP-KA for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:11:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43442) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGsPK-0007B4-Dx; Mon, 20 Nov 2017 15:11:06 -0500 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 A910B68419; Mon, 20 Nov 2017 20:11:05 +0000 (UTC) Received: from localhost (ovpn-204-75.brq.redhat.com [10.40.204.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3A6CE600CC; Mon, 20 Nov 2017 20:11:05 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 20 Nov 2017 21:09:52 +0100 Message-Id: <20171120201004.14999-14-mreitz@redhat.com> In-Reply-To: <20171120201004.14999-1-mreitz@redhat.com> References: <20171120201004.14999-1-mreitz@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]); Mon, 20 Nov 2017 20:11:05 +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 v7 for-2.12 13/25] quorum: Make bdrv_dirname() return NULL X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , John Snow , qemu-devel@nongnu.org, Max Reitz 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" While the common implementation for bdrv_dirname() should return NULL for quorum BDSs already (because they do not have a file node and their exact_filename field should be empty), there is no reason not to make that explicit. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Alberto Garcia --- block/quorum.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/block/quorum.c b/block/quorum.c index 2f1a628449..e5a844335e 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -1095,6 +1095,16 @@ static void quorum_refresh_filename(BlockDriverState= *bs, QDict *options) bs->full_open_options =3D opts; } =20 +static char *quorum_dirname(BlockDriverState *bs, Error **errp) +{ + /* In general, there are multiple BDSs with different dirnames below t= his + * one; so there is no unique dirname we could return (unless all are = equal + * by chance, or there is only one). Therefore, to be consistent, just + * always return NULL. */ + error_setg(errp, "Cannot generate a base directory for quorum nodes"); + return NULL; +} + static BlockDriver bdrv_quorum =3D { .format_name =3D "quorum", .protocol_name =3D "quorum", @@ -1104,6 +1114,7 @@ static BlockDriver bdrv_quorum =3D { .bdrv_file_open =3D quorum_open, .bdrv_close =3D quorum_close, .bdrv_refresh_filename =3D quorum_refresh_filename, + .bdrv_dirname =3D quorum_dirname, =20 .bdrv_co_flush_to_disk =3D quorum_co_flush, =20 --=20 2.13.6 From nobody Sun Apr 28 10:05:15 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 15112094354461016.5588283491438; Mon, 20 Nov 2017 12:23:55 -0800 (PST) Received: from localhost ([::1]:59565 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsbd-0002c7-IR for importer@patchew.org; Mon, 20 Nov 2017 15:23:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35326) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsPW-00008Y-UY for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:11:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGsPS-0007Iz-KW for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:11:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53684) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGsPQ-0007GI-E5; Mon, 20 Nov 2017 15:11:12 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9A734C02738C; Mon, 20 Nov 2017 20:11:11 +0000 (UTC) Received: from localhost (ovpn-204-75.brq.redhat.com [10.40.204.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BA1545FFFA; Mon, 20 Nov 2017 20:11:07 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 20 Nov 2017 21:09:53 +0100 Message-Id: <20171120201004.14999-15-mreitz@redhat.com> In-Reply-To: <20171120201004.14999-1-mreitz@redhat.com> References: <20171120201004.14999-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 20 Nov 2017 20:11:11 +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 v7 for-2.12 14/25] block/nbd: Make bdrv_dirname() return NULL X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , John Snow , qemu-devel@nongnu.org, Max Reitz 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 generic bdrv_dirname() implementation would be able to generate some form of directory name for many NBD nodes, but it would be always wrong. Therefore, we have to explicitly make it an error (until NBD has some form of specification for export paths, if it ever will). Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia --- block/nbd.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/block/nbd.c b/block/nbd.c index a50d24b50a..ed921fa333 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -565,6 +565,16 @@ static void nbd_refresh_filename(BlockDriverState *bs,= QDict *options) bs->full_open_options =3D opts; } =20 +static char *nbd_dirname(BlockDriverState *bs, Error **errp) +{ + /* The generic bdrv_dirname() implementation is able to work out some + * directory name for NBD nodes, but that would be wrong. So far there= is no + * specification for how "export paths" would work, so NBD does not ha= ve + * directory names. */ + error_setg(errp, "Cannot generate a base directory for NBD nodes"); + return NULL; +} + static BlockDriver bdrv_nbd =3D { .format_name =3D "nbd", .protocol_name =3D "nbd", @@ -582,6 +592,7 @@ static BlockDriver bdrv_nbd =3D { .bdrv_detach_aio_context =3D nbd_detach_aio_context, .bdrv_attach_aio_context =3D nbd_attach_aio_context, .bdrv_refresh_filename =3D nbd_refresh_filename, + .bdrv_dirname =3D nbd_dirname, }; =20 static BlockDriver bdrv_nbd_tcp =3D { @@ -601,6 +612,7 @@ static BlockDriver bdrv_nbd_tcp =3D { .bdrv_detach_aio_context =3D nbd_detach_aio_context, .bdrv_attach_aio_context =3D nbd_attach_aio_context, .bdrv_refresh_filename =3D nbd_refresh_filename, + .bdrv_dirname =3D nbd_dirname, }; =20 static BlockDriver bdrv_nbd_unix =3D { @@ -620,6 +632,7 @@ static BlockDriver bdrv_nbd_unix =3D { .bdrv_detach_aio_context =3D nbd_detach_aio_context, .bdrv_attach_aio_context =3D nbd_attach_aio_context, .bdrv_refresh_filename =3D nbd_refresh_filename, + .bdrv_dirname =3D nbd_dirname, }; =20 static void bdrv_nbd_init(void) --=20 2.13.6 From nobody Sun Apr 28 10:05:15 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) 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 1511209606752799.2275461469889; Mon, 20 Nov 2017 12:26:46 -0800 (PST) Received: from localhost ([::1]:59578 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGseA-0004pA-Py for importer@patchew.org; Mon, 20 Nov 2017 15:26:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35349) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsPZ-0000Ap-9u for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:11:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGsPY-0007OC-FI for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:11:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41946) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGsPW-0007Ll-B1; Mon, 20 Nov 2017 15:11:18 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 971B6C9D57; Mon, 20 Nov 2017 20:11:17 +0000 (UTC) Received: from localhost (ovpn-204-75.brq.redhat.com [10.40.204.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7250D5EDE4; Mon, 20 Nov 2017 20:11:14 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 20 Nov 2017 21:09:54 +0100 Message-Id: <20171120201004.14999-16-mreitz@redhat.com> In-Reply-To: <20171120201004.14999-1-mreitz@redhat.com> References: <20171120201004.14999-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 20 Nov 2017 20:11:17 +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 v7 for-2.12 15/25] block/nfs: Implement bdrv_dirname() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , John Snow , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" While the basic idea is obvious and could be handled by the default bdrv_dirname() implementation, we cannot generate a directory name if the gid or uid are set, so we have to explicitly return NULL in those cases. Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia --- block/nfs.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/block/nfs.c b/block/nfs.c index 337fcd9c84..0152a9bd32 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -875,6 +875,19 @@ static void nfs_refresh_filename(BlockDriverState *bs,= QDict *options) bs->full_open_options =3D opts; } =20 +static char *nfs_dirname(BlockDriverState *bs, Error **errp) +{ + NFSClient *client =3D bs->opaque; + + if (client->uid || client->gid) { + error_setg(errp, "Cannot generate a base directory for NBD node '%= s'", + bs->filename); + return NULL; + } + + return g_strdup_printf("nfs://%s%s/", client->server->host, client->pa= th); +} + #ifdef LIBNFS_FEATURE_PAGECACHE static void nfs_invalidate_cache(BlockDriverState *bs, Error **errp) @@ -908,6 +921,7 @@ static BlockDriver bdrv_nfs =3D { .bdrv_detach_aio_context =3D nfs_detach_aio_context, .bdrv_attach_aio_context =3D nfs_attach_aio_context, .bdrv_refresh_filename =3D nfs_refresh_filename, + .bdrv_dirname =3D nfs_dirname, =20 #ifdef LIBNFS_FEATURE_PAGECACHE .bdrv_invalidate_cache =3D nfs_invalidate_cache, --=20 2.13.6 From nobody Sun Apr 28 10:05:15 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 1511208808297160.77525903015953; Mon, 20 Nov 2017 12:13:28 -0800 (PST) Received: from localhost ([::1]:59505 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsRW-000209-DW for importer@patchew.org; Mon, 20 Nov 2017 15:13:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35415) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsPh-0000IC-At for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:11:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGsPc-0007S8-VF for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:11:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44974) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGsPa-0007PH-LF; Mon, 20 Nov 2017 15:11:22 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DDD1CC058EB0; Mon, 20 Nov 2017 20:11:21 +0000 (UTC) Received: from localhost (ovpn-204-75.brq.redhat.com [10.40.204.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8B0FD84F61; Mon, 20 Nov 2017 20:11:19 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 20 Nov 2017 21:09:55 +0100 Message-Id: <20171120201004.14999-17-mreitz@redhat.com> In-Reply-To: <20171120201004.14999-1-mreitz@redhat.com> References: <20171120201004.14999-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 20 Nov 2017 20:11:21 +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 v7 for-2.12 16/25] block: Use bdrv_dirname() for relative filenames X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , John Snow , qemu-devel@nongnu.org, Max Reitz 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" bdrv_get_full_backing_filename_from_filename() breaks down when it comes to JSON filenames. Using bdrv_dirname() as the basis is better because since we have BDS, we can descend through the BDS tree to the protocol layer, which gives us a greater probability of finding a non-JSON name; also, bdrv_dirname() is more correct as it allows block drivers to override the generation of that directory name in a protocol-specific way. We still need to keep bdrv_get_full_backing_filename_from_filename(), though, because it has valid callers which need it during image creation when no BDS is available yet. This makes a test case in qemu-iotest 110, which was supposed to fail, work. That is actually good, but we need to change the reference output (and the comment in 110) accordingly. Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia --- block.c | 20 +++++++++++++++----- tests/qemu-iotests/110 | 3 ++- tests/qemu-iotests/110.out | 2 +- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/block.c b/block.c index 20e45c85c6..2e59e77f9d 100644 --- a/block.c +++ b/block.c @@ -311,12 +311,22 @@ char *bdrv_get_full_backing_filename_from_filename(co= nst char *backed, static char *bdrv_make_absolute_filename(BlockDriverState *relative_to, const char *filename, Error **err= p) { - char *bs_filename =3D relative_to->exact_filename[0] - ? relative_to->exact_filename - : relative_to->filename; + char *dir, *full_name; =20 - return bdrv_get_full_backing_filename_from_filename(bs_filename, - filename ?: "", er= rp); + if (!filename || filename[0] =3D=3D '\0') { + return NULL; + } else if (path_has_protocol(filename) || path_is_absolute(filename)) { + return g_strdup(filename); + } + + dir =3D bdrv_dirname(relative_to, errp); + if (!dir) { + return NULL; + } + + full_name =3D g_strconcat(dir, filename, NULL); + g_free(dir); + return full_name; } =20 char *bdrv_get_full_backing_filename(BlockDriverState *bs, Error **errp) diff --git a/tests/qemu-iotests/110 b/tests/qemu-iotests/110 index 9de7369f3a..ba1b3c6c7d 100755 --- a/tests/qemu-iotests/110 +++ b/tests/qemu-iotests/110 @@ -61,7 +61,8 @@ echo '=3D=3D=3D Non-reconstructable filename =3D=3D=3D' echo =20 # Across blkdebug without a config file, you cannot reconstruct filenames,= so -# qemu is incapable of knowing the directory of the top image +# qemu is incapable of knowing the directory of the top image from the fil= ename +# alone. However, using bdrv_dirname(), it should still work. TEST_IMG=3D"json:{ 'driver': '$IMGFMT', 'file': { diff --git a/tests/qemu-iotests/110.out b/tests/qemu-iotests/110.out index b3584ff87f..5370bc1d26 100644 --- a/tests/qemu-iotests/110.out +++ b/tests/qemu-iotests/110.out @@ -14,7 +14,7 @@ backing file: t.IMGFMT.base (actual path: TEST_DIR/t.IMGF= MT.base) image: json:{"driver": "IMGFMT", "file": {"set-state.0.event": "read_aio",= "image": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "driver": "b= lkdebug", "set-state.0.new_state": 42}} file format: IMGFMT virtual size: 64M (67108864 bytes) -backing file: t.IMGFMT.base (cannot determine actual path) +backing file: t.IMGFMT.base (actual path: TEST_DIR/t.IMGFMT.base) =20 =3D=3D=3D Backing name is always relative to the backed image =3D=3D=3D =20 --=20 2.13.6 From nobody Sun Apr 28 10:05:15 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1511208980055259.98713382679364; Mon, 20 Nov 2017 12:16:20 -0800 (PST) Received: from localhost ([::1]:59522 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsUA-0004O9-7L for importer@patchew.org; Mon, 20 Nov 2017 15:16:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35455) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsPk-0000L5-4X for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:11:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGsPj-0007bM-4T for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:11:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45050) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGsPg-0007XJ-LG; Mon, 20 Nov 2017 15:11:28 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DEC45C058EAF; Mon, 20 Nov 2017 20:11:27 +0000 (UTC) Received: from localhost (ovpn-204-75.brq.redhat.com [10.40.204.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 473E34DC50; Mon, 20 Nov 2017 20:11:24 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 20 Nov 2017 21:09:56 +0100 Message-Id: <20171120201004.14999-18-mreitz@redhat.com> In-Reply-To: <20171120201004.14999-1-mreitz@redhat.com> References: <20171120201004.14999-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 20 Nov 2017 20:11:27 +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 v7 for-2.12 17/25] iotests: Add quorum case to test 110 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , John Snow , qemu-devel@nongnu.org, Max Reitz 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" Test 110 tests relative backing filenames for complex BDS trees. Now that the originally supposedly failing test passes, let us add a new failing test: Quorum can never work automatically (without detecting whether all child nodes have the same base directory, but that would be rather inconsistent behavior). Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia --- tests/qemu-iotests/110 | 26 ++++++++++++++++++++++++++ tests/qemu-iotests/110.out | 7 +++++++ 2 files changed, 33 insertions(+) diff --git a/tests/qemu-iotests/110 b/tests/qemu-iotests/110 index ba1b3c6c7d..08976c8a61 100755 --- a/tests/qemu-iotests/110 +++ b/tests/qemu-iotests/110 @@ -30,6 +30,7 @@ status=3D1 # failure is the default! _cleanup() { _cleanup_test_img + rm -f "$TEST_IMG.copy" } trap "_cleanup; exit \$status" 0 1 2 3 15 =20 @@ -87,6 +88,31 @@ echo # omit the image size; it should work anyway _make_test_img -b "$TEST_IMG_REL.base" =20 +echo +echo '=3D=3D=3D Nodes without a common directory =3D=3D=3D' +echo + +cp "$TEST_IMG" "$TEST_IMG.copy" + +# Should inform us that the actual path of the backing file cannot be dete= rmined +TEST_IMG=3D"json:{ + 'driver': '$IMGFMT', + 'file': { + 'driver': 'quorum', + 'vote-threshold': 1, + 'children': [ + { + 'driver': 'file', + 'filename': '$TEST_IMG' + }, + { + 'driver': 'file', + 'filename': '$TEST_IMG.copy' + } + ] + } +}" _img_info | _filter_img_info + =20 # success, all done echo '*** done' diff --git a/tests/qemu-iotests/110.out b/tests/qemu-iotests/110.out index 5370bc1d26..1d0b2475cc 100644 --- a/tests/qemu-iotests/110.out +++ b/tests/qemu-iotests/110.out @@ -19,4 +19,11 @@ backing file: t.IMGFMT.base (actual path: TEST_DIR/t.IMG= FMT.base) =3D=3D=3D Backing name is always relative to the backed image =3D=3D=3D =20 Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 backing_file= =3Dt.IMGFMT.base + +=3D=3D=3D Nodes without a common directory =3D=3D=3D + +image: json:{"driver": "IMGFMT", "file": {"children": [{"driver": "file", = "filename": "TEST_DIR/t.IMGFMT"}, {"driver": "file", "filename": "TEST_DIR/= t.IMGFMT.copy"}], "driver": "quorum", "blkverify": false, "rewrite-corrupte= d": false, "vote-threshold": 1}} +file format: IMGFMT +virtual size: 64M (67108864 bytes) +backing file: t.IMGFMT.base (cannot determine actual path) *** done --=20 2.13.6 From nobody Sun Apr 28 10:05:15 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1511209529472390.7571091842998; Mon, 20 Nov 2017 12:25:29 -0800 (PST) Received: from localhost ([::1]:59569 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGscz-0003he-3j for importer@patchew.org; Mon, 20 Nov 2017 15:25:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35551) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsPv-0000WH-MP for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:11:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGsPt-0007ip-3h for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:11:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32896) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGsPl-0007fc-W7; Mon, 20 Nov 2017 15:11:34 -0500 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 3DDD481DF3; Mon, 20 Nov 2017 20:11:33 +0000 (UTC) Received: from localhost (ovpn-204-75.brq.redhat.com [10.40.204.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 509B860BE0; Mon, 20 Nov 2017 20:11:30 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 20 Nov 2017 21:09:57 +0100 Message-Id: <20171120201004.14999-19-mreitz@redhat.com> In-Reply-To: <20171120201004.14999-1-mreitz@redhat.com> References: <20171120201004.14999-1-mreitz@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.25]); Mon, 20 Nov 2017 20:11:33 +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 v7 for-2.12 18/25] block: Add sgfnt_runtime_opts to BlockDriver X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , John Snow , qemu-devel@nongnu.org, Max Reitz 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 new field can be set by block drivers to list the runtime options they accept that may influence the contents of the respective BDS. As of a follow-up patch, this list will be used by the common bdrv_refresh_filename() implementation to decide which options to put into BDS.full_open_options (and consequently whether a JSON filename has to be created), thus freeing the drivers of having to implement that logic themselves. Additionally, this patch adds the field to all of the block drivers that need it and sets it accordingly. Signed-off-by: Max Reitz --- include/block/block_int.h | 7 +++++++ block/blkdebug.c | 17 +++++++++++++++++ block/crypto.c | 8 ++++++++ block/curl.c | 21 +++++++++++++++++++++ block/gluster.c | 19 +++++++++++++++++++ block/iscsi.c | 18 ++++++++++++++++++ block/nbd.c | 14 ++++++++++++++ block/nfs.c | 11 +++++++++++ block/null.c | 9 +++++++++ block/qcow.c | 7 +++++++ block/qcow2.c | 7 +++++++ block/quorum.c | 11 +++++++++++ block/raw-format.c | 10 +++++++++- block/rbd.c | 14 ++++++++++++++ block/replication.c | 8 ++++++++ block/sheepdog.c | 12 ++++++++++++ block/ssh.c | 12 ++++++++++++ block/throttle.c | 7 +++++++ block/vpc.c | 7 +++++++ block/vvfat.c | 12 ++++++++++++ block/vxhs.c | 11 +++++++++++ 21 files changed, 241 insertions(+), 1 deletion(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index c07882962d..d99ded8891 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -454,6 +454,13 @@ struct BlockDriver { Error **errp); =20 QLIST_ENTRY(BlockDriver) list; + + /* Pointer to a NULL-terminated array of names of significant options = that + * can be specified for bdrv_open(). A significant option is one that + * changes the data of a BDS. + * If this pointer is NULL, the array is considered empty. + * "filename" and "driver" are always considered significant. */ + const char *const *sgfnt_runtime_opts; }; =20 typedef struct BlockLimits { diff --git a/block/blkdebug.c b/block/blkdebug.c index e21669979d..f93139da58 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -886,6 +886,21 @@ static int blkdebug_reopen_prepare(BDRVReopenState *re= open_state, return 0; } =20 +static const char *const blkdebug_sgfnt_runtime_opts[] =3D { + "config", + "inject-error.", + "set-state.", + "suspend.", + "align", + "max-transfer", + "opt-write-zero", + "max-write-zero", + "opt-discard", + "max-discard", + + NULL +}; + static BlockDriver bdrv_blkdebug =3D { .format_name =3D "blkdebug", .protocol_name =3D "blkdebug", @@ -915,6 +930,8 @@ static BlockDriver bdrv_blkdebug =3D { =3D blkdebug_debug_remove_breakpoint, .bdrv_debug_resume =3D blkdebug_debug_resume, .bdrv_debug_is_suspended =3D blkdebug_debug_is_suspended, + + .sgfnt_runtime_opts =3D blkdebug_sgfnt_runtime_opts, }; =20 static void bdrv_blkdebug_init(void) diff --git a/block/crypto.c b/block/crypto.c index 60ddf8623e..492e64e922 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -609,6 +609,12 @@ block_crypto_get_specific_info_luks(BlockDriverState *= bs) return spec_info; } =20 +static const char *const block_crypto_sgfnt_runtime_opts[] =3D { + BLOCK_CRYPTO_OPT_LUKS_KEY_SECRET, + + NULL +}; + BlockDriver bdrv_crypto_luks =3D { .format_name =3D "luks", .instance_size =3D sizeof(BlockCrypto), @@ -626,6 +632,8 @@ BlockDriver bdrv_crypto_luks =3D { .bdrv_getlength =3D block_crypto_getlength, .bdrv_get_info =3D block_crypto_get_info_luks, .bdrv_get_specific_info =3D block_crypto_get_specific_info_luks, + + .sgfnt_runtime_opts =3D block_crypto_sgfnt_runtime_opts, }; =20 static void block_crypto_init(void) diff --git a/block/curl.c b/block/curl.c index 2a244e2439..11318a9a29 100644 --- a/block/curl.c +++ b/block/curl.c @@ -957,6 +957,19 @@ static int64_t curl_getlength(BlockDriverState *bs) return s->len; } =20 +static const char *const curl_sgfnt_runtime_opts[] =3D { + CURL_BLOCK_OPT_URL, + CURL_BLOCK_OPT_SSLVERIFY, + CURL_BLOCK_OPT_COOKIE, + CURL_BLOCK_OPT_COOKIE_SECRET, + CURL_BLOCK_OPT_USERNAME, + CURL_BLOCK_OPT_PASSWORD_SECRET, + CURL_BLOCK_OPT_PROXY_USERNAME, + CURL_BLOCK_OPT_PROXY_PASSWORD_SECRET, + + NULL +}; + static BlockDriver bdrv_http =3D { .format_name =3D "http", .protocol_name =3D "http", @@ -971,6 +984,8 @@ static BlockDriver bdrv_http =3D { =20 .bdrv_detach_aio_context =3D curl_detach_aio_context, .bdrv_attach_aio_context =3D curl_attach_aio_context, + + .sgfnt_runtime_opts =3D curl_sgfnt_runtime_opts, }; =20 static BlockDriver bdrv_https =3D { @@ -987,6 +1002,8 @@ static BlockDriver bdrv_https =3D { =20 .bdrv_detach_aio_context =3D curl_detach_aio_context, .bdrv_attach_aio_context =3D curl_attach_aio_context, + + .sgfnt_runtime_opts =3D curl_sgfnt_runtime_opts, }; =20 static BlockDriver bdrv_ftp =3D { @@ -1003,6 +1020,8 @@ static BlockDriver bdrv_ftp =3D { =20 .bdrv_detach_aio_context =3D curl_detach_aio_context, .bdrv_attach_aio_context =3D curl_attach_aio_context, + + .sgfnt_runtime_opts =3D curl_sgfnt_runtime_opts, }; =20 static BlockDriver bdrv_ftps =3D { @@ -1019,6 +1038,8 @@ static BlockDriver bdrv_ftps =3D { =20 .bdrv_detach_aio_context =3D curl_detach_aio_context, .bdrv_attach_aio_context =3D curl_attach_aio_context, + + .sgfnt_runtime_opts =3D curl_sgfnt_runtime_opts, }; =20 static void curl_block_init(void) diff --git a/block/gluster.c b/block/gluster.c index 0f4265a3a4..e47bda97df 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -1414,6 +1414,21 @@ static int64_t coroutine_fn qemu_gluster_co_get_bloc= k_status( } =20 =20 +static const char *const gluster_sgfnt_open_opts[] =3D { + GLUSTER_OPT_VOLUME, + GLUSTER_OPT_PATH, + GLUSTER_OPT_TYPE, + GLUSTER_OPT_SERVER_PATTERN, + GLUSTER_OPT_HOST, + GLUSTER_OPT_PORT, + GLUSTER_OPT_TO, + GLUSTER_OPT_IPV4, + GLUSTER_OPT_IPV6, + GLUSTER_OPT_SOCKET, + + NULL +}; + static BlockDriver bdrv_gluster =3D { .format_name =3D "gluster", .protocol_name =3D "gluster", @@ -1440,6 +1455,7 @@ static BlockDriver bdrv_gluster =3D { #endif .bdrv_co_get_block_status =3D qemu_gluster_co_get_block_status, .create_opts =3D &qemu_gluster_create_opts, + .sgfnt_runtime_opts =3D gluster_sgfnt_open_opts, }; =20 static BlockDriver bdrv_gluster_tcp =3D { @@ -1468,6 +1484,7 @@ static BlockDriver bdrv_gluster_tcp =3D { #endif .bdrv_co_get_block_status =3D qemu_gluster_co_get_block_status, .create_opts =3D &qemu_gluster_create_opts, + .sgfnt_runtime_opts =3D gluster_sgfnt_open_opts, }; =20 static BlockDriver bdrv_gluster_unix =3D { @@ -1496,6 +1513,7 @@ static BlockDriver bdrv_gluster_unix =3D { #endif .bdrv_co_get_block_status =3D qemu_gluster_co_get_block_status, .create_opts =3D &qemu_gluster_create_opts, + .sgfnt_runtime_opts =3D gluster_sgfnt_open_opts, }; =20 /* rdma is deprecated (actually never supported for volfile fetch). @@ -1530,6 +1548,7 @@ static BlockDriver bdrv_gluster_rdma =3D { #endif .bdrv_co_get_block_status =3D qemu_gluster_co_get_block_status, .create_opts =3D &qemu_gluster_create_opts, + .sgfnt_runtime_opts =3D gluster_sgfnt_open_opts, }; =20 static void bdrv_gluster_init(void) diff --git a/block/iscsi.c b/block/iscsi.c index 4683f3b244..5da74e3ccb 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -2161,6 +2161,20 @@ static QemuOptsList iscsi_create_opts =3D { } }; =20 +static const char *const iscsi_sgfnt_runtime_opts[] =3D { + "transport", + "portal", + "target", + "user", + "password", + "password-secret", + "lun", + "initiator-name", + "header-digest", + + NULL +}; + static BlockDriver bdrv_iscsi =3D { .format_name =3D "iscsi", .protocol_name =3D "iscsi", @@ -2193,6 +2207,8 @@ static BlockDriver bdrv_iscsi =3D { =20 .bdrv_detach_aio_context =3D iscsi_detach_aio_context, .bdrv_attach_aio_context =3D iscsi_attach_aio_context, + + .sgfnt_runtime_opts =3D iscsi_sgfnt_runtime_opts, }; =20 #if LIBISCSI_API_VERSION >=3D (20160603) @@ -2228,6 +2244,8 @@ static BlockDriver bdrv_iser =3D { =20 .bdrv_detach_aio_context =3D iscsi_detach_aio_context, .bdrv_attach_aio_context =3D iscsi_attach_aio_context, + + .sgfnt_runtime_opts =3D iscsi_sgfnt_runtime_opts, }; #endif =20 diff --git a/block/nbd.c b/block/nbd.c index ed921fa333..0a36394b73 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -575,6 +575,17 @@ static char *nbd_dirname(BlockDriverState *bs, Error *= *errp) return NULL; } =20 +static const char *const nbd_sgfnt_runtime_opts[] =3D { + "path", + "host", + "port", + "export", + "tls-creds", + "server.", + + NULL +}; + static BlockDriver bdrv_nbd =3D { .format_name =3D "nbd", .protocol_name =3D "nbd", @@ -593,6 +604,7 @@ static BlockDriver bdrv_nbd =3D { .bdrv_attach_aio_context =3D nbd_attach_aio_context, .bdrv_refresh_filename =3D nbd_refresh_filename, .bdrv_dirname =3D nbd_dirname, + .sgfnt_runtime_opts =3D nbd_sgfnt_runtime_opts, }; =20 static BlockDriver bdrv_nbd_tcp =3D { @@ -613,6 +625,7 @@ static BlockDriver bdrv_nbd_tcp =3D { .bdrv_attach_aio_context =3D nbd_attach_aio_context, .bdrv_refresh_filename =3D nbd_refresh_filename, .bdrv_dirname =3D nbd_dirname, + .sgfnt_runtime_opts =3D nbd_sgfnt_runtime_opts, }; =20 static BlockDriver bdrv_nbd_unix =3D { @@ -633,6 +646,7 @@ static BlockDriver bdrv_nbd_unix =3D { .bdrv_attach_aio_context =3D nbd_attach_aio_context, .bdrv_refresh_filename =3D nbd_refresh_filename, .bdrv_dirname =3D nbd_dirname, + .sgfnt_runtime_opts =3D nbd_sgfnt_runtime_opts, }; =20 static void bdrv_nbd_init(void) diff --git a/block/nfs.c b/block/nfs.c index 0152a9bd32..445a8d9880 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -897,6 +897,15 @@ static void nfs_invalidate_cache(BlockDriverState *bs, } #endif =20 +static const char *nfs_sgfnt_runtime_opts[] =3D { + "path", + "user", + "group", + "server.", + + NULL +}; + static BlockDriver bdrv_nfs =3D { .format_name =3D "nfs", .protocol_name =3D "nfs", @@ -923,6 +932,8 @@ static BlockDriver bdrv_nfs =3D { .bdrv_refresh_filename =3D nfs_refresh_filename, .bdrv_dirname =3D nfs_dirname, =20 + .sgfnt_runtime_opts =3D nfs_sgfnt_runtime_opts, + #ifdef LIBNFS_FEATURE_PAGECACHE .bdrv_invalidate_cache =3D nfs_invalidate_cache, #endif diff --git a/block/null.c b/block/null.c index dd9c13f9ba..59673d2449 100644 --- a/block/null.c +++ b/block/null.c @@ -255,6 +255,13 @@ static void null_refresh_filename(BlockDriverState *bs= , QDict *opts) bs->full_open_options =3D opts; } =20 +static const char *const null_sgfnt_runtime_opts[] =3D { + BLOCK_OPT_SIZE, + NULL_OPT_ZEROES, + + NULL +}; + static BlockDriver bdrv_null_co =3D { .format_name =3D "null-co", .protocol_name =3D "null-co", @@ -273,6 +280,7 @@ static BlockDriver bdrv_null_co =3D { .bdrv_co_get_block_status =3D null_co_get_block_status, =20 .bdrv_refresh_filename =3D null_refresh_filename, + .sgfnt_runtime_opts =3D null_sgfnt_runtime_opts, }; =20 static BlockDriver bdrv_null_aio =3D { @@ -293,6 +301,7 @@ static BlockDriver bdrv_null_aio =3D { .bdrv_co_get_block_status =3D null_co_get_block_status, =20 .bdrv_refresh_filename =3D null_refresh_filename, + .sgfnt_runtime_opts =3D null_sgfnt_runtime_opts, }; =20 static void bdrv_null_init(void) diff --git a/block/qcow.c b/block/qcow.c index 9569deeaf0..2bfe506ec4 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -1097,6 +1097,12 @@ static QemuOptsList qcow_create_opts =3D { } }; =20 +static const char *const qcow_sgfnt_runtime_opts[] =3D { + "encrypt." BLOCK_CRYPTO_OPT_QCOW_KEY_SECRET, + + NULL +}; + static BlockDriver bdrv_qcow =3D { .format_name =3D "qcow", .instance_size =3D sizeof(BDRVQcowState), @@ -1118,6 +1124,7 @@ static BlockDriver bdrv_qcow =3D { .bdrv_get_info =3D qcow_get_info, =20 .create_opts =3D &qcow_create_opts, + .sgfnt_runtime_opts =3D qcow_sgfnt_runtime_opts, }; =20 static void bdrv_qcow_init(void) diff --git a/block/qcow2.c b/block/qcow2.c index 1914a940e5..2c50eb9245 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -4342,6 +4342,12 @@ static QemuOptsList qcow2_create_opts =3D { } }; =20 +static const char *const qcow2_sgfnt_runtime_opts[] =3D { + "encrypt." BLOCK_CRYPTO_OPT_QCOW_KEY_SECRET, + + NULL +}; + BlockDriver bdrv_qcow2 =3D { .format_name =3D "qcow2", .instance_size =3D sizeof(BDRVQcow2State), @@ -4387,6 +4393,7 @@ BlockDriver bdrv_qcow2 =3D { .bdrv_inactivate =3D qcow2_inactivate, =20 .create_opts =3D &qcow2_create_opts, + .sgfnt_runtime_opts =3D qcow2_sgfnt_runtime_opts, .bdrv_check =3D qcow2_check, .bdrv_amend_options =3D qcow2_amend_options, =20 diff --git a/block/quorum.c b/block/quorum.c index e5a844335e..4b38201aa2 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -1105,6 +1105,15 @@ static char *quorum_dirname(BlockDriverState *bs, Er= ror **errp) return NULL; } =20 +static const char *const quorum_sgfnt_runtime_opts[] =3D { + QUORUM_OPT_VOTE_THRESHOLD, + QUORUM_OPT_BLKVERIFY, + QUORUM_OPT_REWRITE, + QUORUM_OPT_READ_PATTERN, + + NULL +}; + static BlockDriver bdrv_quorum =3D { .format_name =3D "quorum", .protocol_name =3D "quorum", @@ -1130,6 +1139,8 @@ static BlockDriver bdrv_quorum =3D { =20 .is_filter =3D true, .bdrv_recurse_is_first_non_filter =3D quorum_recurse_is_first_non_fi= lter, + + .sgfnt_runtime_opts =3D quorum_sgfnt_runtime_opts, }; =20 static void bdrv_quorum_init(void) diff --git a/block/raw-format.c b/block/raw-format.c index ab552c0954..f09b707b0d 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -481,6 +481,13 @@ static int raw_probe_geometry(BlockDriverState *bs, HD= Geometry *geo) return bdrv_probe_geometry(bs->file->bs, geo); } =20 +static const char *const raw_sgfnt_runtime_opts[] =3D { + "offset", + "size", + + NULL +}; + BlockDriver bdrv_raw =3D { .format_name =3D "raw", .instance_size =3D sizeof(BDRVRawState), @@ -509,7 +516,8 @@ BlockDriver bdrv_raw =3D { .bdrv_lock_medium =3D &raw_lock_medium, .bdrv_co_ioctl =3D &raw_co_ioctl, .create_opts =3D &raw_create_opts, - .bdrv_has_zero_init =3D &raw_has_zero_init + .bdrv_has_zero_init =3D &raw_has_zero_init, + .sgfnt_runtime_opts =3D raw_sgfnt_runtime_opts, }; =20 static void bdrv_raw_init(void) diff --git a/block/rbd.c b/block/rbd.c index a76a5e8755..389f006bea 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -1122,6 +1122,18 @@ static QemuOptsList qemu_rbd_create_opts =3D { } }; =20 +static const char *const qemu_rbd_sgfnt_runtime_opts[] =3D { + "pool", + "image", + "conf", + "snapshot", + "user", + "server.", + "password-secret", + + NULL +}; + static BlockDriver bdrv_rbd =3D { .format_name =3D "rbd", .instance_size =3D sizeof(BDRVRBDState), @@ -1157,6 +1169,8 @@ static BlockDriver bdrv_rbd =3D { #ifdef LIBRBD_SUPPORTS_INVALIDATE .bdrv_invalidate_cache =3D qemu_rbd_invalidate_cache, #endif + + .sgfnt_runtime_opts =3D qemu_rbd_sgfnt_runtime_opts, }; =20 static void bdrv_rbd_init(void) diff --git a/block/replication.c b/block/replication.c index e41e293d2b..c2b9442a5f 100644 --- a/block/replication.c +++ b/block/replication.c @@ -695,6 +695,13 @@ static void replication_stop(ReplicationState *rs, boo= l failover, Error **errp) aio_context_release(aio_context); } =20 +static const char *const replication_sgfnt_runtime_opts[] =3D { + REPLICATION_MODE, + REPLICATION_TOP_ID, + + NULL +}; + BlockDriver bdrv_replication =3D { .format_name =3D "replication", .protocol_name =3D "replication", @@ -712,6 +719,7 @@ BlockDriver bdrv_replication =3D { .bdrv_recurse_is_first_non_filter =3D replication_recurse_is_first_non= _filter, =20 .has_variable_length =3D true, + .sgfnt_runtime_opts =3D replication_sgfnt_runtime_opts, }; =20 static void bdrv_replication_init(void) diff --git a/block/sheepdog.c b/block/sheepdog.c index 696a71442a..1b788534b6 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -3077,6 +3077,15 @@ static QemuOptsList sd_create_opts =3D { } }; =20 +static const char *const sd_sgfnt_runtime_opts[] =3D { + "vdi", + "snap-id", + "tag", + "server.", + + NULL +}; + static BlockDriver bdrv_sheepdog =3D { .format_name =3D "sheepdog", .protocol_name =3D "sheepdog", @@ -3111,6 +3120,7 @@ static BlockDriver bdrv_sheepdog =3D { .bdrv_attach_aio_context =3D sd_attach_aio_context, =20 .create_opts =3D &sd_create_opts, + .sgfnt_runtime_opts =3D sd_sgfnt_runtime_opts, }; =20 static BlockDriver bdrv_sheepdog_tcp =3D { @@ -3147,6 +3157,7 @@ static BlockDriver bdrv_sheepdog_tcp =3D { .bdrv_attach_aio_context =3D sd_attach_aio_context, =20 .create_opts =3D &sd_create_opts, + .sgfnt_runtime_opts =3D sd_sgfnt_runtime_opts, }; =20 static BlockDriver bdrv_sheepdog_unix =3D { @@ -3183,6 +3194,7 @@ static BlockDriver bdrv_sheepdog_unix =3D { .bdrv_attach_aio_context =3D sd_attach_aio_context, =20 .create_opts =3D &sd_create_opts, + .sgfnt_runtime_opts =3D sd_sgfnt_runtime_opts, }; =20 static void bdrv_sheepdog_init(void) diff --git a/block/ssh.c b/block/ssh.c index b049a16eb9..0015c06a3b 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -1195,6 +1195,17 @@ static int64_t ssh_getlength(BlockDriverState *bs) return length; } =20 +static const char *const ssh_sgfnt_runtime_opts[] =3D { + "host", + "port", + "path", + "user", + "host_key_check", + "server.", + + NULL +}; + static BlockDriver bdrv_ssh =3D { .format_name =3D "ssh", .protocol_name =3D "ssh", @@ -1209,6 +1220,7 @@ static BlockDriver bdrv_ssh =3D { .bdrv_getlength =3D ssh_getlength, .bdrv_co_flush_to_disk =3D ssh_co_flush, .create_opts =3D &ssh_create_opts, + .sgfnt_runtime_opts =3D ssh_sgfnt_runtime_opts, }; =20 static void bdrv_ssh_init(void) diff --git a/block/throttle.c b/block/throttle.c index 833175ac77..efdc57616b 100644 --- a/block/throttle.c +++ b/block/throttle.c @@ -212,6 +212,12 @@ static void coroutine_fn throttle_co_drain_end(BlockDr= iverState *bs) atomic_dec(&tgm->io_limits_disabled); } =20 +static const char *const throttle_sgfnt_runtime_opts[] =3D { + QEMU_OPT_THROTTLE_GROUP_NAME, + + NULL +}; + static BlockDriver bdrv_throttle =3D { .format_name =3D "throttle", .protocol_name =3D "throttle", @@ -245,6 +251,7 @@ static BlockDriver bdrv_throttle =3D { .bdrv_co_drain_end =3D throttle_co_drain_end, =20 .is_filter =3D true, + .sgfnt_runtime_opts =3D throttle_sgfnt_runtime_opts, }; =20 static void bdrv_throttle_init(void) diff --git a/block/vpc.c b/block/vpc.c index 1576d7b595..a0a30b6e33 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -1084,6 +1084,12 @@ static QemuOptsList vpc_create_opts =3D { } }; =20 +static const char *const vpc_sgfnt_runtime_opts[] =3D { + VPC_OPT_SIZE_CALC, + + NULL +}; + static BlockDriver bdrv_vpc =3D { .format_name =3D "vpc", .instance_size =3D sizeof(BDRVVPCState), @@ -1103,6 +1109,7 @@ static BlockDriver bdrv_vpc =3D { =20 .create_opts =3D &vpc_create_opts, .bdrv_has_zero_init =3D vpc_has_zero_init, + .sgfnt_runtime_opts =3D vpc_sgfnt_runtime_opts, }; =20 static void bdrv_vpc_init(void) diff --git a/block/vvfat.c b/block/vvfat.c index a690595f2c..76a91f97cb 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -3242,6 +3242,16 @@ static void vvfat_close(BlockDriverState *bs) } } =20 +static const char *const vvfat_sgfnt_runtime_opts[] =3D { + "dir", + "fat-type", + "floppy", + "label", + "rw", + + NULL +}; + static BlockDriver bdrv_vvfat =3D { .format_name =3D "vvfat", .protocol_name =3D "fat", @@ -3256,6 +3266,8 @@ static BlockDriver bdrv_vvfat =3D { .bdrv_co_preadv =3D vvfat_co_preadv, .bdrv_co_pwritev =3D vvfat_co_pwritev, .bdrv_co_get_block_status =3D vvfat_co_get_block_status, + + .sgfnt_runtime_opts =3D vvfat_sgfnt_runtime_opts, }; =20 static void bdrv_vvfat_init(void) diff --git a/block/vxhs.c b/block/vxhs.c index 75cc6c8672..4d6dc5fe4c 100644 --- a/block/vxhs.c +++ b/block/vxhs.c @@ -555,6 +555,16 @@ static int64_t vxhs_getlength(BlockDriverState *bs) return vdisk_size; } =20 +static const char *const vxhs_sgfnt_runtime_opts[] =3D { + VXHS_OPT_VDISK_ID, + "tls-creds", + VXHS_OPT_HOST, + VXHS_OPT_PORT, + VXHS_OPT_SERVER".", + + NULL +}; + static BlockDriver bdrv_vxhs =3D { .format_name =3D "vxhs", .protocol_name =3D "vxhs", @@ -565,6 +575,7 @@ static BlockDriver bdrv_vxhs =3D { .bdrv_getlength =3D vxhs_getlength, .bdrv_aio_readv =3D vxhs_aio_readv, .bdrv_aio_writev =3D vxhs_aio_writev, + .sgfnt_runtime_opts =3D vxhs_sgfnt_runtime_opts, }; =20 static void bdrv_vxhs_init(void) --=20 2.13.6 From nobody Sun Apr 28 10:05:15 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 1511209791318961.2392260780941; Mon, 20 Nov 2017 12:29:51 -0800 (PST) Received: from localhost ([::1]:59598 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGshO-0008LI-J8 for importer@patchew.org; Mon, 20 Nov 2017 15:29:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35556) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsPv-0000WT-SW for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:11:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGsPu-0007ja-G6 for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:11:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44324) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGsPo-0007gy-Rj; Mon, 20 Nov 2017 15:11:37 -0500 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 1906F7F7AB; Mon, 20 Nov 2017 20:11:36 +0000 (UTC) Received: from localhost (ovpn-204-75.brq.redhat.com [10.40.204.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 86CD460C80; Mon, 20 Nov 2017 20:11:35 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 20 Nov 2017 21:09:58 +0100 Message-Id: <20171120201004.14999-20-mreitz@redhat.com> In-Reply-To: <20171120201004.14999-1-mreitz@redhat.com> References: <20171120201004.14999-1-mreitz@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.28]); Mon, 20 Nov 2017 20:11:36 +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 v7 for-2.12 19/25] block: Add BlockDriver.bdrv_gather_child_options X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , John Snow , qemu-devel@nongnu.org, Max Reitz 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" Some follow-up patches will rework the way bs->full_open_options is refreshed in bdrv_refresh_filename(). The new implementation will remove the need for the block drivers' bdrv_refresh_filename() implementations to set bs->full_open_options; instead, it will be generic and use static information from each block driver. However, by implementing bdrv_gather_child_options(), block drivers will still be able to override the way the full_open_options of their children are incorporated into their own. We need to implement this function for VMDK because we have to prevent the generic implementation from gathering the options of all children: It is not possible to specify options for the extents through the runtime options. For quorum, the child names that would be used by the generic implementation and the ones that we actually (currently) want to use differ. See quorum_gather_child_options() for more information. Note that both of these are cases which are not ideal: In case of VMDK it would probably be nice to be able to specify options for all extents. In case of quorum, the current runtime option structure is simply broken and needs to be fixed (but that is left for another patch). Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia --- include/block/block_int.h | 17 +++++++++++++++++ block/quorum.c | 38 ++++++++++++++++++++++++++++++++++++++ block/vmdk.c | 13 +++++++++++++ 3 files changed, 68 insertions(+) diff --git a/include/block/block_int.h b/include/block/block_int.h index d99ded8891..f81516b615 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -136,6 +136,23 @@ struct BlockDriver { void (*bdrv_refresh_filename)(BlockDriverState *bs, QDict *options); =20 /* + * Gathers the open options for all children into @target. + * A simple format driver (without backing file support) might + * implement this function like this: + * + * QINCREF(bs->file->bs->full_open_options); + * qdict_put(target, "file", bs->file->bs->full_open_options); + * + * If not specified, the generic implementation will simply put + * all children's options under their respective name. + * + * Note that ideally this function would not be needed. Every + * block driver which implements it is probably doing something + * shady regarding its runtime option structure. + */ + void (*bdrv_gather_child_options)(BlockDriverState *bs, QDict *target); + + /* * Returns an allocated string which is the directory name of this BDS= : It * will be used to make relative filenames absolute by prepending this * function's return value to them. diff --git a/block/quorum.c b/block/quorum.c index 4b38201aa2..9d680addc6 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -1095,6 +1095,43 @@ static void quorum_refresh_filename(BlockDriverState= *bs, QDict *options) bs->full_open_options =3D opts; } =20 +static void quorum_gather_child_options(BlockDriverState *bs, QDict *targe= t) +{ + BDRVQuorumState *s =3D bs->opaque; + QList *children_list; + int i; + + /* The generic implementation for gathering child options in + * bdrv_refresh_filename() would use the names of the children + * as specified for bdrv_open_child() or bdrv_attach_child(), + * which is "children.%u" with %u being a value + * (s->next_child_index) that is incremented each time a new child + * is added (and never decremented). Since children can be + * deleted at runtime, there may be gaps in that enumeration. + * When creating a new quorum BDS and specifying the children for + * it through runtime options, the enumeration used there may not + * have any gaps, though. + * + * Therefore, we have to create a new gap-less enumeration here + * (which we can achieve by simply putting all of the children's + * full_open_options into a QList). + * + * XXX: Note that there are issues with the current child option + * structure quorum uses (such as the fact that children do + * not really have unique permanent names). Therefore, this + * is going to have to change in the future and ideally we + * want quorum to be covered by the generic implementation. + */ + + children_list =3D qlist_new(); + qdict_put(target, "children", children_list); + + for (i =3D 0; i < s->num_children; i++) { + QINCREF(s->children[i]->bs->full_open_options); + qlist_append(children_list, s->children[i]->bs->full_open_options); + } +} + static char *quorum_dirname(BlockDriverState *bs, Error **errp) { /* In general, there are multiple BDSs with different dirnames below t= his @@ -1123,6 +1160,7 @@ static BlockDriver bdrv_quorum =3D { .bdrv_file_open =3D quorum_open, .bdrv_close =3D quorum_close, .bdrv_refresh_filename =3D quorum_refresh_filename, + .bdrv_gather_child_options =3D quorum_gather_child_options, .bdrv_dirname =3D quorum_dirname, =20 .bdrv_co_flush_to_disk =3D quorum_co_flush, diff --git a/block/vmdk.c b/block/vmdk.c index c1dbcfe133..dffab90a8b 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2327,6 +2327,18 @@ static int vmdk_get_info(BlockDriverState *bs, Block= DriverInfo *bdi) return 0; } =20 +static void vmdk_gather_child_options(BlockDriverState *bs, QDict *target) +{ + /* No children but file and backing can be explicitly specified (TODO)= */ + QINCREF(bs->file->bs->full_open_options); + qdict_put(target, "file", bs->file->bs->full_open_options); + + if (bs->backing && bs->backing_overridden) { + QINCREF(bs->backing->bs->full_open_options); + qdict_put(target, "backing", bs->backing->bs->full_open_options); + } +} + static QemuOptsList vmdk_create_opts =3D { .name =3D "vmdk-create-opts", .head =3D QTAILQ_HEAD_INITIALIZER(vmdk_create_opts.head), @@ -2397,6 +2409,7 @@ static BlockDriver bdrv_vmdk =3D { .bdrv_get_specific_info =3D vmdk_get_specific_info, .bdrv_refresh_limits =3D vmdk_refresh_limits, .bdrv_get_info =3D vmdk_get_info, + .bdrv_gather_child_options =3D vmdk_gather_child_options, =20 .supports_backing =3D true, .create_opts =3D &vmdk_create_opts, --=20 2.13.6 From nobody Sun Apr 28 10:05:15 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1511209888369766.9716677417616; Mon, 20 Nov 2017 12:31:28 -0800 (PST) Received: from localhost ([::1]:59607 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsij-0000tk-Jl for importer@patchew.org; Mon, 20 Nov 2017 15:31:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35577) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsPy-0000a3-QS for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:11:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGsPw-0007kS-Lh for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:11:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44348) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGsPr-0007iA-TE; Mon, 20 Nov 2017 15:11:40 -0500 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 28A5E80082; Mon, 20 Nov 2017 20:11:39 +0000 (UTC) Received: from localhost (ovpn-204-75.brq.redhat.com [10.40.204.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1ABA560BEC; Mon, 20 Nov 2017 20:11:37 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 20 Nov 2017 21:09:59 +0100 Message-Id: <20171120201004.14999-21-mreitz@redhat.com> In-Reply-To: <20171120201004.14999-1-mreitz@redhat.com> References: <20171120201004.14999-1-mreitz@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.28]); Mon, 20 Nov 2017 20:11:39 +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 v7 for-2.12 20/25] block: Generically refresh runtime options X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , John Snow , qemu-devel@nongnu.org, Max Reitz 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" Instead of having every block driver which implements bdrv_refresh_filename() copy all of the significant runtime options over to bs->full_open_options, implement this process generically in bdrv_refresh_filename(). This patch only adds this new generic implementation, it does not remove the old functionality. This is done in a follow-up patch. With this patch, some superfluous information (that should never have been there) may be removed from some JSON filenames, as can be seen in the change to iotest 110's reference output. In case of 191, backing nodes that have not been overridden are now removed from the filename. Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia --- block.c | 116 +++++++++++++++++++++++++++++++++++++++++= +++- tests/qemu-iotests/110.out | 2 +- tests/qemu-iotests/191.out | 24 +++++----- 3 files changed, 128 insertions(+), 14 deletions(-) diff --git a/block.c b/block.c index 2e59e77f9d..64ef30bbac 100644 --- a/block.c +++ b/block.c @@ -4944,6 +4944,92 @@ out: return to_replace_bs; } =20 +/** + * Iterates through the list of runtime option keys that are said to be + * "significant" for a BDS. An option is called "significant" if it change= s a + * BDS's data. For example, the null block driver's "size" and "read-zeroe= s" + * options are significant, but its "latency-ns" option is not. + * + * If a key returned by this function ends with a dot, all options startin= g with + * that prefix are significant. + */ +static const char *const *significant_options(BlockDriverState *bs, + const char *const *curopt) +{ + static const char *const global_options[] =3D { + "driver", "filename", "base-directory", NULL + }; + + if (!curopt) { + return &global_options[0]; + } + + curopt++; + if (curopt =3D=3D &global_options[ARRAY_SIZE(global_options) - 1] && b= s->drv) { + curopt =3D bs->drv->sgfnt_runtime_opts; + } + + return (curopt && *curopt) ? curopt : NULL; +} + +/** + * Copies all significant runtime options from bs->options to the given QD= ict. + * The set of significant option keys is determined by invoking + * significant_options(). + * + * Returns true iff any significant option was present in bs->options (and= thus + * copied to the target QDict) with the exception of "filename" and "drive= r". + * The caller is expected to use this value to decide whether the existenc= e of + * significant options prevents the generation of a plain filename. + */ +static bool append_significant_runtime_options(QDict *d, BlockDriverState = *bs) +{ + bool found_any =3D false; + const char *const *option_name =3D NULL; + + if (!bs->drv) { + return false; + } + + while ((option_name =3D significant_options(bs, option_name))) { + bool option_given =3D false; + + assert(strlen(*option_name) > 0); + if ((*option_name)[strlen(*option_name) - 1] !=3D '.') { + QObject *entry =3D qdict_get(bs->options, *option_name); + if (!entry) { + continue; + } + + qobject_incref(entry); + qdict_put_obj(d, *option_name, entry); + option_given =3D true; + } else { + const QDictEntry *entry; + for (entry =3D qdict_first(bs->options); entry; + entry =3D qdict_next(bs->options, entry)) + { + if (strstart(qdict_entry_key(entry), *option_name, NULL)) { + qobject_incref(qdict_entry_value(entry)); + qdict_put_obj(d, qdict_entry_key(entry), + qdict_entry_value(entry)); + option_given =3D true; + } + } + } + + /* While "driver" and "filename" need to be included in a JSON fil= ename, + * their existence does not prohibit generation of a plain filenam= e. */ + if (!found_any && option_given && + strcmp(*option_name, "driver") && strcmp(*option_name, "filena= me")) + { + found_any =3D true; + } + } + + return found_any; +} + static bool append_open_options(QDict *d, BlockDriverState *bs) { const QDictEntry *entry; @@ -5098,9 +5184,37 @@ void bdrv_refresh_filename(BlockDriverState *bs) bs->full_open_options =3D opts; } =20 + /* Gather the options QDict */ + opts =3D qdict_new(); + append_significant_runtime_options(opts, bs); + + if (drv->bdrv_gather_child_options) { + /* Some block drivers may not want to present all of their childre= n's + * options, or name them differently from BdrvChild.name */ + drv->bdrv_gather_child_options(bs, opts); + } else { + QLIST_FOREACH(child, &bs->children, next) { + if (child->role =3D=3D &child_backing && !bs->backing_overridd= en) { + /* We can skip the backing BDS if it has not been overridd= en */ + continue; + } + + QINCREF(child->bs->full_open_options); + qdict_put(opts, child->name, child->bs->full_open_options); + } + + if (bs->backing_overridden && !bs->backing) { + /* Force no backing file */ + qdict_put(opts, "backing", qstring_new()); + } + } + + QDECREF(bs->full_open_options); + bs->full_open_options =3D opts; + if (bs->exact_filename[0]) { pstrcpy(bs->filename, sizeof(bs->filename), bs->exact_filename); - } else if (bs->full_open_options) { + } else { QString *json =3D qobject_to_json(QOBJECT(bs->full_open_options)); snprintf(bs->filename, sizeof(bs->filename), "json:%s", qstring_get_str(json)); diff --git a/tests/qemu-iotests/110.out b/tests/qemu-iotests/110.out index 1d0b2475cc..46e6a60510 100644 --- a/tests/qemu-iotests/110.out +++ b/tests/qemu-iotests/110.out @@ -22,7 +22,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108= 864 backing_file=3Dt.IMGFMT.b =20 =3D=3D=3D Nodes without a common directory =3D=3D=3D =20 -image: json:{"driver": "IMGFMT", "file": {"children": [{"driver": "file", = "filename": "TEST_DIR/t.IMGFMT"}, {"driver": "file", "filename": "TEST_DIR/= t.IMGFMT.copy"}], "driver": "quorum", "blkverify": false, "rewrite-corrupte= d": false, "vote-threshold": 1}} +image: json:{"driver": "IMGFMT", "file": {"children": [{"driver": "file", = "filename": "TEST_DIR/t.IMGFMT"}, {"driver": "file", "filename": "TEST_DIR/= t.IMGFMT.copy"}], "driver": "quorum", "vote-threshold": 1}} file format: IMGFMT virtual size: 64M (67108864 bytes) backing file: t.IMGFMT.base (cannot determine actual path) diff --git a/tests/qemu-iotests/191.out b/tests/qemu-iotests/191.out index c1ce99985e..7e42b45ddb 100644 --- a/tests/qemu-iotests/191.out +++ b/tests/qemu-iotests/191.out @@ -61,7 +61,7 @@ wrote 65536/65536 bytes at offset 1048576 }, "backing-filename-format": "qcow2", "virtual-size": 67108864, - "filename": "json:{"backing": {"backing": {"driver": "qcow= 2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.base"}}, "driv= er": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.mid"= }}, "driver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.q= cow2.ovl2"}}", + "filename": "json:{"backing": {"driver": "qcow2", "file": = {"driver": "file", "filename": "TEST_DIR/t.qcow2.mid"}}, "driver": "qcow2",= "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.ovl2"}}", "cluster-size": 65536, "format": "qcow2", "actual-size": SIZE, @@ -95,7 +95,7 @@ wrote 65536/65536 bytes at offset 1048576 "direct": false, "writeback": true }, - "file": "json:{"backing": {"backing": {"driver": "qcow2", "fil= e": {"driver": "file", "filename": "TEST_DIR/t.qcow2.base"}}, "driver": "qc= ow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.mid"}}, "dri= ver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.ovl= 2"}}", + "file": "json:{"backing": {"driver": "qcow2", "file": {"driver= ": "file", "filename": "TEST_DIR/t.qcow2.mid"}}, "driver": "qcow2", "file":= {"driver": "file", "filename": "TEST_DIR/t.qcow2.ovl2"}}", "encryption_key_missing": false }, { @@ -150,7 +150,7 @@ wrote 65536/65536 bytes at offset 1048576 }, "backing-filename-format": "qcow2", "virtual-size": 67108864, - "filename": "json:{"backing": {"backing": {"driver": "qcow= 2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.base"}}, "driv= er": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.mid"= }}, "driver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.q= cow2"}}", + "filename": "json:{"backing": {"driver": "qcow2", "file": = {"driver": "file", "filename": "TEST_DIR/t.qcow2.mid"}}, "driver": "qcow2",= "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2"}}", "cluster-size": 65536, "format": "qcow2", "actual-size": SIZE, @@ -184,7 +184,7 @@ wrote 65536/65536 bytes at offset 1048576 "direct": false, "writeback": true }, - "file": "json:{"backing": {"backing": {"driver": "qcow2", "fil= e": {"driver": "file", "filename": "TEST_DIR/t.qcow2.base"}}, "driver": "qc= ow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.mid"}}, "dri= ver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2"}}", + "file": "json:{"backing": {"driver": "qcow2", "file": {"driver= ": "file", "filename": "TEST_DIR/t.qcow2.mid"}}, "driver": "qcow2", "file":= {"driver": "file", "filename": "TEST_DIR/t.qcow2"}}", "encryption_key_missing": false }, { @@ -464,7 +464,7 @@ wrote 65536/65536 bytes at offset 1048576 }, "backing-filename-format": "qcow2", "virtual-size": 67108864, - "filename": "json:{"backing": {"backing": {"driver": "qcow= 2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.base"}}, "driv= er": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.mid"= }}, "driver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.q= cow2.ovl2"}}", + "filename": "json:{"backing": {"driver": "qcow2", "file": = {"driver": "file", "filename": "TEST_DIR/t.qcow2.mid"}}, "driver": "qcow2",= "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.ovl2"}}", "cluster-size": 65536, "format": "qcow2", "actual-size": SIZE, @@ -498,7 +498,7 @@ wrote 65536/65536 bytes at offset 1048576 "direct": false, "writeback": true }, - "file": "json:{"backing": {"backing": {"driver": "qcow2", "fil= e": {"driver": "file", "filename": "TEST_DIR/t.qcow2.base"}}, "driver": "qc= ow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.mid"}}, "dri= ver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.ovl= 2"}}", + "file": "json:{"backing": {"driver": "qcow2", "file": {"driver= ": "file", "filename": "TEST_DIR/t.qcow2.mid"}}, "driver": "qcow2", "file":= {"driver": "file", "filename": "TEST_DIR/t.qcow2.ovl2"}}", "encryption_key_missing": false }, { @@ -554,7 +554,7 @@ wrote 65536/65536 bytes at offset 1048576 }, "backing-filename-format": "qcow2", "virtual-size": 67108864, - "filename": "json:{"backing": {"backing": {"driver": "= qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.base"}}, "= driver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.= mid"}}, "driver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR= /t.qcow2.ovl2"}}", + "filename": "json:{"backing": {"driver": "qcow2", "fil= e": {"driver": "file", "filename": "TEST_DIR/t.qcow2.mid"}}, "driver": "qco= w2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.ovl2"}}", "cluster-size": 65536, "format": "qcow2", "actual-size": SIZE, @@ -573,7 +573,7 @@ wrote 65536/65536 bytes at offset 1048576 }, "backing-filename-format": "qcow2", "virtual-size": 67108864, - "filename": "json:{"backing": {"backing": {"backing": {"dr= iver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.ba= se"}}, "driver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/= t.qcow2.mid"}}, "driver": "qcow2", "file": {"driver": "file", "filename": "= TEST_DIR/t.qcow2.ovl2"}}, "driver": "qcow2", "file": {"driver": "file", "fi= lename": "TEST_DIR/t.qcow2.ovl3"}}", + "filename": "json:{"backing": {"backing": {"driver": "qcow= 2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.mid"}}, "drive= r": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.ovl2"= }}, "driver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.q= cow2.ovl3"}}", "cluster-size": 65536, "format": "qcow2", "actual-size": SIZE, @@ -586,8 +586,8 @@ wrote 65536/65536 bytes at offset 1048576 "corrupt": false } }, - "full-backing-filename": "json:{"backing": {"backing": {"d= river": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.b= ase"}}, "driver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR= /t.qcow2.mid"}}, "driver": "qcow2", "file": {"driver": "file", "filename": = "TEST_DIR/t.qcow2.ovl2"}}", - "backing-filename": "json:{"backing": {"backing": {"driver= ": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.base"}= }, "driver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qc= ow2.mid"}}, "driver": "qcow2", "file": {"driver": "file", "filename": "TEST= _DIR/t.qcow2.ovl2"}}", + "full-backing-filename": "json:{"backing": {"driver": "qco= w2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.mid"}}, "driv= er": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.ovl2= "}}", + "backing-filename": "json:{"backing": {"driver": "qcow2", = "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.mid"}}, "driver": = "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.ovl2"}}", "dirty-flag": false }, "iops_wr": 0, @@ -598,7 +598,7 @@ wrote 65536/65536 bytes at offset 1048576 "iops": 0, "bps_wr": 0, "write_threshold": 0, - "backing_file": "json:{"backing": {"backing": {"driver": "qcow= 2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.base"}}, "driv= er": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.mid"= }}, "driver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.q= cow2.ovl2"}}", + "backing_file": "json:{"backing": {"driver": "qcow2", "file": = {"driver": "file", "filename": "TEST_DIR/t.qcow2.mid"}}, "driver": "qcow2",= "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.ovl2"}}", "encrypted": false, "bps": 0, "bps_rd": 0, @@ -607,7 +607,7 @@ wrote 65536/65536 bytes at offset 1048576 "direct": false, "writeback": true }, - "file": "json:{"backing": {"backing": {"backing": {"driver": "= qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.base"}}, "= driver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.= mid"}}, "driver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR= /t.qcow2.ovl2"}}, "driver": "qcow2", "file": {"driver": "file", "filename":= "TEST_DIR/t.qcow2.ovl3"}}", + "file": "json:{"backing": {"backing": {"driver": "qcow2", "fil= e": {"driver": "file", "filename": "TEST_DIR/t.qcow2.mid"}}, "driver": "qco= w2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.ovl2"}}, "dri= ver": "qcow2", "file": {"driver": "file", "filename": "TEST_DIR/t.qcow2.ovl= 3"}}", "encryption_key_missing": false }, { --=20 2.13.6 From nobody Sun Apr 28 10:05:15 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 151120968327256.59823855317086; Mon, 20 Nov 2017 12:28:03 -0800 (PST) Received: from localhost ([::1]:59585 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsfY-00062G-AO for importer@patchew.org; Mon, 20 Nov 2017 15:27:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35649) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsQ5-0000pi-NG for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:11:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGsQ3-0007n2-Ck for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:11:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43720) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGsPw-0007kJ-U5; Mon, 20 Nov 2017 15:11:45 -0500 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 2D2AD49015; Mon, 20 Nov 2017 20:11:44 +0000 (UTC) Received: from localhost (ovpn-204-75.brq.redhat.com [10.40.204.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 45760620A2; Mon, 20 Nov 2017 20:11:41 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 20 Nov 2017 21:10:00 +0100 Message-Id: <20171120201004.14999-22-mreitz@redhat.com> In-Reply-To: <20171120201004.14999-1-mreitz@redhat.com> References: <20171120201004.14999-1-mreitz@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]); Mon, 20 Nov 2017 20:11:44 +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 v7 for-2.12 21/25] block: Purify .bdrv_refresh_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: Kevin Wolf , Alberto Garcia , John Snow , qemu-devel@nongnu.org, Max Reitz 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" Currently, BlockDriver.bdrv_refresh_filename() is supposed to both refresh the filename (BDS.exact_filename) and set BDS.full_open_options. Now that we have generic code in the central bdrv_refresh_filename() for creating BDS.full_open_options, we can drop the latter part from all BlockDriver.bdrv_refresh_filename() implementations. This also means that we can drop all of the existing default code for this from the global bdrv_refresh_filename() itself. Furthermore, we now have to call BlockDriver.bdrv_refresh_filename() after having set BDS.full_open_options, because the block driver's implementation should now be allowed to depend on BDS.full_open_options being set correctly. Finally, with this patch we can drop the @options parameter from BlockDriver.bdrv_refresh_filename(); also, add a comment on this function's purpose in block/block_int.h while touching its interface. Signed-off-by: Max Reitz --- include/block/block_int.h | 6 +- block.c | 145 +++++++-----------------------------------= ---- block/blkdebug.c | 52 ++++++----------- block/blkverify.c | 16 +---- block/commit.c | 2 +- block/mirror.c | 2 +- block/nbd.c | 23 +------- block/nfs.c | 36 +----------- block/null.c | 23 +++++--- block/quorum.c | 30 ---------- 10 files changed, 63 insertions(+), 272 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index f81516b615..b67f3af599 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -133,7 +133,11 @@ struct BlockDriver { int (*bdrv_create)(const char *filename, QemuOpts *opts, Error **errp); int (*bdrv_make_empty)(BlockDriverState *bs); =20 - void (*bdrv_refresh_filename)(BlockDriverState *bs, QDict *options); + /* + * Refreshes the bs->exact_filename field. If that is impossible, + * bs->exact_filename has to be left empty. + */ + void (*bdrv_refresh_filename)(BlockDriverState *bs); =20 /* * Gathers the open options for all children into @target. diff --git a/block.c b/block.c index 64ef30bbac..275cae460a 100644 --- a/block.c +++ b/block.c @@ -5030,47 +5030,6 @@ static bool append_significant_runtime_options(QDict= *d, BlockDriverState *bs) return found_any; } =20 -static bool append_open_options(QDict *d, BlockDriverState *bs) -{ - const QDictEntry *entry; - QemuOptDesc *desc; - BdrvChild *child; - bool found_any =3D false; - const char *p; - - for (entry =3D qdict_first(bs->options); entry; - entry =3D qdict_next(bs->options, entry)) - { - /* Exclude options for children */ - QLIST_FOREACH(child, &bs->children, next) { - if (strstart(qdict_entry_key(entry), child->name, &p) - && (!*p || *p =3D=3D '.')) - { - break; - } - } - if (child) { - continue; - } - - /* And exclude all non-driver-specific options */ - for (desc =3D bdrv_runtime_opts.desc; desc->name; desc++) { - if (!strcmp(qdict_entry_key(entry), desc->name)) { - break; - } - } - if (desc->name) { - continue; - } - - qobject_incref(qdict_entry_value(entry)); - qdict_put_obj(d, qdict_entry_key(entry), qdict_entry_value(entry)); - found_any =3D true; - } - - return found_any; -} - /* Updates the following BDS fields: * - exact_filename: A filename which may be used for opening a block dev= ice * which (mostly) equals the given BDS (even without any @@ -5088,6 +5047,8 @@ void bdrv_refresh_filename(BlockDriverState *bs) BlockDriver *drv =3D bs->drv; BdrvChild *child; QDict *opts; + bool generate_json_filename; /* Whether our default implementation sho= uld + fill exact_filename (false) or not (tr= ue) */ =20 if (!drv) { return; @@ -5103,90 +5064,10 @@ void bdrv_refresh_filename(BlockDriverState *bs) } } =20 - if (drv->bdrv_refresh_filename) { - /* Obsolete information is of no use here, so drop the old file na= me - * information before refreshing it */ - bs->exact_filename[0] =3D '\0'; - if (bs->full_open_options) { - QDECREF(bs->full_open_options); - bs->full_open_options =3D NULL; - } - - opts =3D qdict_new(); - append_open_options(opts, bs); - drv->bdrv_refresh_filename(bs, opts); - QDECREF(opts); - } else if (bs->file) { - /* Try to reconstruct valid information from the underlying file */ - bool has_open_options; - - bs->exact_filename[0] =3D '\0'; - if (bs->full_open_options) { - QDECREF(bs->full_open_options); - bs->full_open_options =3D NULL; - } - - opts =3D qdict_new(); - has_open_options =3D append_open_options(opts, bs); - has_open_options |=3D bs->backing_overridden; - - /* If no specific options have been given for this BDS, the filena= me of - * the underlying file should suffice for this one as well */ - if (bs->file->bs->exact_filename[0] && !has_open_options) { - strcpy(bs->exact_filename, bs->file->bs->exact_filename); - } - /* Reconstructing the full options QDict is simple for most format= block - * drivers, as long as the full options are known for the underlyi= ng - * file BDS. The full options QDict of that file BDS should somehow - * contain a representation of the filename, therefore the followi= ng - * suffices without querying the (exact_)filename of this BDS. */ - if (bs->file->bs->full_open_options && - (!bs->backing || bs->backing->bs->full_open_options)) - { - qdict_put_str(opts, "driver", drv->format_name); - QINCREF(bs->file->bs->full_open_options); - qdict_put(opts, "file", bs->file->bs->full_open_options); - - if (bs->backing) { - QINCREF(bs->backing->bs->full_open_options); - qdict_put(opts, "backing", bs->backing->bs->full_open_opti= ons); - } else if (bs->backing_overridden && !bs->backing) { - qdict_put(opts, "backing", qstring_new()); - } - - bs->full_open_options =3D opts; - } else { - QDECREF(opts); - } - } else if (!bs->full_open_options && qdict_size(bs->options)) { - /* There is no underlying file BDS (at least referenced by BDS.fil= e), - * so the full options QDict should be equal to the options given - * specifically for this block device when it was opened (plus the - * driver specification). - * Because those options don't change, there is no need to update - * full_open_options when it's already set. */ - - opts =3D qdict_new(); - append_open_options(opts, bs); - qdict_put_str(opts, "driver", drv->format_name); - - if (bs->exact_filename[0]) { - /* This may not work for all block protocol drivers (some may - * require this filename to be parsed), but we have to find so= me - * default solution here, so just include it. If some block dr= iver - * does not support pure options without any filename at all or - * needs some special format of the options QDict, it needs to - * implement the driver-specific bdrv_refresh_filename() funct= ion. - */ - qdict_put_str(opts, "filename", bs->exact_filename); - } - - bs->full_open_options =3D opts; - } - /* Gather the options QDict */ opts =3D qdict_new(); - append_significant_runtime_options(opts, bs); + generate_json_filename =3D append_significant_runtime_options(opts, bs= ); + generate_json_filename |=3D bs->backing_overridden; =20 if (drv->bdrv_gather_child_options) { /* Some block drivers may not want to present all of their childre= n's @@ -5212,6 +5093,24 @@ void bdrv_refresh_filename(BlockDriverState *bs) QDECREF(bs->full_open_options); bs->full_open_options =3D opts; =20 + if (drv->bdrv_refresh_filename) { + /* Obsolete information is of no use here, so drop the old file na= me + * information before refreshing it */ + bs->exact_filename[0] =3D '\0'; + + drv->bdrv_refresh_filename(bs); + } else if (bs->file) { + /* Try to reconstruct valid information from the underlying file */ + + bs->exact_filename[0] =3D '\0'; + + /* If no specific options have been given for this BDS, the filena= me of + * the underlying file should suffice for this one as well */ + if (bs->file->bs->exact_filename[0] && !generate_json_filename) { + strcpy(bs->exact_filename, bs->file->bs->exact_filename); + } + } + if (bs->exact_filename[0]) { pstrcpy(bs->filename, sizeof(bs->filename), bs->exact_filename); } else { diff --git a/block/blkdebug.c b/block/blkdebug.c index f93139da58..5196ff542f 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -808,52 +808,34 @@ static int64_t blkdebug_getlength(BlockDriverState *b= s) return bdrv_getlength(bs->file->bs); } =20 -static void blkdebug_refresh_filename(BlockDriverState *bs, QDict *options) +static void blkdebug_refresh_filename(BlockDriverState *bs) { BDRVBlkdebugState *s =3D bs->opaque; - QDict *opts; const QDictEntry *e; - bool force_json =3D false; - - for (e =3D qdict_first(options); e; e =3D qdict_next(options, e)) { - if (strcmp(qdict_entry_key(e), "config") && - strcmp(qdict_entry_key(e), "x-image")) - { - force_json =3D true; - break; - } - } + int ret; =20 - if (force_json && !bs->file->bs->full_open_options) { - /* The config file cannot be recreated, so creating a plain filena= me - * is impossible */ + if (!bs->file->bs->exact_filename[0]) { return; } =20 - if (!force_json && bs->file->bs->exact_filename[0]) { - int ret =3D snprintf(bs->exact_filename, sizeof(bs->exact_filename= ), - "blkdebug:%s:%s", s->config_file ?: "", - bs->file->bs->exact_filename); - if (ret >=3D sizeof(bs->exact_filename)) { - /* An overflow makes the filename unusable, so do not report a= ny */ - bs->exact_filename[0] =3D 0; + for (e =3D qdict_first(bs->full_open_options); e; + e =3D qdict_next(bs->full_open_options, e)) + { + if (strcmp(qdict_entry_key(e), "config") && + strcmp(qdict_entry_key(e), "image") && + strcmp(qdict_entry_key(e), "driver")) + { + return; } } =20 - opts =3D qdict_new(); - qdict_put_str(opts, "driver", "blkdebug"); - - QINCREF(bs->file->bs->full_open_options); - qdict_put(opts, "image", bs->file->bs->full_open_options); - - for (e =3D qdict_first(options); e; e =3D qdict_next(options, e)) { - if (strcmp(qdict_entry_key(e), "x-image")) { - qobject_incref(qdict_entry_value(e)); - qdict_put_obj(opts, qdict_entry_key(e), qdict_entry_value(e)); - } + ret =3D snprintf(bs->exact_filename, sizeof(bs->exact_filename), + "blkdebug:%s:%s", + s->config_file ?: "", bs->file->bs->exact_filename); + if (ret >=3D sizeof(bs->exact_filename)) { + /* An overflow makes the filename unusable, so do not report any */ + bs->exact_filename[0] =3D 0; } - - bs->full_open_options =3D opts; } =20 static void blkdebug_refresh_limits(BlockDriverState *bs, Error **errp) diff --git a/block/blkverify.c b/block/blkverify.c index d5233eeaf9..7da2e08a06 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -277,24 +277,10 @@ static bool blkverify_recurse_is_first_non_filter(Blo= ckDriverState *bs, return bdrv_recurse_is_first_non_filter(s->test_file->bs, candidate); } =20 -static void blkverify_refresh_filename(BlockDriverState *bs, QDict *option= s) +static void blkverify_refresh_filename(BlockDriverState *bs) { BDRVBlkverifyState *s =3D bs->opaque; =20 - if (bs->file->bs->full_open_options - && s->test_file->bs->full_open_options) - { - QDict *opts =3D qdict_new(); - qdict_put_str(opts, "driver", "blkverify"); - - QINCREF(bs->file->bs->full_open_options); - qdict_put(opts, "raw", bs->file->bs->full_open_options); - QINCREF(s->test_file->bs->full_open_options); - qdict_put(opts, "test", s->test_file->bs->full_open_options); - - bs->full_open_options =3D opts; - } - if (bs->file->bs->exact_filename[0] && s->test_file->bs->exact_filename[0]) { diff --git a/block/commit.c b/block/commit.c index cb529cc2aa..c0d1d749e5 100644 --- a/block/commit.c +++ b/block/commit.c @@ -239,7 +239,7 @@ static int coroutine_fn bdrv_commit_top_preadv(BlockDri= verState *bs, return bdrv_co_preadv(bs->backing, offset, bytes, qiov, flags); } =20 -static void bdrv_commit_top_refresh_filename(BlockDriverState *bs, QDict *= opts) +static void bdrv_commit_top_refresh_filename(BlockDriverState *bs) { pstrcpy(bs->exact_filename, sizeof(bs->exact_filename), bs->backing->bs->filename); diff --git a/block/mirror.c b/block/mirror.c index d6e487fb2e..718c492ded 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1058,7 +1058,7 @@ static int coroutine_fn bdrv_mirror_top_pdiscard(Bloc= kDriverState *bs, return bdrv_co_pdiscard(bs->backing->bs, offset, bytes); } =20 -static void bdrv_mirror_top_refresh_filename(BlockDriverState *bs, QDict *= opts) +static void bdrv_mirror_top_refresh_filename(BlockDriverState *bs) { if (bs->backing =3D=3D NULL) { /* we can be here after failed bdrv_attach_child in diff --git a/block/nbd.c b/block/nbd.c index 0a36394b73..9ce9fad7ea 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -514,12 +514,9 @@ static void nbd_attach_aio_context(BlockDriverState *b= s, nbd_client_attach_aio_context(bs, new_context); } =20 -static void nbd_refresh_filename(BlockDriverState *bs, QDict *options) +static void nbd_refresh_filename(BlockDriverState *bs) { BDRVNBDState *s =3D bs->opaque; - QDict *opts =3D qdict_new(); - QObject *saddr_qdict; - Visitor *ov; const char *host =3D NULL, *port =3D NULL, *path =3D NULL; =20 if (s->saddr->type =3D=3D SOCKET_ADDRESS_TYPE_INET) { @@ -532,8 +529,6 @@ static void nbd_refresh_filename(BlockDriverState *bs, = QDict *options) path =3D s->saddr->u.q_unix.path; } /* else can't represent as pseudo-filename */ =20 - qdict_put_str(opts, "driver", "nbd"); - if (path && s->export) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nbd+unix:///%s?socket=3D%s", s->export, path); @@ -547,22 +542,6 @@ static void nbd_refresh_filename(BlockDriverState *bs,= QDict *options) snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nbd://%s:%s", host, port); } - - ov =3D qobject_output_visitor_new(&saddr_qdict); - visit_type_SocketAddress(ov, NULL, &s->saddr, &error_abort); - visit_complete(ov, &saddr_qdict); - visit_free(ov); - qdict_put_obj(opts, "server", saddr_qdict); - - if (s->export) { - qdict_put_str(opts, "export", s->export); - } - if (s->tlscredsid) { - qdict_put_str(opts, "tls-creds", s->tlscredsid); - } - - qdict_flatten(opts); - bs->full_open_options =3D opts; } =20 static char *nbd_dirname(BlockDriverState *bs, Error **errp) diff --git a/block/nfs.c b/block/nfs.c index 445a8d9880..250e01167d 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -819,14 +819,9 @@ static int nfs_reopen_prepare(BDRVReopenState *state, return 0; } =20 -static void nfs_refresh_filename(BlockDriverState *bs, QDict *options) +static void nfs_refresh_filename(BlockDriverState *bs) { NFSClient *client =3D bs->opaque; - QDict *opts =3D qdict_new(); - QObject *server_qdict; - Visitor *ov; - - qdict_put_str(opts, "driver", "nfs"); =20 if (client->uid && !client->gid) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), @@ -844,35 +839,6 @@ static void nfs_refresh_filename(BlockDriverState *bs,= QDict *options) snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nfs://%s%s", client->server->host, client->path); } - - ov =3D qobject_output_visitor_new(&server_qdict); - visit_type_NFSServer(ov, NULL, &client->server, &error_abort); - visit_complete(ov, &server_qdict); - qdict_put_obj(opts, "server", server_qdict); - qdict_put_str(opts, "path", client->path); - - if (client->uid) { - qdict_put_int(opts, "user", client->uid); - } - if (client->gid) { - qdict_put_int(opts, "group", client->gid); - } - if (client->tcp_syncnt) { - qdict_put_int(opts, "tcp-syn-cnt", client->tcp_syncnt); - } - if (client->readahead) { - qdict_put_int(opts, "readahead-size", client->readahead); - } - if (client->pagecache) { - qdict_put_int(opts, "page-cache-size", client->pagecache); - } - if (client->debug) { - qdict_put_int(opts, "debug", client->debug); - } - - visit_free(ov); - qdict_flatten(opts); - bs->full_open_options =3D opts; } =20 static char *nfs_dirname(BlockDriverState *bs, Error **errp) diff --git a/block/null.c b/block/null.c index 59673d2449..65f5d681c0 100644 --- a/block/null.c +++ b/block/null.c @@ -241,18 +241,23 @@ static int64_t coroutine_fn null_co_get_block_status(= BlockDriverState *bs, } } =20 -static void null_refresh_filename(BlockDriverState *bs, QDict *opts) +static void null_refresh_filename(BlockDriverState *bs) { - QINCREF(opts); - qdict_del(opts, "filename"); - - if (!qdict_size(opts)) { - snprintf(bs->exact_filename, sizeof(bs->exact_filename), "%s://", - bs->drv->format_name); + const QDictEntry *e; + + for (e =3D qdict_first(bs->full_open_options); e; + e =3D qdict_next(bs->full_open_options, e)) + { + /* These options can be ignored */ + if (strcmp(qdict_entry_key(e), "filename") && + strcmp(qdict_entry_key(e), "driver")) + { + return; + } } =20 - qdict_put_str(opts, "driver", bs->drv->format_name); - bs->full_open_options =3D opts; + snprintf(bs->exact_filename, sizeof(bs->exact_filename), "%s://", + bs->drv->format_name); } =20 static const char *const null_sgfnt_runtime_opts[] =3D { diff --git a/block/quorum.c b/block/quorum.c index 9d680addc6..7e8cccd60b 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -1066,35 +1066,6 @@ static void quorum_del_child(BlockDriverState *bs, B= drvChild *child, bdrv_drained_end(bs); } =20 -static void quorum_refresh_filename(BlockDriverState *bs, QDict *options) -{ - BDRVQuorumState *s =3D bs->opaque; - QDict *opts; - QList *children; - int i; - - for (i =3D 0; i < s->num_children; i++) { - if (!s->children[i]->bs->full_open_options) { - return; - } - } - - children =3D qlist_new(); - for (i =3D 0; i < s->num_children; i++) { - QINCREF(s->children[i]->bs->full_open_options); - qlist_append(children, s->children[i]->bs->full_open_options); - } - - opts =3D qdict_new(); - qdict_put_str(opts, "driver", "quorum"); - qdict_put_int(opts, QUORUM_OPT_VOTE_THRESHOLD, s->threshold); - qdict_put_bool(opts, QUORUM_OPT_BLKVERIFY, s->is_blkverify); - qdict_put_bool(opts, QUORUM_OPT_REWRITE, s->rewrite_corrupted); - qdict_put(opts, "children", children); - - bs->full_open_options =3D opts; -} - static void quorum_gather_child_options(BlockDriverState *bs, QDict *targe= t) { BDRVQuorumState *s =3D bs->opaque; @@ -1159,7 +1130,6 @@ static BlockDriver bdrv_quorum =3D { =20 .bdrv_file_open =3D quorum_open, .bdrv_close =3D quorum_close, - .bdrv_refresh_filename =3D quorum_refresh_filename, .bdrv_gather_child_options =3D quorum_gather_child_options, .bdrv_dirname =3D quorum_dirname, =20 --=20 2.13.6 From nobody Sun Apr 28 10:05:15 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 1511209756061448.1673929990461; Mon, 20 Nov 2017 12:29:16 -0800 (PST) Received: from localhost ([::1]:59597 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsgo-0007Tl-CR for importer@patchew.org; Mon, 20 Nov 2017 15:29:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35641) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsQ5-0000pA-AO for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:11:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGsQ4-0007nO-Cd for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:11:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45222) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGsQ2-0007mC-1i; Mon, 20 Nov 2017 15:11:50 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4B492C058EDE; Mon, 20 Nov 2017 20:11:49 +0000 (UTC) Received: from localhost (ovpn-204-75.brq.redhat.com [10.40.204.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C7A3860634; Mon, 20 Nov 2017 20:11:46 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 20 Nov 2017 21:10:01 +0100 Message-Id: <20171120201004.14999-23-mreitz@redhat.com> In-Reply-To: <20171120201004.14999-1-mreitz@redhat.com> References: <20171120201004.14999-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 20 Nov 2017 20:11:49 +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 v7 for-2.12 22/25] block: Do not copy exact_filename from format file X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , John Snow , qemu-devel@nongnu.org, Max Reitz 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" If the a format BDS's file BDS is in turn a format BDS, we cannot simply use the same filename, because when opening a BDS tree based on a filename alone, qemu will create only one format node on top of one protocol node (disregarding a potential backing file). Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia --- block.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/block.c b/block.c index 275cae460a..526ce43e9b 100644 --- a/block.c +++ b/block.c @@ -5104,9 +5104,20 @@ void bdrv_refresh_filename(BlockDriverState *bs) =20 bs->exact_filename[0] =3D '\0'; =20 - /* If no specific options have been given for this BDS, the filena= me of - * the underlying file should suffice for this one as well */ - if (bs->file->bs->exact_filename[0] && !generate_json_filename) { + /* We can use the underlying file's filename if: + * - it has a filename, + * - the file is a protocol BDS, and + * - opening that file (as this BDS's format) will automatically c= reate + * the BDS tree we have right now, that is: + * - the user did not significantly change this BDS's behavior w= ith + * some explicit options + * - no non-file child of this BDS has been overridden by the us= er + * Both of these conditions are represented by generate_json_fil= ename. + */ + if (bs->file->bs->exact_filename[0] && + bs->file->bs->drv->bdrv_file_open && + !generate_json_filename) + { strcpy(bs->exact_filename, bs->file->bs->exact_filename); } } --=20 2.13.6 From nobody Sun Apr 28 10:05:15 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 1511209162607271.4955192341363; Mon, 20 Nov 2017 12:19:22 -0800 (PST) Received: from localhost ([::1]:59538 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsXE-0007Fi-Ng for importer@patchew.org; Mon, 20 Nov 2017 15:19:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35693) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsQE-00016p-AJ for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:12:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGsQ9-0007pp-Qq for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:12:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42200) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGsQ6-0007oe-Sb; Mon, 20 Nov 2017 15:11:55 -0500 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 1D7B13C92; Mon, 20 Nov 2017 20:11:54 +0000 (UTC) Received: from localhost (ovpn-204-75.brq.redhat.com [10.40.204.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9743160BE0; Mon, 20 Nov 2017 20:11:51 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 20 Nov 2017 21:10:02 +0100 Message-Id: <20171120201004.14999-24-mreitz@redhat.com> In-Reply-To: <20171120201004.14999-1-mreitz@redhat.com> References: <20171120201004.14999-1-mreitz@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.29]); Mon, 20 Nov 2017 20:11: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] [PATCH v7 for-2.12 23/25] block: Fix FIXME from "Add BDS.backing_overridden" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , John Snow , qemu-devel@nongnu.org, Max Reitz 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" Said commit introduced a FIXME stating that bdrv_open_backing_file() should set bs->backing_overridden to true not only if the file.filename option was set, but if the "options" QDict contained any option that is significant for any node in the BDS tree emerging from the backing BDS. This behavior is implemented by this patch. Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia --- block.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-= ---- 1 file changed, 75 insertions(+), 6 deletions(-) diff --git a/block.c b/block.c index 526ce43e9b..40007544e5 100644 --- a/block.c +++ b/block.c @@ -73,6 +73,9 @@ static BlockDriverState *bdrv_open_inherit(const char *fi= lename, const BdrvChildRole *child_role, Error **errp); =20 +static bool has_significant_runtime_options(BlockDriverState *bs, + const QDict *d); + /* If non-zero, use only whitelisted block drivers */ static int use_bdrv_whitelist; =20 @@ -2214,6 +2217,42 @@ out: bdrv_refresh_limits(bs, NULL); } =20 +/** + * Checks whether @options contains any significant option for any of the = nodes + * in the BDS tree emerging from @bs. + */ +static bool is_significant_option_tree(BlockDriverState *bs, QDict *option= s) +{ + BdrvChild *child; + + if (!qdict_size(options)) { + /* No need to recurse */ + return false; + } + + if (has_significant_runtime_options(bs, options)) { + return true; + } + + QLIST_FOREACH(child, &bs->children, next) { + QDict *child_options; + char *option_prefix; + + option_prefix =3D g_strdup_printf("%s.", child->name); + qdict_extract_subqdict(options, &child_options, option_prefix); + g_free(option_prefix); + + if (is_significant_option_tree(child->bs, child_options)) { + QDECREF(child_options); + return true; + } + + QDECREF(child_options); + } + + return false; +} + /* * Opens the backing file for a BlockDriverState if not yet open * @@ -2232,7 +2271,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDic= t *parent_options, const char *reference =3D NULL; int ret =3D 0; BlockDriverState *backing_hd; - QDict *options; + QDict *options, *cloned_options =3D NULL; QDict *tmp_parent_options =3D NULL; Error *local_err =3D NULL; =20 @@ -2262,11 +2301,6 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDi= ct *parent_options, reference =3D qdict_get_try_str(parent_options, bdref_key); if (reference || qdict_haskey(options, "file.filename")) { /* keep backing_filename NULL */ - - /* FIXME: Should also be set to true if @options contains other ru= ntime - * options which control the data that is read from the bac= king - * BDS */ - bs->backing_overridden =3D true; } else if (bs->backing_file[0] =3D=3D '\0' && qdict_size(options) =3D= =3D 0) { QDECREF(options); goto free_exit; @@ -2287,6 +2321,8 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDic= t *parent_options, goto free_exit; } =20 + cloned_options =3D qdict_clone_shallow(options); + if (!reference && bs->backing_format[0] !=3D '\0' && !qdict_haskey(options, "driver"= )) { qdict_put_str(options, "driver", bs->backing_format); @@ -2302,6 +2338,10 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDi= ct *parent_options, } bdrv_set_aio_context(backing_hd, bdrv_get_aio_context(bs)); =20 + if (reference || is_significant_option_tree(backing_hd, cloned_options= )) { + bs->backing_overridden =3D true; + } + /* Hook up the backing file link; drop our reference, bs owns the * backing_hd reference now */ bdrv_set_backing_hd(bs, backing_hd, &local_err); @@ -2317,6 +2357,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDic= t *parent_options, free_exit: g_free(backing_filename); QDECREF(tmp_parent_options); + QDECREF(cloned_options); return ret; } =20 @@ -4973,6 +5014,34 @@ static const char *const *significant_options(BlockD= riverState *bs, } =20 /** + * Returns true if @d contains any options the block driver of @bs conside= rs to + * be significant runtime options. + */ +static bool has_significant_runtime_options(BlockDriverState *bs, + const QDict *d) +{ + const char *const *option_name =3D NULL; + + while ((option_name =3D significant_options(bs, option_name))) { + assert(strlen(*option_name) > 0); + if ((*option_name)[strlen(*option_name) - 1] !=3D '.') { + if (qdict_haskey(d, *option_name)) { + return true; + } + } else { + const QDictEntry *entry; + for (entry =3D qdict_first(d); entry; entry =3D qdict_next(d, = entry)) { + if (strstart(qdict_entry_key(entry), *option_name, NULL)) { + return true; + } + } + } + } + + return false; +} + +/** * Copies all significant runtime options from bs->options to the given QD= ict. * The set of significant option keys is determined by invoking * significant_options(). --=20 2.13.6 From nobody Sun Apr 28 10:05:15 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 1511209354154242.53960189872816; Mon, 20 Nov 2017 12:22:34 -0800 (PST) Received: from localhost ([::1]:59554 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsaB-0001G1-DA for importer@patchew.org; Mon, 20 Nov 2017 15:22:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35734) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsQG-0001FO-B7 for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:12:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGsQF-0007t1-Ct for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:12:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33102) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGsQ9-0007ph-WF; Mon, 20 Nov 2017 15:11:58 -0500 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 2ECA4BAED; Mon, 20 Nov 2017 20:11:57 +0000 (UTC) Received: from localhost (ovpn-204-75.brq.redhat.com [10.40.204.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9EAA160BE0; Mon, 20 Nov 2017 20:11:56 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 20 Nov 2017 21:10:03 +0100 Message-Id: <20171120201004.14999-25-mreitz@redhat.com> In-Reply-To: <20171120201004.14999-1-mreitz@redhat.com> References: <20171120201004.14999-1-mreitz@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.25]); Mon, 20 Nov 2017 20:11:57 +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 v7 for-2.12 24/25] block/curl: Implement bdrv_refresh_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: Kevin Wolf , Alberto Garcia , John Snow , qemu-devel@nongnu.org, Max Reitz 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: Max Reitz Reviewed-by: Alberto Garcia --- block/curl.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/block/curl.c b/block/curl.c index 11318a9a29..fe57223fda 100644 --- a/block/curl.c +++ b/block/curl.c @@ -957,6 +957,20 @@ static int64_t curl_getlength(BlockDriverState *bs) return s->len; } =20 +static void curl_refresh_filename(BlockDriverState *bs) +{ + BDRVCURLState *s =3D bs->opaque; + + if (!s->sslverify || s->cookie || + s->username || s->password || s->proxyusername || s->proxypassword) + { + return; + } + + pstrcpy(bs->exact_filename, sizeof(bs->exact_filename), s->url); +} + + static const char *const curl_sgfnt_runtime_opts[] =3D { CURL_BLOCK_OPT_URL, CURL_BLOCK_OPT_SSLVERIFY, @@ -985,6 +999,7 @@ static BlockDriver bdrv_http =3D { .bdrv_detach_aio_context =3D curl_detach_aio_context, .bdrv_attach_aio_context =3D curl_attach_aio_context, =20 + .bdrv_refresh_filename =3D curl_refresh_filename, .sgfnt_runtime_opts =3D curl_sgfnt_runtime_opts, }; =20 @@ -1003,6 +1018,7 @@ static BlockDriver bdrv_https =3D { .bdrv_detach_aio_context =3D curl_detach_aio_context, .bdrv_attach_aio_context =3D curl_attach_aio_context, =20 + .bdrv_refresh_filename =3D curl_refresh_filename, .sgfnt_runtime_opts =3D curl_sgfnt_runtime_opts, }; =20 @@ -1021,6 +1037,7 @@ static BlockDriver bdrv_ftp =3D { .bdrv_detach_aio_context =3D curl_detach_aio_context, .bdrv_attach_aio_context =3D curl_attach_aio_context, =20 + .bdrv_refresh_filename =3D curl_refresh_filename, .sgfnt_runtime_opts =3D curl_sgfnt_runtime_opts, }; =20 @@ -1039,6 +1056,7 @@ static BlockDriver bdrv_ftps =3D { .bdrv_detach_aio_context =3D curl_detach_aio_context, .bdrv_attach_aio_context =3D curl_attach_aio_context, =20 + .bdrv_refresh_filename =3D curl_refresh_filename, .sgfnt_runtime_opts =3D curl_sgfnt_runtime_opts, }; =20 --=20 2.13.6 From nobody Sun Apr 28 10:05:15 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1511209525846636.833164452064; Mon, 20 Nov 2017 12:25:25 -0800 (PST) Received: from localhost ([::1]:59567 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsct-0003e5-Qf for importer@patchew.org; Mon, 20 Nov 2017 15:25:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35746) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGsQH-0001Gv-Hy for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:12:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGsQG-0007tW-NJ for qemu-devel@nongnu.org; Mon, 20 Nov 2017 15:12:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50222) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGsQE-0007s8-L2; Mon, 20 Nov 2017 15:12:02 -0500 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 DBBCE356CA; Mon, 20 Nov 2017 20:12:01 +0000 (UTC) Received: from localhost (ovpn-204-75.brq.redhat.com [10.40.204.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7ECD0620A2; Mon, 20 Nov 2017 20:11:59 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 20 Nov 2017 21:10:04 +0100 Message-Id: <20171120201004.14999-26-mreitz@redhat.com> In-Reply-To: <20171120201004.14999-1-mreitz@redhat.com> References: <20171120201004.14999-1-mreitz@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]); Mon, 20 Nov 2017 20:12: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] [PATCH v7 for-2.12 25/25] block/null: Generate filename even with latency-ns X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , John Snow , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" While we cannot represent the latency-ns option in a filename, it is not a significant option so not being able to should not stop us from generating a filename nonetheless. Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia --- block/null.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/null.c b/block/null.c index 65f5d681c0..ca0aa3d528 100644 --- a/block/null.c +++ b/block/null.c @@ -250,7 +250,8 @@ static void null_refresh_filename(BlockDriverState *bs) { /* These options can be ignored */ if (strcmp(qdict_entry_key(e), "filename") && - strcmp(qdict_entry_key(e), "driver")) + strcmp(qdict_entry_key(e), "driver") && + strcmp(qdict_entry_key(e), NULL_OPT_LATENCY)) { return; } --=20 2.13.6