[PATCH for-5.0 05/31] block: Drop BdrvChildClass.stay_at_node

Max Reitz posted 31 patches 6 years, 2 months ago
Maintainers: Kevin Wolf <kwolf@redhat.com>, John Snow <jsnow@redhat.com>, Alberto Garcia <berto@igalia.com>, Jeff Cody <codyprime@gmail.com>, Stefan Weil <sw@weilnetz.de>, "Denis V. Lunev" <den@openvz.org>, Xie Changlong <xiechanglong.d@gmail.com>, Wen Congyang <wencongyang2@huawei.com>, Fam Zheng <fam@euphon.net>, Paolo Bonzini <pbonzini@redhat.com>, Ari Sundholm <ari@tuxera.com>, Stefan Hajnoczi <stefanha@redhat.com>, Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>, Max Reitz <mreitz@redhat.com>
There is a newer version of this series
[PATCH for-5.0 05/31] block: Drop BdrvChildClass.stay_at_node
Posted by Max Reitz 6 years, 2 months ago
This should better be in BdrvChildRole so that parents can decide when
to and when not to keep the child node fixed.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block.c                   | 2 +-
 blockjob.c                | 3 +--
 include/block/block_int.h | 4 ----
 3 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/block.c b/block.c
index 90974ae36b..6c50ad661e 100644
--- a/block.c
+++ b/block.c
@@ -4103,7 +4103,7 @@ static bool should_update_child(BdrvChild *c, BlockDriverState *to)
     GHashTable *found;
     bool ret;
 
-    if (c->klass->stay_at_node) {
+    if (c->role & BDRV_CHILD_STAY_AT_NODE) {
         return false;
     }
 
diff --git a/blockjob.c b/blockjob.c
index e7dbb4093a..f58356fb6c 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -170,7 +170,6 @@ static const BdrvChildClass child_job = {
     .drained_end        = child_job_drained_end,
     .can_set_aio_ctx    = child_job_can_set_aio_ctx,
     .set_aio_ctx        = child_job_set_aio_ctx,
-    .stay_at_node       = true,
 };
 
 void block_job_remove_all_bdrv(BlockJob *job)
@@ -217,7 +216,7 @@ 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, 0,
+    c = bdrv_root_attach_child(bs, name, &child_job, BDRV_CHILD_STAY_AT_NODE,
                                job->job.aio_context, perm, shared_perm, job,
                                errp);
     if (job->job.aio_context != qemu_get_aio_context()) {
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 85cfa4b069..102ce7853e 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -660,10 +660,6 @@ typedef struct BdrvAioNotifier {
 } BdrvAioNotifier;
 
 struct BdrvChildClass {
-    /* If true, bdrv_replace_node() doesn't change the node this BdrvChild
-     * points to. */
-    bool stay_at_node;
-
     /* If true, the parent is a BlockDriverState and bdrv_next_all_states()
      * will return it. This information is used for drain_all, where every node
      * will be drained separately, so the drain only needs to be propagated to
-- 
2.23.0