From nobody Sun May 5 01:13:32 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517844818567822.3224974105194; Mon, 5 Feb 2018 07:33:38 -0800 (PST) Received: from localhost ([::1]:53809 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiim1-0002kQ-EY for importer@patchew.org; Mon, 05 Feb 2018 10:33:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52690) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiiXf-0007t3-L6 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:18:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiiXe-00057M-N5 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:18:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33718) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eiiXc-000524-5z; Mon, 05 Feb 2018 10:18:44 -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 68466C044CBE; Mon, 5 Feb 2018 15:18:43 +0000 (UTC) Received: from localhost (unknown [10.40.205.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B614D5EDEA; Mon, 5 Feb 2018 15:18:42 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 5 Feb 2018 16:18:10 +0100 Message-Id: <20180205151835.20812-2-mreitz@redhat.com> In-Reply-To: <20180205151835.20812-1-mreitz@redhat.com> References: <20180205151835.20812-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.32]); Mon, 05 Feb 2018 15:18:43 +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 v8 01/26] 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 , 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 c9badc1203..45e35c909f 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.14.3 From nobody Sun May 5 01:13:32 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517847244586710.636676547109; Mon, 5 Feb 2018 08:14:04 -0800 (PST) Received: from localhost ([::1]:57448 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eijP9-00045T-Kp for importer@patchew.org; Mon, 05 Feb 2018 11:14:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52770) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiiXn-00081T-Ne for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:18:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiiXm-0005SC-LO for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:18:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56306) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eiiXi-0005Ew-GK; Mon, 05 Feb 2018 10:18:50 -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 C8E0B61B1F; Mon, 5 Feb 2018 15:18:49 +0000 (UTC) Received: from localhost (unknown [10.40.205.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5C9875EDEA; Mon, 5 Feb 2018 15:18:45 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 5 Feb 2018 16:18:11 +0100 Message-Id: <20180205151835.20812-3-mreitz@redhat.com> In-Reply-To: <20180205151835.20812-1-mreitz@redhat.com> References: <20180205151835.20812-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.25]); Mon, 05 Feb 2018 15:18: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 v8 02/26] 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 , 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 Reviewed-by: Kevin Wolf --- 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 a8da4f2b25..b84aba2d95 100644 --- a/block.c +++ b/block.c @@ -5020,16 +5020,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 bb6c904704..1fa6c9c0e0 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 45e35c909f..5a627ba589 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.14.3 From nobody Sun May 5 01:13:32 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517845739868197.99275656763973; Mon, 5 Feb 2018 07:48:59 -0800 (PST) Received: from localhost ([::1]:55475 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eij0t-00085K-0E for importer@patchew.org; Mon, 05 Feb 2018 10:48:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiiXp-00083h-Gc for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:18:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiiXn-0005Vl-PG for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:18:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38093) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eiiXk-0005Kg-Pv; Mon, 05 Feb 2018 10:18:52 -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 0EF6B776C6; Mon, 5 Feb 2018 15:18:52 +0000 (UTC) Received: from localhost (unknown [10.40.205.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 82A285EDEA; Mon, 5 Feb 2018 15:18:51 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 5 Feb 2018 16:18:12 +0100 Message-Id: <20180205151835.20812-4-mreitz@redhat.com> In-Reply-To: <20180205151835.20812-1-mreitz@redhat.com> References: <20180205151835.20812-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, 05 Feb 2018 15:18:52 +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 v8 03/26] 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 , 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 29cafa4236..b5c124fcbd 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 b84aba2d95..66e37219b9 100644 --- a/block.c +++ b/block.c @@ -2268,6 +2268,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; @@ -2469,6 +2474,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); @@ -2599,6 +2607,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 @@ -5031,6 +5040,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 5a627ba589..aa68531352 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 8e977eef11..bbe264c3c0 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1795,6 +1795,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; AioContext *aio_context; =20 aio_context =3D bdrv_get_aio_context(state->old_bs); @@ -1808,6 +1810,20 @@ static void external_snapshot_commit(BlkActionState = *common) NULL); } =20 + 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); + } + aio_context_release(aio_context); } =20 --=20 2.14.3 From nobody Sun May 5 01:13:32 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517845946338672.1157642428794; Mon, 5 Feb 2018 07:52:26 -0800 (PST) Received: from localhost ([::1]:55716 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eij4A-0002lo-E3 for importer@patchew.org; Mon, 05 Feb 2018 10:52:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52874) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiiXv-0008EE-US for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:19:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiiXu-0005lS-OJ for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:19:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45798) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eiiXq-0005b6-8y; Mon, 05 Feb 2018 10:18:58 -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 985F3776E0; Mon, 5 Feb 2018 15:18:57 +0000 (UTC) Received: from localhost (unknown [10.40.205.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EE2A26090C; Mon, 5 Feb 2018 15:18:53 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 5 Feb 2018 16:18:13 +0100 Message-Id: <20180205151835.20812-5-mreitz@redhat.com> In-Reply-To: <20180205151835.20812-1-mreitz@redhat.com> References: <20180205151835.20812-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.27]); Mon, 05 Feb 2018 15:18: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 v8 04/26] 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 , 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 | 52 +++++++++++++++++++++++-------------------= ---- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/tests/qemu-iotests/191 b/tests/qemu-iotests/191 index dfad6555e4..af93e932bf 100755 --- a/tests/qemu-iotests/191 +++ b/tests/qemu-iotests/191 @@ -66,8 +66,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 190c5f049a..575cd3ea2d 100644 --- a/tests/qemu-iotests/191.out +++ b/tests/qemu-iotests/191.out @@ -184,33 +184,21 @@ wrote 65536/65536 bytes at offset 1048576 "iops_rd": 0, "detect_zeroes": "off", "image": { - "backing-image": { - "virtual-size": 67108864, - "filename": "TEST_DIR/t.IMGFMT.base", - "cluster-size": 65536, - "format": "IMGFMT", - "actual-size": SIZE, - "dirty-flag": false - }, - "backing-filename-format": "IMGFMT", "virtual-size": 67108864, - "filename": "TEST_DIR/t.IMGFMT.mid", + "filename": "TEST_DIR/t.IMGFMT.base", "cluster-size": 65536, "format": "IMGFMT", "actual-size": SIZE, - "full-backing-filename": "TEST_DIR/t.IMGFMT.base", - "backing-filename": "TEST_DIR/t.IMGFMT.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": "IMGFMT", "iops": 0, "bps_wr": 0, "write_threshold": 0, - "backing_file": "TEST_DIR/t.IMGFMT.base", "encrypted": false, "bps": 0, "bps_rd": 0, @@ -219,7 +207,7 @@ wrote 65536/65536 bytes at offset 1048576 "direct": false, "writeback": true }, - "file": "TEST_DIR/t.IMGFMT.mid", + "file": "TEST_DIR/t.IMGFMT.base", "encryption_key_missing": false }, { @@ -227,13 +215,13 @@ wrote 65536/65536 bytes at offset 1048576 "detect_zeroes": "off", "image": { "virtual-size": 393216, - "filename": "TEST_DIR/t.IMGFMT.mid", + "filename": "TEST_DIR/t.IMGFMT.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", @@ -248,28 +236,40 @@ wrote 65536/65536 bytes at offset 1048576 "direct": false, "writeback": true }, - "file": "TEST_DIR/t.IMGFMT.mid", + "file": "TEST_DIR/t.IMGFMT.base", "encryption_key_missing": false }, { "iops_rd": 0, "detect_zeroes": "off", "image": { + "backing-image": { + "virtual-size": 67108864, + "filename": "TEST_DIR/t.IMGFMT.base", + "cluster-size": 65536, + "format": "IMGFMT", + "actual-size": SIZE, + "dirty-flag": false + }, + "backing-filename-format": "IMGFMT", "virtual-size": 67108864, - "filename": "TEST_DIR/t.IMGFMT.base", + "filename": "TEST_DIR/t.IMGFMT.mid", "cluster-size": 65536, "format": "IMGFMT", "actual-size": SIZE, + "full-backing-filename": "TEST_DIR/t.IMGFMT.base", + "backing-filename": "TEST_DIR/t.IMGFMT.base", "dirty-flag": false }, "iops_wr": 0, "ro": false, - "node-name": "base", - "backing_file_depth": 0, + "node-name": "mid", + "backing_file_depth": 1, "drv": "IMGFMT", "iops": 0, "bps_wr": 0, "write_threshold": 0, + "backing_file": "TEST_DIR/t.IMGFMT.base", "encrypted": false, "bps": 0, "bps_rd": 0, @@ -278,7 +278,7 @@ wrote 65536/65536 bytes at offset 1048576 "direct": false, "writeback": true }, - "file": "TEST_DIR/t.IMGFMT.base", + "file": "TEST_DIR/t.IMGFMT.mid", "encryption_key_missing": false }, { @@ -286,7 +286,7 @@ wrote 65536/65536 bytes at offset 1048576 "detect_zeroes": "off", "image": { "virtual-size": 393216, - "filename": "TEST_DIR/t.IMGFMT.base", + "filename": "TEST_DIR/t.IMGFMT.mid", "format": "file", "actual-size": SIZE, "dirty-flag": false @@ -307,7 +307,7 @@ wrote 65536/65536 bytes at offset 1048576 "direct": false, "writeback": true }, - "file": "TEST_DIR/t.IMGFMT.base", + "file": "TEST_DIR/t.IMGFMT.mid", "encryption_key_missing": false } ] --=20 2.14.3 From nobody Sun May 5 01:13:32 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517847478925136.2399530285469; Mon, 5 Feb 2018 08:17:58 -0800 (PST) Received: from localhost ([::1]:57637 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eijSw-0007EO-1B for importer@patchew.org; Mon, 05 Feb 2018 11:17:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52892) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiiY1-0008Iy-2o for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:19:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiiXy-0005v6-T2 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:19:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:2986) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eiiXs-0005en-1i; Mon, 05 Feb 2018 10:19:00 -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 5E65E5F7BB; Mon, 5 Feb 2018 15:18:59 +0000 (UTC) Received: from localhost (unknown [10.40.205.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 04F7B608F0; Mon, 5 Feb 2018 15:18:57 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 5 Feb 2018 16:18:14 +0100 Message-Id: <20180205151835.20812-6-mreitz@redhat.com> In-Reply-To: <20180205151835.20812-1-mreitz@redhat.com> References: <20180205151835.20812-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.39]); Mon, 05 Feb 2018 15:18:59 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v8 05/26] 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 , 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 66e37219b9..249616af68 100644 --- a/block.c +++ b/block.c @@ -5071,6 +5071,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 */ @@ -5082,11 +5083,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) { + 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 dd9846d1ce..6bf76ed0fb 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) @@ -149,7 +149,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) @@ -169,7 +169,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) @@ -189,7 +189,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 830c11880a..777a6b3adc 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) @@ -241,7 +241,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) @@ -261,7 +261,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) @@ -281,7 +281,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 575cd3ea2d..b22471b40a 100644 --- a/tests/qemu-iotests/191.out +++ b/tests/qemu-iotests/191.out @@ -52,7 +52,7 @@ wrote 65536/65536 bytes at offset 1048576 }, "backing-filename-format": "IMGFMT", "virtual-size": 67108864, - "filename": "TEST_DIR/t.IMGFMT.ovl2", + "filename": "json:{"backing": {"backing": {"driver": "IMGF= MT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.base"}}, "dr= iver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.= mid"}}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DI= R/t.IMGFMT.ovl2"}}", "cluster-size": 65536, "format": "IMGFMT", "actual-size": SIZE, @@ -77,7 +77,7 @@ wrote 65536/65536 bytes at offset 1048576 "direct": false, "writeback": true }, - "file": "TEST_DIR/t.IMGFMT.ovl2", + "file": "json:{"backing": {"backing": {"driver": "IMGFMT", "fi= le": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.base"}}, "driver": "= IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.mid"}}, = "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGF= MT.ovl2"}}", "encryption_key_missing": false }, { @@ -123,7 +123,7 @@ wrote 65536/65536 bytes at offset 1048576 }, "backing-filename-format": "IMGFMT", "virtual-size": 67108864, - "filename": "TEST_DIR/t.IMGFMT", + "filename": "json:{"backing": {"backing": {"driver": "IMGF= MT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.base"}}, "dr= iver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.= mid"}}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DI= R/t.IMGFMT"}}", "cluster-size": 65536, "format": "IMGFMT", "actual-size": SIZE, @@ -148,7 +148,7 @@ wrote 65536/65536 bytes at offset 1048576 "direct": false, "writeback": true }, - "file": "TEST_DIR/t.IMGFMT", + "file": "json:{"backing": {"backing": {"driver": "IMGFMT", "fi= le": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.base"}}, "driver": "= IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.mid"}}, = "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGF= MT"}}", "encryption_key_missing": false }, { @@ -392,7 +392,7 @@ wrote 65536/65536 bytes at offset 1048576 }, "backing-filename-format": "IMGFMT", "virtual-size": 67108864, - "filename": "TEST_DIR/t.IMGFMT.ovl2", + "filename": "json:{"backing": {"backing": {"driver": "IMGF= MT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.base"}}, "dr= iver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.= mid"}}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DI= R/t.IMGFMT.ovl2"}}", "cluster-size": 65536, "format": "IMGFMT", "actual-size": SIZE, @@ -417,7 +417,7 @@ wrote 65536/65536 bytes at offset 1048576 "direct": false, "writeback": true }, - "file": "TEST_DIR/t.IMGFMT.ovl2", + "file": "json:{"backing": {"backing": {"driver": "IMGFMT", "fi= le": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.base"}}, "driver": "= IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.mid"}}, = "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGF= MT.ovl2"}}", "encryption_key_missing": false }, { @@ -464,7 +464,7 @@ wrote 65536/65536 bytes at offset 1048576 }, "backing-filename-format": "IMGFMT", "virtual-size": 67108864, - "filename": "TEST_DIR/t.IMGFMT.ovl2", + "filename": "json:{"backing": {"backing": {"driver": "= IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.base"}},= "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMG= FMT.mid"}}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TES= T_DIR/t.IMGFMT.ovl2"}}", "cluster-size": 65536, "format": "IMGFMT", "actual-size": SIZE, @@ -474,12 +474,12 @@ wrote 65536/65536 bytes at offset 1048576 }, "backing-filename-format": "IMGFMT", "virtual-size": 67108864, - "filename": "TEST_DIR/t.IMGFMT.ovl3", + "filename": "json:{"backing": {"backing": {"backing": {"dr= iver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.= base"}}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_D= IR/t.IMGFMT.mid"}}, "driver": "IMGFMT", "file": {"driver": "file", "filenam= e": "TEST_DIR/t.IMGFMT.ovl2"}}, "driver": "IMGFMT", "file": {"driver": "fil= e", "filename": "TEST_DIR/t.IMGFMT.ovl3"}}", "cluster-size": 65536, "format": "IMGFMT", "actual-size": SIZE, - "full-backing-filename": "TEST_DIR/t.IMGFMT.ovl2", - "backing-filename": "TEST_DIR/t.IMGFMT.ovl2", + "full-backing-filename": "json:{"backing": {"backing": {"d= river": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT= .base"}}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_= DIR/t.IMGFMT.mid"}}, "driver": "IMGFMT", "file": {"driver": "file", "filena= me": "TEST_DIR/t.IMGFMT.ovl2"}}", + "backing-filename": "json:{"backing": {"backing": {"driver= ": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.base= "}}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t= .IMGFMT.mid"}}, "driver": "IMGFMT", "file": {"driver": "file", "filename": = "TEST_DIR/t.IMGFMT.ovl2"}}", "dirty-flag": false }, "iops_wr": 0, @@ -490,7 +490,7 @@ wrote 65536/65536 bytes at offset 1048576 "iops": 0, "bps_wr": 0, "write_threshold": 0, - "backing_file": "TEST_DIR/t.IMGFMT.ovl2", + "backing_file": "json:{"backing": {"backing": {"driver": "IMGF= MT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.base"}}, "dr= iver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.= mid"}}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DI= R/t.IMGFMT.ovl2"}}", "encrypted": false, "bps": 0, "bps_rd": 0, @@ -499,7 +499,7 @@ wrote 65536/65536 bytes at offset 1048576 "direct": false, "writeback": true }, - "file": "TEST_DIR/t.IMGFMT.ovl3", + "file": "json:{"backing": {"backing": {"backing": {"driver": "= IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.base"}},= "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMG= FMT.mid"}}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TES= T_DIR/t.IMGFMT.ovl2"}}, "driver": "IMGFMT", "file": {"driver": "file", "fil= ename": "TEST_DIR/t.IMGFMT.ovl3"}}", "encryption_key_missing": false }, { --=20 2.14.3 From nobody Sun May 5 01:13:32 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517845889385161.5880079612948; Mon, 5 Feb 2018 07:51:29 -0800 (PST) Received: from localhost ([::1]:55715 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eij3F-00025W-Ck for importer@patchew.org; Mon, 05 Feb 2018 10:51:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52933) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiiY9-0008Pt-IK for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:19:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiiY8-0006N7-96 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:19:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60031) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eiiY0-0005yr-Nx; Mon, 05 Feb 2018 10:19:08 -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 0FCC361461; Mon, 5 Feb 2018 15:19:08 +0000 (UTC) Received: from localhost (unknown [10.40.205.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3EC852E0C1; Mon, 5 Feb 2018 15:19:01 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 5 Feb 2018 16:18:15 +0100 Message-Id: <20180205151835.20812-7-mreitz@redhat.com> In-Reply-To: <20180205151835.20812-1-mreitz@redhat.com> References: <20180205151835.20812-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.39]); Mon, 05 Feb 2018 15:19:08 +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 v8 06/26] 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 , 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 Reviewed-by: Kevin Wolf --- 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 9b12774ddf..993ae74b7e 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 249616af68..84ab8d4675 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 @@ -4182,8 +4191,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)) { @@ -4192,8 +4201,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 d71cec4f31..0a0f16d0f0 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.14.3 From nobody Sun May 5 01:13:32 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517846088376819.4500559869504; Mon, 5 Feb 2018 07:54:48 -0800 (PST) Received: from localhost ([::1]:55795 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eij6V-0004kJ-D8 for importer@patchew.org; Mon, 05 Feb 2018 10:54:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53001) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiiYN-00007B-Be for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:19:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiiYK-0006hN-KJ for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:19:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:16432) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eiiYC-0006UM-QR; Mon, 05 Feb 2018 10:19:20 -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 1B3897E42C; Mon, 5 Feb 2018 15:19:20 +0000 (UTC) Received: from localhost (unknown [10.40.205.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F1BF26090C; Mon, 5 Feb 2018 15:19:09 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 5 Feb 2018 16:18:16 +0100 Message-Id: <20180205151835.20812-8-mreitz@redhat.com> In-Reply-To: <20180205151835.20812-1-mreitz@redhat.com> References: <20180205151835.20812-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.27]); Mon, 05 Feb 2018 15:19:20 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v8 07/26] 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 , 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 993ae74b7e..46ceb1c8d3 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 84ab8d4675..6269d25093 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) @@ -4647,17 +4666,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 0a0f16d0f0..e61d15bc92 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2017,16 +2017,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.14.3 From nobody Sun May 5 01:13:32 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517846289068985.3784446407328; Mon, 5 Feb 2018 07:58:09 -0800 (PST) Received: from localhost ([::1]:55876 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eij9f-0007RJ-3H for importer@patchew.org; Mon, 05 Feb 2018 10:58:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiiYR-0000Cy-VB for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:19:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiiYQ-0006tu-In for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:19:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44010) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eiiYN-0006n7-74; Mon, 05 Feb 2018 10:19:31 -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 849CA3AD8C; Mon, 5 Feb 2018 15:19:30 +0000 (UTC) Received: from localhost (unknown [10.40.205.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9D90E608F0; Mon, 5 Feb 2018 15:19:22 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 5 Feb 2018 16:18:17 +0100 Message-Id: <20180205151835.20812-9-mreitz@redhat.com> In-Reply-To: <20180205151835.20812-1-mreitz@redhat.com> References: <20180205151835.20812-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.38]); Mon, 05 Feb 2018 15:19: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 v8 08/26] 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 , 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 46ceb1c8d3..fafb8a6a7a 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 6269d25093..483dcf863e 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) @@ -2261,7 +2250,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; @@ -2295,7 +2284,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 @@ -2305,8 +2294,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); @@ -2327,9 +2315,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: "); @@ -4174,7 +4161,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; @@ -4191,21 +4177,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.14.3 From nobody Sun May 5 01:13:32 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517845050406725.2262649560844; Mon, 5 Feb 2018 07:37:30 -0800 (PST) Received: from localhost ([::1]:54035 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiipk-0006Tm-K7 for importer@patchew.org; Mon, 05 Feb 2018 10:37:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53098) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiiYY-0000Lu-QW for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:19:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiiYX-00076I-UH for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:19:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57636) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eiiYT-0006yk-R2; Mon, 05 Feb 2018 10:19:37 -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 23B6D67C55; Mon, 5 Feb 2018 15:19:37 +0000 (UTC) Received: from localhost (unknown [10.40.205.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7B65565617; Mon, 5 Feb 2018 15:19:32 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 5 Feb 2018 16:18:18 +0100 Message-Id: <20180205151835.20812-10-mreitz@redhat.com> In-Reply-To: <20180205151835.20812-1-mreitz@redhat.com> References: <20180205151835.20812-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.25]); Mon, 05 Feb 2018 15:19:37 +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 v8 09/26] 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 , 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 483dcf863e..f404728732 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.14.3 From nobody Sun May 5 01:13:32 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517846514969393.8234997872703; Mon, 5 Feb 2018 08:01:54 -0800 (PST) Received: from localhost ([::1]:56404 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eijDN-0002Mx-VA for importer@patchew.org; Mon, 05 Feb 2018 11:01:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53182) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiiYg-0000Se-0a for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:19:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiiYe-0007K7-Sx for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:19:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35812) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eiiYa-0007AT-Q2; Mon, 05 Feb 2018 10:19:44 -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 1C0FBC0517B7; Mon, 5 Feb 2018 15:19:44 +0000 (UTC) Received: from localhost (unknown [10.40.205.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 20551424D; Mon, 5 Feb 2018 15:19:38 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 5 Feb 2018 16:18:19 +0100 Message-Id: <20180205151835.20812-11-mreitz@redhat.com> In-Reply-To: <20180205151835.20812-1-mreitz@redhat.com> References: <20180205151835.20812-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.32]); Mon, 05 Feb 2018 15:19: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 v8 10/26] 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 , 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 f404728732..06ee694ac5 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 @@ -4179,7 +4170,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 @@ -4208,22 +4198,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; @@ -4234,7 +4225,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.14.3 From nobody Sun May 5 01:13:32 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517847752551428.48669297402955; Mon, 5 Feb 2018 08:22:32 -0800 (PST) Received: from localhost ([::1]:58453 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eijXL-0002s7-Kd for importer@patchew.org; Mon, 05 Feb 2018 11:22:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53280) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiiYs-0000hk-B6 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:20:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiiYr-0007qK-Bt for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:20:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36366) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eiiYn-0007cm-Kr; Mon, 05 Feb 2018 10:19: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 E84E6C059726; Mon, 5 Feb 2018 15:19:56 +0000 (UTC) Received: from localhost (unknown [10.40.205.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1E7DF60278; Mon, 5 Feb 2018 15:19:45 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 5 Feb 2018 16:18:20 +0100 Message-Id: <20180205151835.20812-12-mreitz@redhat.com> In-Reply-To: <20180205151835.20812-1-mreitz@redhat.com> References: <20180205151835.20812-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.32]); Mon, 05 Feb 2018 15:19: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 v8 11/26] 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 , 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 fafb8a6a7a..1983055916 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 b5c124fcbd..8b0413e3df 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 06ee694ac5..8957a3d4dc 100644 --- a/block.c +++ b/block.c @@ -5153,6 +5153,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.14.3 From nobody Sun May 5 01:13:32 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517846169268741.2258309796626; Mon, 5 Feb 2018 07:56:09 -0800 (PST) Received: from localhost ([::1]:55823 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eij7o-0005tI-AH for importer@patchew.org; Mon, 05 Feb 2018 10:56:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53350) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiiZ7-000108-W0 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:20:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiiZ5-0008NI-9V for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:20:17 -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 1eiiYw-00081y-U3; Mon, 05 Feb 2018 10:20:07 -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 220944D2E0; Mon, 5 Feb 2018 15:20:06 +0000 (UTC) Received: from localhost (unknown [10.40.205.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E4C8460C7B; Mon, 5 Feb 2018 15:19:58 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 5 Feb 2018 16:18:21 +0100 Message-Id: <20180205151835.20812-13-mreitz@redhat.com> In-Reply-To: <20180205151835.20812-1-mreitz@redhat.com> References: <20180205151835.20812-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.30]); Mon, 05 Feb 2018 15:20:06 +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 v8 12/26] 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 , 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" 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.14.3 From nobody Sun May 5 01:13:32 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517846362704202.18264196557698; Mon, 5 Feb 2018 07:59:22 -0800 (PST) Received: from localhost ([::1]:55942 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eijAv-00006w-T4 for importer@patchew.org; Mon, 05 Feb 2018 10:59:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53458) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiiZJ-0001B4-DW for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:20:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiiZB-00009h-OB for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:20:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41972) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eiiZ9-0008TM-6S; Mon, 05 Feb 2018 10:20:19 -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 76E1462E80; Mon, 5 Feb 2018 15:20:18 +0000 (UTC) Received: from localhost (unknown [10.40.205.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B41ED2E0C1; Mon, 5 Feb 2018 15:20:08 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 5 Feb 2018 16:18:22 +0100 Message-Id: <20180205151835.20812-14-mreitz@redhat.com> In-Reply-To: <20180205151835.20812-1-mreitz@redhat.com> References: <20180205151835.20812-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.39]); Mon, 05 Feb 2018 15:20:18 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v8 13/26] 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 , 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.14.3 From nobody Sun May 5 01:13:32 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151784834009269.91101708222584; Mon, 5 Feb 2018 08:32:20 -0800 (PST) Received: from localhost ([::1]:59944 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eijgp-0003DR-6w for importer@patchew.org; Mon, 05 Feb 2018 11:32:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53557) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiiZZ-0001Nj-Fk for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:20:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiiZT-0000tA-G2 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:20:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42284) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eiiZK-0000Vv-RP; Mon, 05 Feb 2018 10:20:30 -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 0986625BBE; Mon, 5 Feb 2018 15:20:30 +0000 (UTC) Received: from localhost (unknown [10.40.205.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 769A7608F0; Mon, 5 Feb 2018 15:20:20 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 5 Feb 2018 16:18:23 +0100 Message-Id: <20180205151835.20812-15-mreitz@redhat.com> In-Reply-To: <20180205151835.20812-1-mreitz@redhat.com> References: <20180205151835.20812-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.39]); Mon, 05 Feb 2018 15:20: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 v8 14/26] 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 , 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 94220f6d14..dcea7ffaef 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -574,6 +574,16 @@ static int nbd_get_info(BlockDriverState *bs, BlockDri= verInfo *bdi) return 0; } =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", @@ -592,6 +602,7 @@ static BlockDriver bdrv_nbd =3D { .bdrv_attach_aio_context =3D nbd_attach_aio_context, .bdrv_refresh_filename =3D nbd_refresh_filename, .bdrv_get_info =3D nbd_get_info, + .bdrv_dirname =3D nbd_dirname, }; =20 static BlockDriver bdrv_nbd_tcp =3D { @@ -612,6 +623,7 @@ static BlockDriver bdrv_nbd_tcp =3D { .bdrv_attach_aio_context =3D nbd_attach_aio_context, .bdrv_refresh_filename =3D nbd_refresh_filename, .bdrv_get_info =3D nbd_get_info, + .bdrv_dirname =3D nbd_dirname, }; =20 static BlockDriver bdrv_nbd_unix =3D { @@ -632,6 +644,7 @@ static BlockDriver bdrv_nbd_unix =3D { .bdrv_attach_aio_context =3D nbd_attach_aio_context, .bdrv_refresh_filename =3D nbd_refresh_filename, .bdrv_get_info =3D nbd_get_info, + .bdrv_dirname =3D nbd_dirname, }; =20 static void bdrv_nbd_init(void) --=20 2.14.3 From nobody Sun May 5 01:13:32 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151784802848562.48729629171271; Mon, 5 Feb 2018 08:27:08 -0800 (PST) Received: from localhost ([::1]:59209 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eijbk-00075c-9E for importer@patchew.org; Mon, 05 Feb 2018 11:27:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53540) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiiZV-0001Lz-8m for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:20:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiiZU-0000vn-9s for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:20:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51120) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eiiZQ-0000nD-Sy; Mon, 05 Feb 2018 10:20:36 -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 339842CE970; Mon, 5 Feb 2018 15:20:36 +0000 (UTC) Received: from localhost (unknown [10.40.205.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E83345C8A4; Mon, 5 Feb 2018 15:20:31 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 5 Feb 2018 16:18:24 +0100 Message-Id: <20180205151835.20812-16-mreitz@redhat.com> In-Reply-To: <20180205151835.20812-1-mreitz@redhat.com> References: <20180205151835.20812-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.29]); Mon, 05 Feb 2018 15:20: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 v8 15/26] 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 , 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 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 effc8719b5..ee1160980a 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -874,6 +874,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) @@ -907,6 +920,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.14.3 From nobody Sun May 5 01:13:32 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517846602366621.3183537890748; Mon, 5 Feb 2018 08:03:22 -0800 (PST) Received: from localhost ([::1]:56407 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eijEj-0003Mi-HP for importer@patchew.org; Mon, 05 Feb 2018 11:03:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53631) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiiZn-0001i9-EX for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:21:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiiZi-0001L8-LC for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:20:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43162) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eiiZd-0001C2-HZ; Mon, 05 Feb 2018 10:20:49 -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 C81F2272A7; Mon, 5 Feb 2018 15:20:48 +0000 (UTC) Received: from localhost (unknown [10.40.205.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 321DF5C25F; Mon, 5 Feb 2018 15:20:37 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 5 Feb 2018 16:18:25 +0100 Message-Id: <20180205151835.20812-17-mreitz@redhat.com> In-Reply-To: <20180205151835.20812-1-mreitz@redhat.com> References: <20180205151835.20812-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.39]); Mon, 05 Feb 2018 15:20: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 v8 16/26] 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 , 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 8957a3d4dc..f23b35405d 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.14.3 From nobody Sun May 5 01:13:32 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517846769905905.6464166021176; Mon, 5 Feb 2018 08:06:09 -0800 (PST) Received: from localhost ([::1]:56567 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eijHQ-0005d3-4G for importer@patchew.org; Mon, 05 Feb 2018 11:06:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiia3-00020V-Md for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:21:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiiZz-0001p6-JI for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:21:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40960) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eiiZl-0001PV-LZ; Mon, 05 Feb 2018 10:20:57 -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 DEA2870D6A; Mon, 5 Feb 2018 15:20:56 +0000 (UTC) Received: from localhost (unknown [10.40.205.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D52725EE15; Mon, 5 Feb 2018 15:20:50 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 5 Feb 2018 16:18:26 +0100 Message-Id: <20180205151835.20812-18-mreitz@redhat.com> In-Reply-To: <20180205151835.20812-1-mreitz@redhat.com> References: <20180205151835.20812-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, 05 Feb 2018 15:20: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 v8 17/26] 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 , 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.14.3 From nobody Sun May 5 01:13:32 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517845589962802.996177500714; Mon, 5 Feb 2018 07:46:29 -0800 (PST) Received: from localhost ([::1]:55238 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiiyN-00068o-Nv for importer@patchew.org; Mon, 05 Feb 2018 10:46:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53779) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiia6-00024h-QJ for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:21:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiiZz-0001ox-Gb for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:21:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38896) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eiiZr-0001Y7-0z; Mon, 05 Feb 2018 10:21:03 -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 3A9B7C05179C; Mon, 5 Feb 2018 15:21:02 +0000 (UTC) Received: from localhost (unknown [10.40.205.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D30965C8A4; Mon, 5 Feb 2018 15:20:58 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 5 Feb 2018 16:18:27 +0100 Message-Id: <20180205151835.20812-19-mreitz@redhat.com> In-Reply-To: <20180205151835.20812-1-mreitz@redhat.com> References: <20180205151835.20812-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.32]); Mon, 05 Feb 2018 15:21:02 +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 v8 18/26] 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 , 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 8b0413e3df..9e6800d42e 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 35cf417f59..7c5418324f 100644 --- a/block/curl.c +++ b/block/curl.c @@ -969,6 +969,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", @@ -983,6 +996,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 { @@ -999,6 +1014,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 { @@ -1015,6 +1032,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 { @@ -1031,6 +1050,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 6a1c53711a..f77acf68af 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -2183,6 +2183,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", @@ -2215,6 +2229,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) @@ -2250,6 +2266,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 dcea7ffaef..44a60f59bd 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -584,6 +584,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", @@ -603,6 +614,7 @@ static BlockDriver bdrv_nbd =3D { .bdrv_refresh_filename =3D nbd_refresh_filename, .bdrv_get_info =3D nbd_get_info, .bdrv_dirname =3D nbd_dirname, + .sgfnt_runtime_opts =3D nbd_sgfnt_runtime_opts, }; =20 static BlockDriver bdrv_nbd_tcp =3D { @@ -624,6 +636,7 @@ static BlockDriver bdrv_nbd_tcp =3D { .bdrv_refresh_filename =3D nbd_refresh_filename, .bdrv_get_info =3D nbd_get_info, .bdrv_dirname =3D nbd_dirname, + .sgfnt_runtime_opts =3D nbd_sgfnt_runtime_opts, }; =20 static BlockDriver bdrv_nbd_unix =3D { @@ -645,6 +658,7 @@ static BlockDriver bdrv_nbd_unix =3D { .bdrv_refresh_filename =3D nbd_refresh_filename, .bdrv_get_info =3D nbd_get_info, .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 ee1160980a..298ba7e320 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -896,6 +896,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", @@ -922,6 +931,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 0cdabaa440..0fcd2671c8 100644 --- a/block/null.c +++ b/block/null.c @@ -254,6 +254,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", @@ -272,6 +279,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 { @@ -292,6 +300,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 d552a6eba8..1b8c7378db 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -1113,6 +1113,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), @@ -1134,6 +1140,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 1f80961e1b..c61933aa2e 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -4315,6 +4315,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), @@ -4360,6 +4366,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 b1ea3caa4b..12f57c9676 100644 --- a/block/replication.c +++ b/block/replication.c @@ -701,6 +701,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", @@ -718,6 +725,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 f684477328..2425a0775b 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -3076,6 +3076,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", @@ -3110,6 +3119,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 { @@ -3146,6 +3156,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 { @@ -3182,6 +3193,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 8890a0c4ba..905fc44142 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -1196,6 +1196,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", @@ -1210,6 +1221,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.14.3 From nobody Sun May 5 01:13:32 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517845324864653.4483588532983; Mon, 5 Feb 2018 07:42:04 -0800 (PST) Received: from localhost ([::1]:54232 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiiu9-0001wq-SV for importer@patchew.org; Mon, 05 Feb 2018 10:42:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53718) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiia2-0001yl-9W for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:21:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiia0-0001rW-T0 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:21:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43596) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eiiZs-0001bM-Nw; Mon, 05 Feb 2018 10:21:04 -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 0B4DC6149B; Mon, 5 Feb 2018 15:21:04 +0000 (UTC) Received: from localhost (unknown [10.40.205.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8BEC55D9CB; Mon, 5 Feb 2018 15:21:03 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 5 Feb 2018 16:18:28 +0100 Message-Id: <20180205151835.20812-20-mreitz@redhat.com> In-Reply-To: <20180205151835.20812-1-mreitz@redhat.com> References: <20180205151835.20812-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.39]); Mon, 05 Feb 2018 15:21:04 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v8 19/26] 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 , 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 9e6800d42e..5e0bfe70d4 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -135,6 +135,23 @@ struct BlockDriver { =20 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 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 e61d15bc92..caa6131712 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2343,6 +2343,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), @@ -2413,6 +2425,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.14.3 From nobody Sun May 5 01:13:32 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517846988441186.10247059734672; Mon, 5 Feb 2018 08:09:48 -0800 (PST) Received: from localhost ([::1]:57126 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eijKz-0000Ri-Fh for importer@patchew.org; Mon, 05 Feb 2018 11:09:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53752) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiia4-00021q-KQ for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:21:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiia2-0001uB-Fh for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:21:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49850) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eiiZv-0001g4-DP; Mon, 05 Feb 2018 10:21:07 -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 AEA14C053FBB; Mon, 5 Feb 2018 15:21:06 +0000 (UTC) Received: from localhost (unknown [10.40.205.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 07E6C6090C; Mon, 5 Feb 2018 15:21:05 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 5 Feb 2018 16:18:29 +0100 Message-Id: <20180205151835.20812-21-mreitz@redhat.com> In-Reply-To: <20180205151835.20812-1-mreitz@redhat.com> References: <20180205151835.20812-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, 05 Feb 2018 15:21:06 +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 v8 20/26] 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 , 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 f23b35405d..7980090d25 100644 --- a/block.c +++ b/block.c @@ -4999,6 +4999,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", 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; @@ -5153,9 +5239,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 b22471b40a..627ae51106 100644 --- a/tests/qemu-iotests/191.out +++ b/tests/qemu-iotests/191.out @@ -52,7 +52,7 @@ wrote 65536/65536 bytes at offset 1048576 }, "backing-filename-format": "IMGFMT", "virtual-size": 67108864, - "filename": "json:{"backing": {"backing": {"driver": "IMGF= MT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.base"}}, "dr= iver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.= mid"}}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DI= R/t.IMGFMT.ovl2"}}", + "filename": "json:{"backing": {"driver": "IMGFMT", "file":= {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.mid"}}, "driver": "IMGFM= T", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.ovl2"}}", "cluster-size": 65536, "format": "IMGFMT", "actual-size": SIZE, @@ -77,7 +77,7 @@ wrote 65536/65536 bytes at offset 1048576 "direct": false, "writeback": true }, - "file": "json:{"backing": {"backing": {"driver": "IMGFMT", "fi= le": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.base"}}, "driver": "= IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.mid"}}, = "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGF= MT.ovl2"}}", + "file": "json:{"backing": {"driver": "IMGFMT", "file": {"drive= r": "file", "filename": "TEST_DIR/t.IMGFMT.mid"}}, "driver": "IMGFMT", "fil= e": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.ovl2"}}", "encryption_key_missing": false }, { @@ -123,7 +123,7 @@ wrote 65536/65536 bytes at offset 1048576 }, "backing-filename-format": "IMGFMT", "virtual-size": 67108864, - "filename": "json:{"backing": {"backing": {"driver": "IMGF= MT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.base"}}, "dr= iver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.= mid"}}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DI= R/t.IMGFMT"}}", + "filename": "json:{"backing": {"driver": "IMGFMT", "file":= {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.mid"}}, "driver": "IMGFM= T", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}}", "cluster-size": 65536, "format": "IMGFMT", "actual-size": SIZE, @@ -148,7 +148,7 @@ wrote 65536/65536 bytes at offset 1048576 "direct": false, "writeback": true }, - "file": "json:{"backing": {"backing": {"driver": "IMGFMT", "fi= le": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.base"}}, "driver": "= IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.mid"}}, = "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGF= MT"}}", + "file": "json:{"backing": {"driver": "IMGFMT", "file": {"drive= r": "file", "filename": "TEST_DIR/t.IMGFMT.mid"}}, "driver": "IMGFMT", "fil= e": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}}", "encryption_key_missing": false }, { @@ -392,7 +392,7 @@ wrote 65536/65536 bytes at offset 1048576 }, "backing-filename-format": "IMGFMT", "virtual-size": 67108864, - "filename": "json:{"backing": {"backing": {"driver": "IMGF= MT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.base"}}, "dr= iver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.= mid"}}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DI= R/t.IMGFMT.ovl2"}}", + "filename": "json:{"backing": {"driver": "IMGFMT", "file":= {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.mid"}}, "driver": "IMGFM= T", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.ovl2"}}", "cluster-size": 65536, "format": "IMGFMT", "actual-size": SIZE, @@ -417,7 +417,7 @@ wrote 65536/65536 bytes at offset 1048576 "direct": false, "writeback": true }, - "file": "json:{"backing": {"backing": {"driver": "IMGFMT", "fi= le": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.base"}}, "driver": "= IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.mid"}}, = "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGF= MT.ovl2"}}", + "file": "json:{"backing": {"driver": "IMGFMT", "file": {"drive= r": "file", "filename": "TEST_DIR/t.IMGFMT.mid"}}, "driver": "IMGFMT", "fil= e": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.ovl2"}}", "encryption_key_missing": false }, { @@ -464,7 +464,7 @@ wrote 65536/65536 bytes at offset 1048576 }, "backing-filename-format": "IMGFMT", "virtual-size": 67108864, - "filename": "json:{"backing": {"backing": {"driver": "= IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.base"}},= "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMG= FMT.mid"}}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TES= T_DIR/t.IMGFMT.ovl2"}}", + "filename": "json:{"backing": {"driver": "IMGFMT", "fi= le": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.mid"}}, "driver": "I= MGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.ovl2"}}", "cluster-size": 65536, "format": "IMGFMT", "actual-size": SIZE, @@ -474,12 +474,12 @@ wrote 65536/65536 bytes at offset 1048576 }, "backing-filename-format": "IMGFMT", "virtual-size": 67108864, - "filename": "json:{"backing": {"backing": {"backing": {"dr= iver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.= base"}}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_D= IR/t.IMGFMT.mid"}}, "driver": "IMGFMT", "file": {"driver": "file", "filenam= e": "TEST_DIR/t.IMGFMT.ovl2"}}, "driver": "IMGFMT", "file": {"driver": "fil= e", "filename": "TEST_DIR/t.IMGFMT.ovl3"}}", + "filename": "json:{"backing": {"backing": {"driver": "IMGF= MT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.mid"}}, "dri= ver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.o= vl2"}}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DI= R/t.IMGFMT.ovl3"}}", "cluster-size": 65536, "format": "IMGFMT", "actual-size": SIZE, - "full-backing-filename": "json:{"backing": {"backing": {"d= river": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT= .base"}}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_= DIR/t.IMGFMT.mid"}}, "driver": "IMGFMT", "file": {"driver": "file", "filena= me": "TEST_DIR/t.IMGFMT.ovl2"}}", - "backing-filename": "json:{"backing": {"backing": {"driver= ": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.base= "}}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t= .IMGFMT.mid"}}, "driver": "IMGFMT", "file": {"driver": "file", "filename": = "TEST_DIR/t.IMGFMT.ovl2"}}", + "full-backing-filename": "json:{"backing": {"driver": "IMG= FMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.mid"}}, "dr= iver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.= ovl2"}}", + "backing-filename": "json:{"backing": {"driver": "IMGFMT",= "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.mid"}}, "driver"= : "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.ovl2"= }}", "dirty-flag": false }, "iops_wr": 0, @@ -490,7 +490,7 @@ wrote 65536/65536 bytes at offset 1048576 "iops": 0, "bps_wr": 0, "write_threshold": 0, - "backing_file": "json:{"backing": {"backing": {"driver": "IMGF= MT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.base"}}, "dr= iver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.= mid"}}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DI= R/t.IMGFMT.ovl2"}}", + "backing_file": "json:{"backing": {"driver": "IMGFMT", "file":= {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.mid"}}, "driver": "IMGFM= T", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.ovl2"}}", "encrypted": false, "bps": 0, "bps_rd": 0, @@ -499,7 +499,7 @@ wrote 65536/65536 bytes at offset 1048576 "direct": false, "writeback": true }, - "file": "json:{"backing": {"backing": {"backing": {"driver": "= IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.base"}},= "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMG= FMT.mid"}}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TES= T_DIR/t.IMGFMT.ovl2"}}, "driver": "IMGFMT", "file": {"driver": "file", "fil= ename": "TEST_DIR/t.IMGFMT.ovl3"}}", + "file": "json:{"backing": {"backing": {"driver": "IMGFMT", "fi= le": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.mid"}}, "driver": "I= MGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.ovl2"}}, = "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGF= MT.ovl3"}}", "encryption_key_missing": false }, { --=20 2.14.3 From nobody Sun May 5 01:13:32 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517848605980311.3893018518228; Mon, 5 Feb 2018 08:36:45 -0800 (PST) Received: from localhost ([::1]:60374 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eijl7-0006o8-2Z for importer@patchew.org; Mon, 05 Feb 2018 11:36:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53773) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiia6-00024N-GG for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:21:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiia4-0001x0-3i for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:21:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:18908) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eiiZy-0001nB-Tf; Mon, 05 Feb 2018 10:21:11 -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 38C09C036760; Mon, 5 Feb 2018 15:21:10 +0000 (UTC) Received: from localhost (unknown [10.40.205.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AD7E4508FF; Mon, 5 Feb 2018 15:21:08 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 5 Feb 2018 16:18:30 +0100 Message-Id: <20180205151835.20812-22-mreitz@redhat.com> In-Reply-To: <20180205151835.20812-1-mreitz@redhat.com> References: <20180205151835.20812-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, 05 Feb 2018 15:21:10 +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 v8 21/26] 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 , 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 Reviewed-by: Alberto Garcia --- include/block/block_int.h | 6 +- block.c | 145 +++++++-----------------------------------= ---- block/blkdebug.c | 55 +++++++----------- 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, 66 insertions(+), 272 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 5e0bfe70d4..178adde654 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 7980090d25..2963cbc921 100644 --- a/block.c +++ b/block.c @@ -5085,47 +5085,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 @@ -5143,6 +5102,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; @@ -5158,90 +5119,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) { - 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 @@ -5267,6 +5148,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..7bd0e8d968 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -808,52 +808,37 @@ 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)) + { + /* Real child options are under "image", but "x-image" may + * contain a filename */ + if (strcmp(qdict_entry_key(e), "config") && + strcmp(qdict_entry_key(e), "image") && + strcmp(qdict_entry_key(e), "x-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 1fa6c9c0e0..1270b2290b 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 aa68531352..1e3b40c2b8 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 44a60f59bd..9b74894efb 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -515,12 +515,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) { @@ -533,8 +530,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); @@ -548,22 +543,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 int nbd_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) diff --git a/block/nfs.c b/block/nfs.c index 298ba7e320..6a9783be39 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -818,14 +818,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), @@ -843,35 +838,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 0fcd2671c8..cca149ce9c 100644 --- a/block/null.c +++ b/block/null.c @@ -240,18 +240,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.14.3 From nobody Sun May 5 01:13:32 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517847195575626.7045654515391; Mon, 5 Feb 2018 08:13:15 -0800 (PST) Received: from localhost ([::1]:57447 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eijOM-0003RW-PU for importer@patchew.org; Mon, 05 Feb 2018 11:13:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53868) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiiaG-0002AQ-Pz for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:21:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiiaA-00029E-UY for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:21:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41246) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eiia0-0001qY-Pv; Mon, 05 Feb 2018 10:21:12 -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 16D7E70D81; Mon, 5 Feb 2018 15:21:12 +0000 (UTC) Received: from localhost (unknown [10.40.205.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 97AED5D6A2; Mon, 5 Feb 2018 15:21:11 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 5 Feb 2018 16:18:31 +0100 Message-Id: <20180205151835.20812-23-mreitz@redhat.com> In-Reply-To: <20180205151835.20812-1-mreitz@redhat.com> References: <20180205151835.20812-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, 05 Feb 2018 15:21:12 +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 v8 22/26] 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 , 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 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 2963cbc921..664f87bad4 100644 --- a/block.c +++ b/block.c @@ -5159,9 +5159,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.14.3 From nobody Sun May 5 01:13:32 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15178490350521001.3447532794447; Mon, 5 Feb 2018 08:43:55 -0800 (PST) Received: from localhost ([::1]:33467 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eijrx-0004uT-VV for importer@patchew.org; Mon, 05 Feb 2018 11:43:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53877) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiiaH-0002B3-G2 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:21:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiiaC-0002C6-JP for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:21:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44768) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eiia6-00020F-HL; Mon, 05 Feb 2018 10:21:18 -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 C241E43A44; Mon, 5 Feb 2018 15:21:17 +0000 (UTC) Received: from localhost (unknown [10.40.205.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 104975C25E; Mon, 5 Feb 2018 15:21:13 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 5 Feb 2018 16:18:32 +0100 Message-Id: <20180205151835.20812-24-mreitz@redhat.com> In-Reply-To: <20180205151835.20812-1-mreitz@redhat.com> References: <20180205151835.20812-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.30]); Mon, 05 Feb 2018 15:21: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 v8 23/26] 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 , 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" 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 664f87bad4..640015e1f7 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 @@ -2249,6 +2252,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 * @@ -2267,7 +2306,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 @@ -2297,11 +2336,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; @@ -2322,6 +2356,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); @@ -2337,6 +2373,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); @@ -2352,6 +2392,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 @@ -5027,6 +5068,34 @@ static const char *const *significant_options(BlockD= riverState *bs, return (curopt && *curopt) ? curopt : NULL; } =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 --=20 2.14.3 From nobody Sun May 5 01:13:32 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517848813996134.45081315769505; Mon, 5 Feb 2018 08:40:13 -0800 (PST) Received: from localhost ([::1]:60787 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eijoR-0001Tq-AW for importer@patchew.org; Mon, 05 Feb 2018 11:40:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53857) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiiaD-00029F-58 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:21:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiiaB-0002Aw-U2 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:21:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52100) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eiia9-00025A-6j; Mon, 05 Feb 2018 10:21:21 -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 7F2932D0FD0; Mon, 5 Feb 2018 15:21:20 +0000 (UTC) Received: from localhost (unknown [10.40.205.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B845D5C25E; Mon, 5 Feb 2018 15:21:19 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 5 Feb 2018 16:18:33 +0100 Message-Id: <20180205151835.20812-25-mreitz@redhat.com> In-Reply-To: <20180205151835.20812-1-mreitz@redhat.com> References: <20180205151835.20812-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.29]); Mon, 05 Feb 2018 15:21:20 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v8 24/26] block/curl: Harmonize option defaults 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 , 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" Both of the defaults we currently have in the curl driver are named based on a slightly different schema, let's unify that and call both CURL_BLOCK_OPT_${NAME}_DEFAULT. While at it, we can add a macro for the third option for which a default exists, namely "sslverify". Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia --- block/curl.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/block/curl.c b/block/curl.c index 7c5418324f..4790c7dad5 100644 --- a/block/curl.c +++ b/block/curl.c @@ -72,8 +72,6 @@ static CURLMcode __curl_multi_socket_action(CURLM *multi_= handle, =20 #define CURL_NUM_STATES 8 #define CURL_NUM_ACB 8 -#define READ_AHEAD_DEFAULT (256 * 1024) -#define CURL_TIMEOUT_DEFAULT 5 #define CURL_TIMEOUT_MAX 10000 =20 #define CURL_BLOCK_OPT_URL "url" @@ -87,6 +85,10 @@ static CURLMcode __curl_multi_socket_action(CURLM *multi= _handle, #define CURL_BLOCK_OPT_PROXY_USERNAME "proxy-username" #define CURL_BLOCK_OPT_PROXY_PASSWORD_SECRET "proxy-password-secret" =20 +#define CURL_BLOCK_OPT_READAHEAD_DEFAULT (256 * 1024) +#define CURL_BLOCK_OPT_SSLVERIFY_DEFAULT true +#define CURL_BLOCK_OPT_TIMEOUT_DEFAULT 5 + struct BDRVCURLState; =20 static bool libcurl_initialized; @@ -714,7 +716,7 @@ static int curl_open(BlockDriverState *bs, QDict *optio= ns, int flags, } =20 s->readahead_size =3D qemu_opt_get_size(opts, CURL_BLOCK_OPT_READAHEAD, - READ_AHEAD_DEFAULT); + CURL_BLOCK_OPT_READAHEAD_DEFAULT= ); if ((s->readahead_size & 0x1ff) !=3D 0) { error_setg(errp, "HTTP_READAHEAD_SIZE %zd is not a multiple of 512= ", s->readahead_size); @@ -722,13 +724,14 @@ static int curl_open(BlockDriverState *bs, QDict *opt= ions, int flags, } =20 s->timeout =3D qemu_opt_get_number(opts, CURL_BLOCK_OPT_TIMEOUT, - CURL_TIMEOUT_DEFAULT); + CURL_BLOCK_OPT_TIMEOUT_DEFAULT); if (s->timeout > CURL_TIMEOUT_MAX) { error_setg(errp, "timeout parameter is too large or negative"); goto out_noclean; } =20 - s->sslverify =3D qemu_opt_get_bool(opts, CURL_BLOCK_OPT_SSLVERIFY, tru= e); + s->sslverify =3D qemu_opt_get_bool(opts, CURL_BLOCK_OPT_SSLVERIFY, + CURL_BLOCK_OPT_SSLVERIFY_DEFAULT); =20 cookie =3D qemu_opt_get(opts, CURL_BLOCK_OPT_COOKIE); cookie_secret =3D qemu_opt_get(opts, CURL_BLOCK_OPT_COOKIE_SECRET); --=20 2.14.3 From nobody Sun May 5 01:13:32 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517846865472205.1701310766341; Mon, 5 Feb 2018 08:07:45 -0800 (PST) Received: from localhost ([::1]:56948 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eijJ2-00077w-J0 for importer@patchew.org; Mon, 05 Feb 2018 11:07:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53947) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiiaV-0002MV-Ai for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:21:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiiaR-0002Za-6q for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:21:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47582) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eiiaI-0002Kl-Ct; Mon, 05 Feb 2018 10:21:30 -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 9B6243A9FA; Mon, 5 Feb 2018 15:21:29 +0000 (UTC) Received: from localhost (unknown [10.40.205.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EE8D760C7B; Mon, 5 Feb 2018 15:21:22 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 5 Feb 2018 16:18:34 +0100 Message-Id: <20180205151835.20812-26-mreitz@redhat.com> In-Reply-To: <20180205151835.20812-1-mreitz@redhat.com> References: <20180205151835.20812-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, 05 Feb 2018 15:21:29 +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 v8 25/26] 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 , 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 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/block/curl.c b/block/curl.c index 4790c7dad5..f4053e207c 100644 --- a/block/curl.c +++ b/block/curl.c @@ -972,6 +972,23 @@ static int64_t curl_getlength(BlockDriverState *bs) return s->len; } =20 +static void curl_refresh_filename(BlockDriverState *bs) +{ + BDRVCURLState *s =3D bs->opaque; + + /* "readahead" and "timeout" do not change the guest-visible data, + * so ignore them */ + if (s->sslverify !=3D CURL_BLOCK_OPT_SSLVERIFY_DEFAULT || + 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, @@ -1000,6 +1017,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 @@ -1018,6 +1036,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 @@ -1036,6 +1055,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 @@ -1054,6 +1074,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.14.3 From nobody Sun May 5 01:13:32 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517849216318198.70775407922088; Mon, 5 Feb 2018 08:46:56 -0800 (PST) Received: from localhost ([::1]:33901 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eijuv-0007st-IB for importer@patchew.org; Mon, 05 Feb 2018 11:46:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiiaf-0002U8-7v for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:21:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiiab-0002qR-3l for qemu-devel@nongnu.org; Mon, 05 Feb 2018 10:21:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39890) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eiiaR-0002Zh-QG; Mon, 05 Feb 2018 10:21:39 -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 0B2D2C05178D; Mon, 5 Feb 2018 15:21:39 +0000 (UTC) Received: from localhost (unknown [10.40.205.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9741F5D6B4; Mon, 5 Feb 2018 15:21:31 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 5 Feb 2018 16:18:35 +0100 Message-Id: <20180205151835.20812-27-mreitz@redhat.com> In-Reply-To: <20180205151835.20812-1-mreitz@redhat.com> References: <20180205151835.20812-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.32]); Mon, 05 Feb 2018 15:21: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 v8 26/26] 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 , 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 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 cca149ce9c..6ffed1c98e 100644 --- a/block/null.c +++ b/block/null.c @@ -249,7 +249,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.14.3