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>,
	qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: [PATCH v3 05/33] block: Pass BdrvChildRole to bdrv_child_perm()
Date: Tue, 18 Feb 2020 13:42:14 +0100	[thread overview]
Message-ID: <20200218124242.584644-6-mreitz@redhat.com> (raw)
In-Reply-To: <20200218124242.584644-1-mreitz@redhat.com>

For now, all callers pass 0 and no callee evaluates this value.  Later
patches will change both.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 block.c                     | 22 ++++++++++++----------
 block/backup-top.c          |  3 ++-
 block/blkdebug.c            |  5 +++--
 block/blklogwrites.c        |  9 +++++----
 block/commit.c              |  1 +
 block/copy-on-read.c        |  1 +
 block/mirror.c              |  1 +
 block/quorum.c              |  1 +
 block/replication.c         |  1 +
 block/vvfat.c               |  1 +
 include/block/block_int.h   |  5 ++++-
 tests/test-bdrv-drain.c     |  5 +++--
 tests/test-bdrv-graph-mod.c |  1 +
 13 files changed, 36 insertions(+), 20 deletions(-)

diff --git a/block.c b/block.c
index e8ddf1689e..bfeed6e8d9 100644
--- a/block.c
+++ b/block.c
@@ -1786,12 +1786,12 @@ bool bdrv_is_writable(BlockDriverState *bs)
 
 static void bdrv_child_perm(BlockDriverState *bs, BlockDriverState *child_bs,
                             BdrvChild *c, const BdrvChildClass *child_class,
-                            BlockReopenQueue *reopen_queue,
+                            BdrvChildRole role, BlockReopenQueue *reopen_queue,
                             uint64_t parent_perm, uint64_t parent_shared,
                             uint64_t *nperm, uint64_t *nshared)
 {
     assert(bs->drv && bs->drv->bdrv_child_perm);
-    bs->drv->bdrv_child_perm(bs, c, child_class, reopen_queue,
+    bs->drv->bdrv_child_perm(bs, c, child_class, role, reopen_queue,
                              parent_perm, parent_shared,
                              nperm, nshared);
     /* TODO Take force_share from reopen_queue */
@@ -1885,7 +1885,7 @@ static int bdrv_check_perm(BlockDriverState *bs, BlockReopenQueue *q,
         uint64_t cur_perm, cur_shared;
         bool child_tighten_restr;
 
-        bdrv_child_perm(bs, c->bs, c, c->klass, q,
+        bdrv_child_perm(bs, c->bs, c, c->klass, c->role, q,
                         cumulative_perms, cumulative_shared_perms,
                         &cur_perm, &cur_shared);
         ret = bdrv_child_check_perm(c, q, cur_perm, cur_shared, ignore_children,
@@ -1952,7 +1952,7 @@ static void bdrv_set_perm(BlockDriverState *bs, uint64_t cumulative_perms,
     /* Update all children */
     QLIST_FOREACH(c, &bs->children, next) {
         uint64_t cur_perm, cur_shared;
-        bdrv_child_perm(bs, c->bs, c, c->klass, NULL,
+        bdrv_child_perm(bs, c->bs, c, c->klass, c->role, NULL,
                         cumulative_perms, cumulative_shared_perms,
                         &cur_perm, &cur_shared);
         bdrv_child_set_perm(c, cur_perm, cur_shared);
@@ -2180,14 +2180,15 @@ int bdrv_child_refresh_perms(BlockDriverState *bs, BdrvChild *c, Error **errp)
     uint64_t perms, shared;
 
     bdrv_get_cumulative_perm(bs, &parent_perms, &parent_shared);
-    bdrv_child_perm(bs, c->bs, c, c->klass, NULL, parent_perms, parent_shared,
-                    &perms, &shared);
+    bdrv_child_perm(bs, c->bs, c, c->klass, c->role, NULL,
+                    parent_perms, parent_shared, &perms, &shared);
 
     return bdrv_child_try_set_perm(c, perms, shared, errp);
 }
 
 void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c,
                                const BdrvChildClass *child_class,
+                               BdrvChildRole role,
                                BlockReopenQueue *reopen_queue,
                                uint64_t perm, uint64_t shared,
                                uint64_t *nperm, uint64_t *nshared)
@@ -2198,6 +2199,7 @@ void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c,
 
 void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c,
                                const BdrvChildClass *child_class,
+                               BdrvChildRole role,
                                BlockReopenQueue *reopen_queue,
                                uint64_t perm, uint64_t shared,
                                uint64_t *nperm, uint64_t *nshared)
@@ -2210,7 +2212,7 @@ void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c,
 
         /* Apart from the modifications below, the same permissions are
          * forwarded and left alone as for filters */
-        bdrv_filter_default_perms(bs, c, child_class, reopen_queue,
+        bdrv_filter_default_perms(bs, c, child_class, role, reopen_queue,
                                   perm, shared, &perm, &shared);
 
         /* Format drivers may touch metadata even if the guest doesn't write */
@@ -2486,7 +2488,7 @@ BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs,
     bdrv_get_cumulative_perm(parent_bs, &perm, &shared_perm);
 
     assert(parent_bs->drv);
-    bdrv_child_perm(parent_bs, child_bs, NULL, child_class, NULL,
+    bdrv_child_perm(parent_bs, child_bs, NULL, child_class, child_role, NULL,
                     perm, shared_perm, &perm, &shared_perm);
 
     child = bdrv_root_attach_child(child_bs, child_name, child_class,
@@ -3524,7 +3526,7 @@ int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, Error **errp)
         if (state->replace_backing_bs && state->new_backing_bs) {
             uint64_t nperm, nshared;
             bdrv_child_perm(state->bs, state->new_backing_bs,
-                            NULL, &child_backing, bs_queue,
+                            NULL, &child_backing, 0, bs_queue,
                             state->perm, state->shared_perm,
                             &nperm, &nshared);
             ret = bdrv_check_update_perm(state->new_backing_bs, NULL,
@@ -3638,7 +3640,7 @@ static void bdrv_reopen_perm(BlockReopenQueue *q, BlockDriverState *bs,
         } else {
             uint64_t nperm, nshared;
 
-            bdrv_child_perm(parent->state.bs, bs, c, c->klass, q,
+            bdrv_child_perm(parent->state.bs, bs, c, c->klass, c->role, q,
                             parent->state.perm, parent->state.shared_perm,
                             &nperm, &nshared);
 
diff --git a/block/backup-top.c b/block/backup-top.c
index b13d459e86..9dd89c2fde 100644
--- a/block/backup-top.c
+++ b/block/backup-top.c
@@ -122,6 +122,7 @@ static void backup_top_refresh_filename(BlockDriverState *bs)
 
 static void backup_top_child_perm(BlockDriverState *bs, BdrvChild *c,
                                   const BdrvChildClass *child_class,
+                                  BdrvChildRole role,
                                   BlockReopenQueue *reopen_queue,
                                   uint64_t perm, uint64_t shared,
                                   uint64_t *nperm, uint64_t *nshared)
@@ -152,7 +153,7 @@ static void backup_top_child_perm(BlockDriverState *bs, BdrvChild *c,
         *nperm = BLK_PERM_WRITE;
     } else {
         /* Source child */
-        bdrv_filter_default_perms(bs, c, child_class, reopen_queue,
+        bdrv_filter_default_perms(bs, c, child_class, role, reopen_queue,
                                   perm, shared, nperm, nshared);
 
         if (perm & BLK_PERM_WRITE) {
diff --git a/block/blkdebug.c b/block/blkdebug.c
index c91e78d5c8..8dd8ed6055 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -994,14 +994,15 @@ static int blkdebug_reopen_prepare(BDRVReopenState *reopen_state,
 
 static void blkdebug_child_perm(BlockDriverState *bs, BdrvChild *c,
                                 const BdrvChildClass *child_class,
+                                BdrvChildRole role,
                                 BlockReopenQueue *reopen_queue,
                                 uint64_t perm, uint64_t shared,
                                 uint64_t *nperm, uint64_t *nshared)
 {
     BDRVBlkdebugState *s = bs->opaque;
 
-    bdrv_filter_default_perms(bs, c, child_class, reopen_queue, perm, shared,
-                              nperm, nshared);
+    bdrv_filter_default_perms(bs, c, child_class, role, reopen_queue,
+                              perm, shared, nperm, nshared);
 
     *nperm |= s->take_child_perms;
     *nshared &= ~s->unshare_child_perms;
diff --git a/block/blklogwrites.c b/block/blklogwrites.c
index 739db6dcf6..4faf912ef1 100644
--- a/block/blklogwrites.c
+++ b/block/blklogwrites.c
@@ -283,6 +283,7 @@ static int64_t blk_log_writes_getlength(BlockDriverState *bs)
 
 static void blk_log_writes_child_perm(BlockDriverState *bs, BdrvChild *c,
                                       const BdrvChildClass *child_class,
+                                      BdrvChildRole role,
                                       BlockReopenQueue *ro_q,
                                       uint64_t perm, uint64_t shrd,
                                       uint64_t *nperm, uint64_t *nshrd)
@@ -294,11 +295,11 @@ static void blk_log_writes_child_perm(BlockDriverState *bs, BdrvChild *c,
     }
 
     if (!strcmp(c->name, "log")) {
-        bdrv_format_default_perms(bs, c, child_class, ro_q, perm, shrd, nperm,
-                                  nshrd);
+        bdrv_format_default_perms(bs, c, child_class, role, ro_q, perm, shrd,
+                                  nperm, nshrd);
     } else {
-        bdrv_filter_default_perms(bs, c, child_class, ro_q, perm, shrd, nperm,
-                                  nshrd);
+        bdrv_filter_default_perms(bs, c, child_class, role, ro_q, perm, shrd,
+                                  nperm, nshrd);
     }
 }
 
diff --git a/block/commit.c b/block/commit.c
index a712662633..6d094c8cd1 100644
--- a/block/commit.c
+++ b/block/commit.c
@@ -224,6 +224,7 @@ static void bdrv_commit_top_refresh_filename(BlockDriverState *bs)
 
 static void bdrv_commit_top_child_perm(BlockDriverState *bs, BdrvChild *c,
                                        const BdrvChildClass *child_class,
+                                       BdrvChildRole role,
                                        BlockReopenQueue *reopen_queue,
                                        uint64_t perm, uint64_t shared,
                                        uint64_t *nperm, uint64_t *nshared)
diff --git a/block/copy-on-read.c b/block/copy-on-read.c
index a2c4e6dc58..a2d92ac394 100644
--- a/block/copy-on-read.c
+++ b/block/copy-on-read.c
@@ -52,6 +52,7 @@ static int cor_open(BlockDriverState *bs, QDict *options, int flags,
 
 static void cor_child_perm(BlockDriverState *bs, BdrvChild *c,
                            const BdrvChildClass *child_class,
+                           BdrvChildRole role,
                            BlockReopenQueue *reopen_queue,
                            uint64_t perm, uint64_t shared,
                            uint64_t *nperm, uint64_t *nshared)
diff --git a/block/mirror.c b/block/mirror.c
index d8506af45a..25c5e8b622 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -1485,6 +1485,7 @@ static void bdrv_mirror_top_refresh_filename(BlockDriverState *bs)
 
 static void bdrv_mirror_top_child_perm(BlockDriverState *bs, BdrvChild *c,
                                        const BdrvChildClass *child_class,
+                                       BdrvChildRole role,
                                        BlockReopenQueue *reopen_queue,
                                        uint64_t perm, uint64_t shared,
                                        uint64_t *nperm, uint64_t *nshared)
diff --git a/block/quorum.c b/block/quorum.c
index 024de76e6f..d37b77a522 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -1152,6 +1152,7 @@ static char *quorum_dirname(BlockDriverState *bs, Error **errp)
 
 static void quorum_child_perm(BlockDriverState *bs, BdrvChild *c,
                               const BdrvChildClass *child_class,
+                              BdrvChildRole role,
                               BlockReopenQueue *reopen_queue,
                               uint64_t perm, uint64_t shared,
                               uint64_t *nperm, uint64_t *nshared)
diff --git a/block/replication.c b/block/replication.c
index c05df1bc16..9ca5c9368e 100644
--- a/block/replication.c
+++ b/block/replication.c
@@ -161,6 +161,7 @@ static void replication_close(BlockDriverState *bs)
 
 static void replication_child_perm(BlockDriverState *bs, BdrvChild *c,
                                    const BdrvChildClass *child_class,
+                                   BdrvChildRole role,
                                    BlockReopenQueue *reopen_queue,
                                    uint64_t perm, uint64_t shared,
                                    uint64_t *nperm, uint64_t *nshared)
diff --git a/block/vvfat.c b/block/vvfat.c
index 022462d9c9..8e56513604 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -3213,6 +3213,7 @@ err:
 
 static void vvfat_child_perm(BlockDriverState *bs, BdrvChild *c,
                              const BdrvChildClass *child_class,
+                             BdrvChildRole role,
                              BlockReopenQueue *reopen_queue,
                              uint64_t perm, uint64_t shared,
                              uint64_t *nperm, uint64_t *nshared)
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 0f51ff8f5a..826d1bf6bd 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -556,7 +556,7 @@ struct BlockDriver {
      * the parents in @parent_perm and @parent_shared.
      *
      * If @c is NULL, return the permissions for attaching a new child for the
-     * given @child_class.
+     * given @child_class and @role.
      *
      * If @reopen_queue is non-NULL, don't return the currently needed
      * permissions, but those that will be needed after applying the
@@ -564,6 +564,7 @@ struct BlockDriver {
      */
      void (*bdrv_child_perm)(BlockDriverState *bs, BdrvChild *c,
                              const BdrvChildClass *child_class,
+                             BdrvChildRole role,
                              BlockReopenQueue *reopen_queue,
                              uint64_t parent_perm, uint64_t parent_shared,
                              uint64_t *nperm, uint64_t *nshared);
@@ -1257,6 +1258,7 @@ int bdrv_child_refresh_perms(BlockDriverState *bs, BdrvChild *c, Error **errp);
  * all children */
 void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c,
                                const BdrvChildClass *child_class,
+                               BdrvChildRole child_role,
                                BlockReopenQueue *reopen_queue,
                                uint64_t perm, uint64_t shared,
                                uint64_t *nperm, uint64_t *nshared);
@@ -1267,6 +1269,7 @@ void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c,
  * CONSISTENT_READ and doesn't share WRITE. */
 void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c,
                                const BdrvChildClass *child_class,
+                               BdrvChildRole child_role,
                                BlockReopenQueue *reopen_queue,
                                uint64_t perm, uint64_t shared,
                                uint64_t *nperm, uint64_t *nshared);
diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c
index c03705ea37..b3d7960bd0 100644
--- a/tests/test-bdrv-drain.c
+++ b/tests/test-bdrv-drain.c
@@ -87,6 +87,7 @@ static int coroutine_fn bdrv_test_co_preadv(BlockDriverState *bs,
 
 static void bdrv_test_child_perm(BlockDriverState *bs, BdrvChild *c,
                                  const BdrvChildClass *child_class,
+                                 BdrvChildRole role,
                                  BlockReopenQueue *reopen_queue,
                                  uint64_t perm, uint64_t shared,
                                  uint64_t *nperm, uint64_t *nshared)
@@ -99,8 +100,8 @@ static void bdrv_test_child_perm(BlockDriverState *bs, BdrvChild *c,
         child_class = &child_file;
     }
 
-    bdrv_format_default_perms(bs, c, child_class, reopen_queue, perm, shared,
-                              nperm, nshared);
+    bdrv_format_default_perms(bs, c, child_class, role, reopen_queue,
+                              perm, shared, nperm, nshared);
 }
 
 static int bdrv_test_change_backing_file(BlockDriverState *bs,
diff --git a/tests/test-bdrv-graph-mod.c b/tests/test-bdrv-graph-mod.c
index 8b8c186c9f..3707e2533c 100644
--- a/tests/test-bdrv-graph-mod.c
+++ b/tests/test-bdrv-graph-mod.c
@@ -31,6 +31,7 @@ static BlockDriver bdrv_pass_through = {
 
 static void no_perm_default_perms(BlockDriverState *bs, BdrvChild *c,
                                          const BdrvChildClass *child_class,
+                                         BdrvChildRole role,
                                          BlockReopenQueue *reopen_queue,
                                          uint64_t perm, uint64_t shared,
                                          uint64_t *nperm, uint64_t *nshared)
-- 
2.24.1



  parent reply	other threads:[~2020-02-18 12:44 UTC|newest]

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

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