From: Kevin Wolf <kwolf@redhat.com>
To: Jean-Louis Dupond <jean-louis@dupond.be>
Cc: qemu-devel@nongnu.org,
Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>,
John Snow <jsnow@redhat.com>,
Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>,
Hanna Reitz <hreitz@redhat.com>,
Fiona Ebner <f.ebner@proxmox.com>,
qemu-block@nongnu.org
Subject: Re: [PATCH v2 1/3] block: add bdrv_open_backing_chain_until
Date: Fri, 30 Oct 2026 18:25:41 +0100 [thread overview]
Message-ID: <auTTFW6aKUds7qHQ@redhat.com> (raw)
In-Reply-To: <20260915140444.1223798-2-jean-louis@dupond.be>
Am 15.09.2026 um 16:04 hat Jean-Louis Dupond geschrieben:
> Add a new function called bdrv_open_backing_chain_until.
> This is used to open a block up until a specified backing chain.
>
> Modified bdrv_open_inherit to accept a new arg
> 'open_backing_recursively' to force to not open the next backing.
> Adjusting all references to keep the existing behaviour.
>
> Signed-off-by: Jean-Louis Dupond <jean-louis@dupond.be>
Do you actually have a use case where limiting the backing chain is a
requirement? It looks a bit like premature optimisation, because for
running a VM, you'll open the whole chain anyway, so it can't be
unworkably long.
> diff --git a/block.c b/block.c
> index f0a6042e61..9763137d8c 100644
> --- a/block.c
> +++ b/block.c
> @@ -83,6 +83,7 @@ static QLIST_HEAD(, BlockDriver) bdrv_drivers =
> static BlockDriverState *bdrv_open_inherit(const char *filename,
> const char *reference,
> QDict *options, int flags,
> + bool open_backing_recursively,
> BlockDriverState *parent,
> const BdrvChildClass *child_class,
> BdrvChildRole child_role,
bdrv_open_inherit() already has too many parameters. Can't you just pass
BDRV_O_NO_BACKING instead of adding a new one?
> @@ -3733,6 +3735,54 @@ free_exit:
> return ret;
> }
>
> +int
> +bdrv_open_backing_chain_until(BlockDriverState *top_bs,
> + const char *base_filename,
> + Error **errp)
> +{
> + BlockDriverState *curr = top_bs;
> + int ret;
> +
> + GLOBAL_STATE_CODE();
> +
> + if (!base_filename) {
> + return 0;
> + }
> +
> + if (bdrv_find_backing_image(top_bs, base_filename)) {
> + return 0;
> + }
> +
> + while (true) {
> + QDict *options = qdict_clone_shallow(curr->options);
> +
> + ret = bdrv_open_backing_file(curr, options, false, "backing", errp);
> + qobject_unref(options);
Does this actually do anything? I don't think curr->options can contain
"backing" options when you opened it without backing files. It would
already fail during the initial open because bdrv_open_backing_file()
doesn't absorb the options, so they are considered unknown:
$ ./qemu-img info --image-opts driver=qcow2,file.filename=/tmp/overlay.qcow2,backing=foo
qemu-img: Could not open 'driver=qcow2,file.filename=/tmp/overlay.qcow2,backing=foo': Block format 'qcow2' does not support the option 'backing'
(Using 'qemu-img info' as an example that uses BDRV_O_NO_BACKING.)
In your specific 'qemu-img measure' implementation, it seems even
impossible to specify backing file options in the BDRV_O_NO_BACKING case
in the first place because --image-opts disables the partial loading.
Which might actually be another reason not to do the partial opening at
all because it's inconsistent behaviour.
> + if (ret < 0) {
> + return ret;
> + }
> +
> + bdrv_graph_rdlock_main_loop();
> + if (!curr->backing) {
> + bdrv_graph_rdunlock_main_loop();
> + error_setg(errp,
> + "Did not find '%s' in the backing chain of '%s'",
> + base_filename, top_bs->filename);
> + return -ENOENT;
> + }
> + bdrv_graph_rdunlock_main_loop();
> +
> + if (bdrv_find_backing_image(curr, base_filename)) {
> + return 0;
> + }
> +
> + /* Switch to the next layer */
> + bdrv_graph_rdlock_main_loop();
> + curr = curr->backing->bs;
> + bdrv_graph_rdunlock_main_loop();
> + }
> +}
Kevin
next prev parent reply other threads:[~2026-10-30 17:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 14:04 [PATCH v2 0/3] block: measure for commit Jean-Louis Dupond
2026-09-15 14:04 ` [PATCH v2 1/3] block: add bdrv_open_backing_chain_until Jean-Louis Dupond
2026-10-30 17:25 ` Kevin Wolf [this message]
2026-09-15 14:04 ` [PATCH v2 2/3] block: support measure for commit Jean-Louis Dupond
2026-10-30 19:06 ` Kevin Wolf
2026-09-15 14:04 ` [PATCH v2 3/3] iotests/290: add test case for qemu-img measure Jean-Louis Dupond
2026-10-30 19:11 ` Kevin Wolf
2026-10-13 11:10 ` [PATCH v2 0/3] block: measure for commit Jean-Louis Dupond
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=auTTFW6aKUds7qHQ@redhat.com \
--to=kwolf@redhat.com \
--cc=f.ebner@proxmox.com \
--cc=hreitz@redhat.com \
--cc=jean-louis@dupond.be \
--cc=jsnow@redhat.com \
--cc=pierrick.bouvier@oss.qualcomm.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@yandex-team.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.