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 04/33] block: Add BdrvChildRole to BdrvChild
Date: Tue, 18 Feb 2020 13:42:13 +0100	[thread overview]
Message-ID: <20200218124242.584644-5-mreitz@redhat.com> (raw)
In-Reply-To: <20200218124242.584644-1-mreitz@redhat.com>

For now, it is always set to 0.  Later patches in this series will
ensure that all callers pass an appropriate combination of flags.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block.c                     | 11 ++++++++---
 block/backup-top.c          |  3 ++-
 block/blkdebug.c            |  2 +-
 block/blklogwrites.c        |  6 +++---
 block/blkreplay.c           |  2 +-
 block/blkverify.c           |  4 ++--
 block/block-backend.c       |  4 ++--
 block/bochs.c               |  2 +-
 block/cloop.c               |  2 +-
 block/copy-on-read.c        |  2 +-
 block/crypto.c              |  2 +-
 block/dmg.c                 |  2 +-
 block/filter-compress.c     |  2 +-
 block/parallels.c           |  2 +-
 block/qcow.c                |  2 +-
 block/qcow2.c               |  6 +++---
 block/qed.c                 |  2 +-
 block/quorum.c              |  4 ++--
 block/raw-format.c          |  2 +-
 block/replication.c         |  2 +-
 block/throttle.c            |  2 +-
 block/vdi.c                 |  2 +-
 block/vhdx.c                |  2 +-
 block/vmdk.c                |  4 ++--
 block/vpc.c                 |  2 +-
 block/vvfat.c               |  2 +-
 blockjob.c                  |  5 +++--
 include/block/block.h       |  2 ++
 include/block/block_int.h   |  2 ++
 tests/test-bdrv-drain.c     | 20 +++++++++++---------
 tests/test-bdrv-graph-mod.c |  4 ++--
 31 files changed, 62 insertions(+), 49 deletions(-)

diff --git a/block.c b/block.c
index a1326e956f..e8ddf1689e 100644
--- a/block.c
+++ b/block.c
@@ -2403,6 +2403,7 @@ static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs)
 BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs,
                                   const char *child_name,
                                   const BdrvChildClass *child_class,
+                                  BdrvChildRole child_role,
                                   AioContext *ctx,
                                   uint64_t perm, uint64_t shared_perm,
                                   void *opaque, Error **errp)
@@ -2424,6 +2425,7 @@ BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs,
         .bs             = NULL,
         .name           = g_strdup(child_name),
         .klass          = child_class,
+        .role           = child_role,
         .perm           = perm,
         .shared_perm    = shared_perm,
         .opaque         = opaque,
@@ -2475,6 +2477,7 @@ BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs,
                              BlockDriverState *child_bs,
                              const char *child_name,
                              const BdrvChildClass *child_class,
+                             BdrvChildRole child_role,
                              Error **errp)
 {
     BdrvChild *child;
@@ -2487,7 +2490,7 @@ BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs,
                     perm, shared_perm, &perm, &shared_perm);
 
     child = bdrv_root_attach_child(child_bs, child_name, child_class,
-                                   bdrv_get_aio_context(parent_bs),
+                                   child_role, bdrv_get_aio_context(parent_bs),
                                    perm, shared_perm, parent_bs, errp);
     if (child == NULL) {
         return NULL;
@@ -2608,7 +2611,7 @@ void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd,
     }
 
     bs->backing = bdrv_attach_child(bs, backing_hd, "backing", &child_backing,
-                                    errp);
+                                    0, errp);
     /* If backing_hd was already part of bs's backing chain, and
      * inherits_from pointed recursively to bs then let's update it to
      * point directly to bs (else it will become NULL). */
@@ -2799,6 +2802,7 @@ BdrvChild *bdrv_open_child(const char *filename,
                            QDict *options, const char *bdref_key,
                            BlockDriverState *parent,
                            const BdrvChildClass *child_class,
+                           BdrvChildRole child_role,
                            bool allow_none, Error **errp)
 {
     BlockDriverState *bs;
@@ -2809,7 +2813,8 @@ BdrvChild *bdrv_open_child(const char *filename,
         return NULL;
     }
 
-    return bdrv_attach_child(parent, bs, bdref_key, child_class, errp);
+    return bdrv_attach_child(parent, bs, bdref_key, child_class, child_role,
+                             errp);
 }
 
 /*
diff --git a/block/backup-top.c b/block/backup-top.c
index 2d232828ff..b13d459e86 100644
--- a/block/backup-top.c
+++ b/block/backup-top.c
@@ -209,7 +209,8 @@ BlockDriverState *bdrv_backup_top_append(BlockDriverState *source,
              source->supported_zero_flags);
 
     bdrv_ref(target);
-    state->target = bdrv_attach_child(top, target, "target", &child_file, errp);
+    state->target = bdrv_attach_child(top, target, "target", &child_file, 0,
+                                      errp);
     if (!state->target) {
         bdrv_unref(target);
         bdrv_unref(top);
diff --git a/block/blkdebug.c b/block/blkdebug.c
index f369d54ee4..c91e78d5c8 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -497,7 +497,7 @@ 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, false, &local_err);
+                               bs, &child_file, 0, false, &local_err);
     if (local_err) {
         ret = -EINVAL;
         error_propagate(errp, local_err);
diff --git a/block/blklogwrites.c b/block/blklogwrites.c
index f3b3259d8d..739db6dcf6 100644
--- a/block/blklogwrites.c
+++ b/block/blklogwrites.c
@@ -157,7 +157,7 @@ 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, false,
+    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0, false,
                                &local_err);
     if (local_err) {
         ret = -EINVAL;
@@ -166,8 +166,8 @@ static int blk_log_writes_open(BlockDriverState *bs, QDict *options, int flags,
     }
 
     /* Open the log file */
-    s->log_file = bdrv_open_child(NULL, options, "log", bs, &child_file, false,
-                                  &local_err);
+    s->log_file = bdrv_open_child(NULL, options, "log", bs, &child_file, 0,
+                                  false, &local_err);
     if (local_err) {
         ret = -EINVAL;
         error_propagate(errp, local_err);
diff --git a/block/blkreplay.c b/block/blkreplay.c
index c96ac8f4bc..f97493f45a 100644
--- a/block/blkreplay.c
+++ b/block/blkreplay.c
@@ -28,7 +28,7 @@ static int blkreplay_open(BlockDriverState *bs, QDict *options, int flags,
 
     /* Open the image file */
     bs->file = bdrv_open_child(NULL, options, "image",
-                               bs, &child_file, false, &local_err);
+                               bs, &child_file, 0, false, &local_err);
     if (local_err) {
         ret = -EINVAL;
         error_propagate(errp, local_err);
diff --git a/block/blkverify.c b/block/blkverify.c
index ba6b1853ae..ba4f6d7b7c 100644
--- a/block/blkverify.c
+++ b/block/blkverify.c
@@ -125,7 +125,7 @@ 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, false, &local_err);
+                               bs, &child_file, 0, false, &local_err);
     if (local_err) {
         ret = -EINVAL;
         error_propagate(errp, local_err);
@@ -134,7 +134,7 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags,
 
     /* Open the test file */
     s->test_file = bdrv_open_child(qemu_opt_get(opts, "x-image"), options,
-                                   "test", bs, &child_format, false,
+                                   "test", bs, &child_format, 0, false,
                                    &local_err);
     if (local_err) {
         ret = -EINVAL;
diff --git a/block/block-backend.c b/block/block-backend.c
index 3d7e96e0d4..4b79b2abb1 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -400,7 +400,7 @@ BlockBackend *blk_new_open(const char *filename, const char *reference,
         return NULL;
     }
 
-    blk->root = bdrv_root_attach_child(bs, "root", &child_root, blk->ctx,
+    blk->root = bdrv_root_attach_child(bs, "root", &child_root, 0, blk->ctx,
                                        perm, BLK_PERM_ALL, blk, errp);
     if (!blk->root) {
         blk_unref(blk);
@@ -811,7 +811,7 @@ int blk_insert_bs(BlockBackend *blk, BlockDriverState *bs, Error **errp)
 {
     ThrottleGroupMember *tgm = &blk->public.throttle_group_member;
     bdrv_ref(bs);
-    blk->root = bdrv_root_attach_child(bs, "root", &child_root, blk->ctx,
+    blk->root = bdrv_root_attach_child(bs, "root", &child_root, 0, blk->ctx,
                                        blk->perm, blk->shared_perm, blk, errp);
     if (blk->root == NULL) {
         return -EPERM;
diff --git a/block/bochs.c b/block/bochs.c
index e7bbeaa1c4..b013e73063 100644
--- a/block/bochs.c
+++ b/block/bochs.c
@@ -110,7 +110,7 @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags,
         return ret;
     }
 
-    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
+    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
                                false, errp);
     if (!bs->file) {
         return -EINVAL;
diff --git a/block/cloop.c b/block/cloop.c
index f90f1a4b4c..3ed9fa63cc 100644
--- a/block/cloop.c
+++ b/block/cloop.c
@@ -71,7 +71,7 @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags,
         return ret;
     }
 
-    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
+    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
                                false, errp);
     if (!bs->file) {
         return -EINVAL;
diff --git a/block/copy-on-read.c b/block/copy-on-read.c
index 7504ca6ffc..a2c4e6dc58 100644
--- a/block/copy-on-read.c
+++ b/block/copy-on-read.c
@@ -28,7 +28,7 @@
 static int cor_open(BlockDriverState *bs, QDict *options, int flags,
                     Error **errp)
 {
-    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, false,
+    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0, false,
                                errp);
     if (!bs->file) {
         return -EINVAL;
diff --git a/block/crypto.c b/block/crypto.c
index b81f673a51..4da74a7737 100644
--- a/block/crypto.c
+++ b/block/crypto.c
@@ -200,7 +200,7 @@ static int block_crypto_open_generic(QCryptoBlockFormat format,
     unsigned int cflags = 0;
     QDict *cryptoopts = NULL;
 
-    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
+    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
                                false, errp);
     if (!bs->file) {
         return -EINVAL;
diff --git a/block/dmg.c b/block/dmg.c
index ef3c6e771d..af8188638c 100644
--- a/block/dmg.c
+++ b/block/dmg.c
@@ -439,7 +439,7 @@ static int dmg_open(BlockDriverState *bs, QDict *options, int flags,
         return ret;
     }
 
-    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
+    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
                                false, errp);
     if (!bs->file) {
         return -EINVAL;
diff --git a/block/filter-compress.c b/block/filter-compress.c
index 82c315b298..4dc5f9fb8c 100644
--- a/block/filter-compress.c
+++ b/block/filter-compress.c
@@ -30,7 +30,7 @@
 static int compress_open(BlockDriverState *bs, QDict *options, int flags,
                          Error **errp)
 {
-    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, false,
+    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0, false,
                                errp);
     if (!bs->file) {
         return -EINVAL;
diff --git a/block/parallels.c b/block/parallels.c
index 30eda982bd..3d5b3b7c63 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -728,7 +728,7 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
     Error *local_err = NULL;
     char *buf;
 
-    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
+    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
                                false, errp);
     if (!bs->file) {
         return -EINVAL;
diff --git a/block/qcow.c b/block/qcow.c
index 0e4f09934c..2bf8e8eb36 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -130,7 +130,7 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
     qdict_extract_subqdict(options, &encryptopts, "encrypt.");
     encryptfmt = qdict_get_try_str(encryptopts, "format");
 
-    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
+    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
                                false, errp);
     if (!bs->file) {
         ret = -EINVAL;
diff --git a/block/qcow2.c b/block/qcow2.c
index 875eb7d5d9..2ce974df4d 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1538,7 +1538,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
 
     /* Open external data file */
     s->data_file = bdrv_open_child(NULL, options, "data-file", bs, &child_file,
-                                   true, &local_err);
+                                   0, true, &local_err);
     if (local_err) {
         error_propagate(errp, local_err);
         ret = -EINVAL;
@@ -1548,7 +1548,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
     if (s->incompatible_features & QCOW2_INCOMPAT_DATA_FILE) {
         if (!s->data_file && s->image_data_file) {
             s->data_file = bdrv_open_child(s->image_data_file, options,
-                                           "data-file", bs, &child_file,
+                                           "data-file", bs, &child_file, 0,
                                            false, errp);
             if (!s->data_file) {
                 ret = -EINVAL;
@@ -1808,7 +1808,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
         .ret = -EINPROGRESS
     };
 
-    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
+    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
                                false, errp);
     if (!bs->file) {
         return -EINVAL;
diff --git a/block/qed.c b/block/qed.c
index eb6139acbc..d15ba11959 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -547,7 +547,7 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags,
         .ret = -EINPROGRESS
     };
 
-    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
+    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
                                false, errp);
     if (!bs->file) {
         return -EINVAL;
diff --git a/block/quorum.c b/block/quorum.c
index a0824c300d..024de76e6f 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -977,7 +977,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
         assert(ret < 32);
 
         s->children[i] = bdrv_open_child(NULL, options, indexstr, bs,
-                                         &child_format, false, &local_err);
+                                         &child_format, 0, false, &local_err);
         if (local_err) {
             ret = -EINVAL;
             goto close_exit;
@@ -1053,7 +1053,7 @@ static void quorum_add_child(BlockDriverState *bs, BlockDriverState *child_bs,
     /* We can safely add the child now */
     bdrv_ref(child_bs);
 
-    child = bdrv_attach_child(bs, child_bs, indexstr, &child_format, errp);
+    child = bdrv_attach_child(bs, child_bs, indexstr, &child_format, 0, errp);
     if (child == NULL) {
         s->next_child_index--;
         goto out;
diff --git a/block/raw-format.c b/block/raw-format.c
index 2429ff0d23..b600dae209 100644
--- a/block/raw-format.c
+++ b/block/raw-format.c
@@ -431,7 +431,7 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
     BDRVRawState *s = bs->opaque;
     int ret;
 
-    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
+    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
                                false, errp);
     if (!bs->file) {
         return -EINVAL;
diff --git a/block/replication.c b/block/replication.c
index e268a6e5c5..c05df1bc16 100644
--- a/block/replication.c
+++ b/block/replication.c
@@ -90,7 +90,7 @@ 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,
+    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
                                false, errp);
     if (!bs->file) {
         return -EINVAL;
diff --git a/block/throttle.c b/block/throttle.c
index 71f4bb0ad1..2dea913be7 100644
--- a/block/throttle.c
+++ b/block/throttle.c
@@ -82,7 +82,7 @@ static int throttle_open(BlockDriverState *bs, QDict *options,
     int ret;
 
     bs->file = bdrv_open_child(NULL, options, "file", bs,
-                               &child_file, false, errp);
+                               &child_file, 0, false, errp);
     if (!bs->file) {
         return -EINVAL;
     }
diff --git a/block/vdi.c b/block/vdi.c
index 7e87b205b5..987e2ed592 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -378,7 +378,7 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
     Error *local_err = NULL;
     QemuUUID uuid_link, uuid_parent;
 
-    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
+    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
                                false, errp);
     if (!bs->file) {
         return -EINVAL;
diff --git a/block/vhdx.c b/block/vhdx.c
index d3c1619026..be23290ac8 100644
--- a/block/vhdx.c
+++ b/block/vhdx.c
@@ -997,7 +997,7 @@ static int vhdx_open(BlockDriverState *bs, QDict *options, int flags,
     uint64_t signature;
     Error *local_err = NULL;
 
-    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
+    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
                                false, errp);
     if (!bs->file) {
         return -EINVAL;
diff --git a/block/vmdk.c b/block/vmdk.c
index 631fcd15ab..84f99d881f 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -1152,7 +1152,7 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
         assert(ret < 32);
 
         extent_file = bdrv_open_child(extent_path, options, extent_opt_prefix,
-                                      bs, &child_file, false, &local_err);
+                                      bs, &child_file, 0, false, &local_err);
         g_free(extent_path);
         if (local_err) {
             error_propagate(errp, local_err);
@@ -1257,7 +1257,7 @@ static int vmdk_open(BlockDriverState *bs, QDict *options, int flags,
     uint32_t magic;
     Error *local_err = NULL;
 
-    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
+    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
                                false, errp);
     if (!bs->file) {
         return -EINVAL;
diff --git a/block/vpc.c b/block/vpc.c
index 7cf0f87a16..5378e32d1d 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -228,7 +228,7 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags,
     int ret;
     int64_t bs_size;
 
-    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
+    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
                                false, errp);
     if (!bs->file) {
         return -EINVAL;
diff --git a/block/vvfat.c b/block/vvfat.c
index d41bdfc934..022462d9c9 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -3185,7 +3185,7 @@ static int enable_write_target(BlockDriverState *bs, Error **errp)
     options = qdict_new();
     qdict_put_str(options, "write-target.driver", "qcow");
     s->qcow = bdrv_open_child(s->qcow_filename, options, "write-target", bs,
-                              &child_vvfat_qcow, false, errp);
+                              &child_vvfat_qcow, 0, false, errp);
     qobject_unref(options);
     if (!s->qcow) {
         ret = -EINVAL;
diff --git a/blockjob.c b/blockjob.c
index 79f303822b..533ef0af30 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -217,8 +217,9 @@ int block_job_add_bdrv(BlockJob *job, const char *name, BlockDriverState *bs,
     if (job->job.aio_context != qemu_get_aio_context()) {
         aio_context_release(job->job.aio_context);
     }
-    c = bdrv_root_attach_child(bs, name, &child_job, job->job.aio_context,
-                               perm, shared_perm, job, errp);
+    c = bdrv_root_attach_child(bs, name, &child_job, 0,
+                               job->job.aio_context, perm, shared_perm, job,
+                               errp);
     if (job->job.aio_context != qemu_get_aio_context()) {
         aio_context_acquire(job->job.aio_context);
     }
diff --git a/include/block/block.h b/include/block/block.h
index 8c23948d08..01832ec79b 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -334,6 +334,7 @@ BdrvChild *bdrv_open_child(const char *filename,
                            QDict *options, const char *bdref_key,
                            BlockDriverState* parent,
                            const BdrvChildClass *child_class,
+                           BdrvChildRole child_role,
                            bool allow_none, Error **errp);
 BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp);
 void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd,
@@ -577,6 +578,7 @@ BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs,
                              BlockDriverState *child_bs,
                              const char *child_name,
                              const BdrvChildClass *child_class,
+                             BdrvChildRole child_role,
                              Error **errp);
 
 bool bdrv_op_is_blocked(BlockDriverState *bs, BlockOpType op, Error **errp);
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 5d54debc34..0f51ff8f5a 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -746,6 +746,7 @@ struct BdrvChild {
     BlockDriverState *bs;
     char *name;
     const BdrvChildClass *klass;
+    BdrvChildRole role;
     void *opaque;
 
     /**
@@ -1227,6 +1228,7 @@ void hmp_drive_add_node(Monitor *mon, const char *optstr);
 BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs,
                                   const char *child_name,
                                   const BdrvChildClass *child_class,
+                                  BdrvChildRole child_role,
                                   AioContext *ctx,
                                   uint64_t perm, uint64_t shared_perm,
                                   void *opaque, Error **errp);
diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c
index 9d683a6c11..c03705ea37 100644
--- a/tests/test-bdrv-drain.c
+++ b/tests/test-bdrv-drain.c
@@ -1202,7 +1202,7 @@ static void do_test_delete_by_drain(bool detach_instead_of_delete,
 
     null_bs = bdrv_open("null-co://", NULL, NULL, BDRV_O_RDWR | BDRV_O_PROTOCOL,
                         &error_abort);
-    bdrv_attach_child(bs, null_bs, "null-child", &child_file, &error_abort);
+    bdrv_attach_child(bs, null_bs, "null-child", &child_file, 0, &error_abort);
 
     /* This child will be the one to pass to requests through to, and
      * it will stall until a drain occurs */
@@ -1211,13 +1211,13 @@ static void do_test_delete_by_drain(bool detach_instead_of_delete,
     child_bs->total_sectors = 65536 >> BDRV_SECTOR_BITS;
     /* Takes our reference to child_bs */
     tts->wait_child = bdrv_attach_child(bs, child_bs, "wait-child", &child_file,
-                                        &error_abort);
+                                        0, &error_abort);
 
     /* This child is just there to be deleted
      * (for detach_instead_of_delete == true) */
     null_bs = bdrv_open("null-co://", NULL, NULL, BDRV_O_RDWR | BDRV_O_PROTOCOL,
                         &error_abort);
-    bdrv_attach_child(bs, null_bs, "null-child", &child_file, &error_abort);
+    bdrv_attach_child(bs, null_bs, "null-child", &child_file, 0, &error_abort);
 
     blk = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
     blk_insert_bs(blk, bs, &error_abort);
@@ -1314,7 +1314,7 @@ static void detach_indirect_bh(void *opaque)
 
     bdrv_ref(data->c);
     data->child_c = bdrv_attach_child(data->parent_b, data->c, "PB-C",
-                                      &child_file, &error_abort);
+                                      &child_file, 0, &error_abort);
 }
 
 static void detach_by_parent_aio_cb(void *opaque, int ret)
@@ -1396,13 +1396,15 @@ static void test_detach_indirect(bool by_parent_cb)
     /* Set child relationships */
     bdrv_ref(b);
     bdrv_ref(a);
-    child_b = bdrv_attach_child(parent_b, b, "PB-B", &child_file, &error_abort);
-    child_a = bdrv_attach_child(parent_b, a, "PB-A", &child_backing, &error_abort);
+    child_b = bdrv_attach_child(parent_b, b, "PB-B", &child_file, 0,
+                                &error_abort);
+    child_a = bdrv_attach_child(parent_b, a, "PB-A", &child_backing, 0,
+                                &error_abort);
 
     bdrv_ref(a);
     bdrv_attach_child(parent_a, a, "PA-A",
                       by_parent_cb ? &child_file : &detach_by_driver_cb_class,
-                      &error_abort);
+                      0, &error_abort);
 
     g_assert_cmpint(parent_a->refcnt, ==, 1);
     g_assert_cmpint(parent_b->refcnt, ==, 1);
@@ -1813,7 +1815,7 @@ static void test_drop_intermediate_poll(void)
             /* Takes the reference to chain[i - 1] */
             chain[i]->backing = bdrv_attach_child(chain[i], chain[i - 1],
                                                   "chain", &chain_child_class,
-                                                  &error_abort);
+                                                  0, &error_abort);
         }
     }
 
@@ -2031,7 +2033,7 @@ static void do_test_replace_child_mid_drain(int old_drain_count,
 
     bdrv_ref(old_child_bs);
     parent_bs->backing = bdrv_attach_child(parent_bs, old_child_bs, "child",
-                                           &child_backing, &error_abort);
+                                           &child_backing, 0, &error_abort);
 
     for (i = 0; i < old_drain_count; i++) {
         bdrv_drained_begin(old_child_bs);
diff --git a/tests/test-bdrv-graph-mod.c b/tests/test-bdrv-graph-mod.c
index fef42cb294..8b8c186c9f 100644
--- a/tests/test-bdrv-graph-mod.c
+++ b/tests/test-bdrv-graph-mod.c
@@ -111,7 +111,7 @@ static void test_update_perm_tree(void)
 
     blk_insert_bs(root, bs, &error_abort);
 
-    bdrv_attach_child(filter, bs, "child", &child_file, &error_abort);
+    bdrv_attach_child(filter, bs, "child", &child_file, 0, &error_abort);
 
     bdrv_append(filter, bs, &local_err);
 
@@ -177,7 +177,7 @@ static void test_should_update_child(void)
     bdrv_set_backing_hd(target, bs, &error_abort);
 
     g_assert(target->backing->bs == bs);
-    bdrv_attach_child(filter, target, "target", &child_file, &error_abort);
+    bdrv_attach_child(filter, target, "target", &child_file, 0, &error_abort);
     bdrv_append(filter, bs, &error_abort);
     g_assert(target->backing->bs == bs);
 
-- 
2.24.1



  parent reply	other threads:[~2020-02-18 12:45 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 ` Max Reitz [this message]
2020-02-18 13:06   ` [PATCH v3 04/33] block: Add BdrvChildRole to BdrvChild Eric Blake
2020-02-18 12:42 ` [PATCH v3 05/33] block: Pass BdrvChildRole to bdrv_child_perm() Max Reitz
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-5-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.