All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
	qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: [PATCH v2 25/33] block: Make filter drivers use child_of_bds
Date: Tue,  4 Feb 2020 18:08:40 +0100	[thread overview]
Message-ID: <20200204170848.614480-26-mreitz@redhat.com> (raw)
In-Reply-To: <20200204170848.614480-1-mreitz@redhat.com>

Note that some filters have secondary children, namely blkverify (the
image to be verified) and blklogwrites (the log).  This patch does not
touch those children.

Note that for blkverify, the filtered child should not be format-probed.
While there is nothing enforcing this here, in practice, it will not be:
blkverify implements .bdrv_file_open.  The block layer ensures (and in
fact, asserts) that BDRV_O_PROTOCOL is set for every BDS whose driver
implements .bdrv_file_open.  This flag will then be bequeathed to
blkverify's children, and they will thus (by default) not be probed
either.

("By default" refers to the fact that blkverify's other child (the
non-filtered one) will have BDRV_O_PROTOCOL force-unset, because that is
what happens for all non-filtered children of non-format drivers.)

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block/blkdebug.c        | 4 +++-
 block/blklogwrites.c    | 3 ++-
 block/blkverify.c       | 4 +++-
 block/copy-on-read.c    | 5 +++--
 block/filter-compress.c | 5 +++--
 block/replication.c     | 3 ++-
 block/throttle.c        | 5 +++--
 7 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/block/blkdebug.c b/block/blkdebug.c
index 8dd8ed6055..b31fa40b0e 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -497,7 +497,9 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
 
     /* Open the image file */
     bs->file = bdrv_open_child(qemu_opt_get(opts, "x-image"), options, "image",
-                               bs, &child_file, 0, false, &local_err);
+                               bs, &child_of_bds,
+                               BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY,
+                               false, &local_err);
     if (local_err) {
         ret = -EINVAL;
         error_propagate(errp, local_err);
diff --git a/block/blklogwrites.c b/block/blklogwrites.c
index 4faf912ef1..78b0c49460 100644
--- a/block/blklogwrites.c
+++ b/block/blklogwrites.c
@@ -157,7 +157,8 @@ static int blk_log_writes_open(BlockDriverState *bs, QDict *options, int flags,
     }
 
     /* Open the file */
-    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0, false,
+    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds,
+                               BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, false,
                                &local_err);
     if (local_err) {
         ret = -EINVAL;
diff --git a/block/blkverify.c b/block/blkverify.c
index 1684b7aa2e..5c3b29244a 100644
--- a/block/blkverify.c
+++ b/block/blkverify.c
@@ -125,7 +125,9 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags,
 
     /* Open the raw file */
     bs->file = bdrv_open_child(qemu_opt_get(opts, "x-raw"), options, "raw",
-                               bs, &child_file, 0, false, &local_err);
+                               bs, &child_of_bds,
+                               BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY,
+                               false, &local_err);
     if (local_err) {
         ret = -EINVAL;
         error_propagate(errp, local_err);
diff --git a/block/copy-on-read.c b/block/copy-on-read.c
index a2d92ac394..c857ea0da7 100644
--- a/block/copy-on-read.c
+++ b/block/copy-on-read.c
@@ -28,8 +28,9 @@
 static int cor_open(BlockDriverState *bs, QDict *options, int flags,
                     Error **errp)
 {
-    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0, false,
-                               errp);
+    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds,
+                               BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY,
+                               false, errp);
     if (!bs->file) {
         return -EINVAL;
     }
diff --git a/block/filter-compress.c b/block/filter-compress.c
index 4dc5f9fb8c..9edd937645 100644
--- a/block/filter-compress.c
+++ b/block/filter-compress.c
@@ -30,8 +30,9 @@
 static int compress_open(BlockDriverState *bs, QDict *options, int flags,
                          Error **errp)
 {
-    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0, false,
-                               errp);
+    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds,
+                               BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY,
+                               false, errp);
     if (!bs->file) {
         return -EINVAL;
     }
diff --git a/block/replication.c b/block/replication.c
index 9ca5c9368e..ec512ae1c3 100644
--- a/block/replication.c
+++ b/block/replication.c
@@ -90,7 +90,8 @@ static int replication_open(BlockDriverState *bs, QDict *options,
     const char *mode;
     const char *top_id;
 
-    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
+    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds,
+                               BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY,
                                false, errp);
     if (!bs->file) {
         return -EINVAL;
diff --git a/block/throttle.c b/block/throttle.c
index 2dea913be7..47b0a3522d 100644
--- a/block/throttle.c
+++ b/block/throttle.c
@@ -81,8 +81,9 @@ static int throttle_open(BlockDriverState *bs, QDict *options,
     char *group;
     int ret;
 
-    bs->file = bdrv_open_child(NULL, options, "file", bs,
-                               &child_file, 0, false, errp);
+    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds,
+                               BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY,
+                               false, errp);
     if (!bs->file) {
         return -EINVAL;
     }
-- 
2.24.1



  parent reply	other threads:[~2020-02-04 17:19 UTC|newest]

Thread overview: 86+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-04 17:08 [PATCH v2 00/33] block: Introduce real BdrvChildRole Max Reitz
2020-02-04 17:08 ` [PATCH v2 01/33] block: Add BlockDriver.is_format Max Reitz
2020-02-05 13:51   ` Eric Blake
2020-02-06 10:25     ` Max Reitz
2020-02-11 15:30   ` Alberto Garcia
2020-02-04 17:08 ` [PATCH v2 02/33] block: Rename BdrvChildRole to BdrvChildClass Max Reitz
2020-02-05 15:20   ` Eric Blake
2020-02-11 15:31   ` Alberto Garcia
2020-02-04 17:08 ` [PATCH v2 03/33] block: Add BdrvChildRole Max Reitz
2020-02-05 15:24   ` Eric Blake
2020-02-06 10:47     ` Max Reitz
2020-02-06 10:49       ` Max Reitz
2020-02-11 15:35         ` Eric Blake
2020-02-11 15:41   ` Alberto Garcia
2020-02-17 14:40     ` Max Reitz
2020-02-04 17:08 ` [PATCH v2 04/33] block: Add BdrvChildRole to BdrvChild Max Reitz
2020-02-05 15:33   ` Eric Blake
2020-02-06 10:53     ` Max Reitz
2020-02-11 15:37       ` Eric Blake
2020-02-04 17:08 ` [PATCH v2 05/33] block: Pass BdrvChildRole to bdrv_child_perm() Max Reitz
2020-02-05 16:14   ` Eric Blake
2020-02-04 17:08 ` [PATCH v2 06/33] block: Pass BdrvChildRole to .inherit_options() Max Reitz
2020-02-05 16:18   ` Eric Blake
2020-02-04 17:08 ` [PATCH v2 07/33] block: Pass parent_is_format " Max Reitz
2020-02-05 16:26   ` Eric Blake
2020-02-04 17:08 ` [PATCH v2 08/33] block: Rename bdrv_inherited_options() Max Reitz
2020-02-05 16:36   ` Eric Blake
2020-02-04 17:08 ` [PATCH v2 09/33] block: Add generic bdrv_inherited_options() Max Reitz
2020-02-05 16:48   ` Eric Blake
2020-02-06 11:06     ` Max Reitz
2020-02-04 17:08 ` [PATCH v2 10/33] block: Use bdrv_inherited_options() Max Reitz
2020-02-05 17:14   ` Eric Blake
2020-02-04 17:08 ` [PATCH v2 11/33] block: Unify bdrv_child_cb_attach() Max Reitz
2020-02-05 17:24   ` Eric Blake
2020-02-04 17:08 ` [PATCH v2 12/33] block: Unify bdrv_child_cb_detach() Max Reitz
2020-02-05 17:26   ` Eric Blake
2020-02-04 17:08 ` [PATCH v2 13/33] block: Add child_of_bds Max Reitz
2020-02-05 20:33   ` Eric Blake
2020-02-04 17:08 ` [PATCH v2 14/33] block: Distinguish paths in *_format_default_perms Max Reitz
2020-02-05 20:54   ` Eric Blake
2020-02-04 17:08 ` [PATCH v2 15/33] block: Pull out bdrv_default_perms_for_backing() Max Reitz
2020-02-05 20:56   ` Eric Blake
2020-02-06 11:19     ` Max Reitz
2020-02-11 15:38       ` Eric Blake
2020-02-04 17:08 ` [PATCH v2 16/33] block: Pull out bdrv_default_perms_for_storage() Max Reitz
2020-02-05 21:02   ` Eric Blake
2020-02-06 11:20     ` Max Reitz
2020-02-04 17:08 ` [PATCH v2 17/33] block: Split bdrv_default_perms_for_storage() Max Reitz
2020-02-05 21:25   ` Eric Blake
2020-02-04 17:08 ` [PATCH v2 18/33] block: Add bdrv_default_perms() Max Reitz
2020-02-05 21:53   ` Eric Blake
2020-02-04 17:08 ` [PATCH v2 19/33] raw-format: Split raw_read_options() Max Reitz
2020-02-05 21:57   ` Eric Blake
2020-02-04 17:08 ` [PATCH v2 20/33] block: Switch child_format users to child_of_bds Max Reitz
2020-02-05 22:11   ` Eric Blake
2020-02-04 17:08 ` [PATCH v2 21/33] block: Drop child_format Max Reitz
2020-02-05 22:19   ` Eric Blake
2020-02-04 17:08 ` [PATCH v2 22/33] block: Make backing files child_of_bds children Max Reitz
2020-02-05 22:45   ` Eric Blake
2020-02-06 11:33     ` Max Reitz
2020-02-11 15:39       ` Eric Blake
2020-02-04 17:08 ` [PATCH v2 23/33] block: Drop child_backing Max Reitz
2020-02-05 22:48   ` Eric Blake
2020-02-04 17:08 ` [PATCH v2 24/33] block: Make format drivers use child_of_bds Max Reitz
2020-02-05 22:54   ` Eric Blake
2020-02-04 17:08 ` Max Reitz [this message]
2020-02-05 23:02   ` [PATCH v2 25/33] block: Make filter " Eric Blake
2020-02-06 11:35     ` Max Reitz
2020-02-04 17:08 ` [PATCH v2 26/33] block: Use child_of_bds in remaining places Max Reitz
2020-02-05 23:28   ` Eric Blake
2020-02-04 17:08 ` [PATCH v2 27/33] tests: Use child_of_bds instead of child_file Max Reitz
2020-02-11 15:42   ` Eric Blake
2020-02-04 17:08 ` [PATCH v2 28/33] block: Use bdrv_default_perms() Max Reitz
2020-02-11 15:46   ` Eric Blake
2020-02-04 17:08 ` [PATCH v2 29/33] block: Make bdrv_filter_default_perms() static Max Reitz
2020-02-11 15:48   ` Eric Blake
2020-02-04 17:08 ` [PATCH v2 30/33] block: Drop bdrv_format_default_perms() Max Reitz
2020-02-11 15:48   ` Eric Blake
2020-02-04 17:08 ` [PATCH v2 31/33] block: Drop child_file Max Reitz
2020-02-11 15:49   ` Eric Blake
2020-02-04 17:08 ` [PATCH v2 32/33] block: Pass BdrvChildRole in remaining cases Max Reitz
2020-02-11 15:53   ` Eric Blake
2020-02-18 12:01     ` Max Reitz
2020-02-18 12:53       ` Eric Blake
2020-02-04 17:08 ` [PATCH v2 33/33] block: Drop @child_class from bdrv_child_perm() Max Reitz
2020-02-11 15:56   ` Eric Blake

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=20200204170848.614480-26-mreitz@redhat.com \
    --to=mreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@virtuozzo.com \
    /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.