]> git.proxmox.com Git - mirror_qemu.git/commitdiff
block: BlockDriver: add .filtered_child_is_backing field
authorVladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Tue, 26 Jul 2022 20:11:20 +0000 (23:11 +0300)
committerKevin Wolf <kwolf@redhat.com>
Thu, 27 Oct 2022 18:14:11 +0000 (20:14 +0200)
Unfortunately not all filters use .file child as filtered child. Two
exclusions are mirror_top and commit_top. Happily they both are private
filters. Bad thing is that this inconsistency is observable through qmp
commands query-block / query-named-block-nodes. So, could we just
change mirror_top and commit_top to use file child as all other filter
driver is an open question. Probably, we could do that with some kind
of deprecation period, but how to warn users during it?

For now, let's just add a field so we can distinguish them in generic
code, it will be used in further commits.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
Message-Id: <20220726201134.924743-2-vsementsov@yandex-team.ru>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/commit.c
block/mirror.c
include/block/block_int-common.h

index 38571510cbdc0c278a4c8e65b8fa83985f922ba5..e210e86bacb38a42adf0762719305effc2fd753d 100644 (file)
@@ -238,6 +238,7 @@ static BlockDriver bdrv_commit_top = {
     .bdrv_child_perm            = bdrv_commit_top_child_perm,
 
     .is_filter                  = true,
+    .filtered_child_is_backing  = true,
 };
 
 void commit_start(const char *job_id, BlockDriverState *bs,
index 80c0109d39652a7d1b08e6eef728bb7a36d332c7..f9432af3df3cc48b23872763fde1e1535ddb05c4 100644 (file)
@@ -1587,6 +1587,7 @@ static BlockDriver bdrv_mirror_top = {
     .bdrv_child_perm            = bdrv_mirror_top_child_perm,
 
     .is_filter                  = true,
+    .filtered_child_is_backing  = true,
 };
 
 static BlockJob *mirror_start_job(
index d7c0a7e96f67a47d316fecfb1037a1115a6ec841..95392052c96a44fe3f1438d4880c2e90577030f3 100644 (file)
@@ -119,6 +119,19 @@ struct BlockDriver {
      * (And this filtered child must then be bs->file or bs->backing.)
      */
     bool is_filter;
+    /*
+     * Only make sense for filter drivers, for others must be false.
+     * If true, filtered child is bs->backing. Otherwise it's bs->file.
+     * Only two internal filters use bs->backing as filtered child and has this
+     * field set to true: mirror_top and commit_top.
+     *
+     * Never create any more such filters!
+     *
+     * TODO: imagine how to deprecate this behavior and make all filters work
+     * similarly using bs->file as filtered child.
+     */
+    bool filtered_child_is_backing;
+
     /*
      * Set to true if the BlockDriver is a format driver.  Format nodes
      * generally do not expect their children to be other format nodes