aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
Diffstat (limited to 'block.c')
-rw-r--r--block.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/block.c b/block.c
index fe0cdc7d99..5ba3435f8f 100644
--- a/block.c
+++ b/block.c
@@ -3855,6 +3855,8 @@ BlockDriverState *bdrv_find_base(BlockDriverState *bs)
int bdrv_drop_intermediate(BlockDriverState *top, BlockDriverState *base,
const char *backing_file_str)
{
+ BlockDriverState *explicit_top = top;
+ bool update_inherits_from;
BdrvChild *c, *next;
Error *local_err = NULL;
int ret = -EIO;
@@ -3870,6 +3872,16 @@ int bdrv_drop_intermediate(BlockDriverState *top, BlockDriverState *base,
goto exit;
}
+ /* If 'base' recursively inherits from 'top' then we should set
+ * base->inherits_from to top->inherits_from after 'top' and all
+ * other intermediate nodes have been dropped.
+ * If 'top' is an implicit node (e.g. "commit_top") we should skip
+ * it because no one inherits from it. We use explicit_top for that. */
+ while (explicit_top && explicit_top->implicit) {
+ explicit_top = backing_bs(explicit_top);
+ }
+ update_inherits_from = bdrv_inherits_from_recursive(base, explicit_top);
+
/* success - we can delete the intermediate states, and link top->base */
/* TODO Check graph modification op blockers (BLK_PERM_GRAPH_MOD) once
* we've figured out how they should work. */
@@ -3905,6 +3917,10 @@ int bdrv_drop_intermediate(BlockDriverState *top, BlockDriverState *base,
bdrv_unref(top);
}
+ if (update_inherits_from) {
+ base->inherits_from = explicit_top->inherits_from;
+ }
+
ret = 0;
exit:
bdrv_unref(top);