block: Add BdrvChildRole.stay_at_node
authorKevin Wolf <kwolf@redhat.com>
Tue, 17 Jan 2017 12:39:34 +0000 (13:39 +0100)
committerKevin Wolf <kwolf@redhat.com>
Tue, 28 Feb 2017 19:40:37 +0000 (20:40 +0100)
When the parents' child links are updated in bdrv_append() or
bdrv_replace_in_backing_chain(), this should affect all child links of
BlockBackends or other nodes, but not on child links held for other
purposes (like for setting permissions). This patch allows to control
the behaviour per BdrvChildRole.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Acked-by: Fam Zheng <famz@redhat.com>
block.c
include/block/block_int.h

diff --git a/block.c b/block.c
index f72a67f230ba9b33aaa13474a7d012b113c3a58f..9e538a5d4101b3e611f80d87cfdab122788e4a5c 100644 (file)
--- a/block.c
+++ b/block.c
@@ -2853,6 +2853,9 @@ static void change_parent_backing_link(BlockDriverState *from,
     BdrvChild *c, *next, *to_c;
 
     QLIST_FOREACH_SAFE(c, &from->parents, next_parent, next) {
+        if (c->role->stay_at_node) {
+            continue;
+        }
         if (c->role == &child_backing) {
             /* @from is generally not allowed to be a backing file, except for
              * when @to is the overlay. In that case, @from may not be replaced
index 3177b9f4961d98f9ece7ad3ed25f464840cbf532..a0d9328b59de4eec1c23a34a202bbc19c521562d 100644 (file)
@@ -441,6 +441,10 @@ typedef struct BdrvAioNotifier {
 } BdrvAioNotifier;
 
 struct BdrvChildRole {
+    /* If true, bdrv_replace_in_backing_chain() doesn't change the node this
+     * BdrvChild points to. */
+    bool stay_at_node;
+
     void (*inherit_options)(int *child_flags, QDict *child_options,
                             int parent_flags, QDict *parent_options);