qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-block] [PATCH v2 1/3] block: Allow replacement of a BDS by its ove


From: Max Reitz
Subject: [Qemu-block] [PATCH v2 1/3] block: Allow replacement of a BDS by its overlay
Date: Mon, 6 Jun 2016 16:42:10 +0200

change_parent_backing_link() asserts that the BDS to be replaced is not
used as a backing file. However, we may want to replace a BDS by its
overlay in which case that very link should not be redirected.

Signed-off-by: Max Reitz <address@hidden>
---
 block.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/block.c b/block.c
index f54bc25..16463aa 100644
--- a/block.c
+++ b/block.c
@@ -2224,9 +2224,22 @@ void bdrv_close_all(void)
 static void change_parent_backing_link(BlockDriverState *from,
                                        BlockDriverState *to)
 {
-    BdrvChild *c, *next;
+    BdrvChild *c, *next, *to_c;
 
     QLIST_FOREACH_SAFE(c, &from->parents, next_parent, next) {
+        if (c->role == &child_backing) {
+            /* Allow @from to be in a backing chain, but only if it is @to's
+             * backing chain. Do not replace @from by @to there. */
+            QLIST_FOREACH(to_c, &to->children, next) {
+                if (to_c == c) {
+                    break;
+                }
+            }
+            if (to_c) {
+                continue;
+            }
+        }
+
         assert(c->role != &child_backing);
         bdrv_ref(to);
         bdrv_replace_child(c, to);
-- 
2.8.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]