diff options
author | Kevin Wolf <kwolf@redhat.com> | 2015-04-09 18:54:04 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2015-06-12 17:04:59 +0200 |
commit | 67251a311371c4d22e803f151f47fe817175b6c3 (patch) | |
tree | 40a064d981318c605579967644878d15d5258df7 /block.c | |
parent | bddcec3745b0220d4a7eda700950812a94398668 (diff) | |
download | qemu-67251a311371c4d22e803f151f47fe817175b6c3.zip qemu-67251a311371c4d22e803f151f47fe817175b6c3.tar.gz qemu-67251a311371c4d22e803f151f47fe817175b6c3.tar.bz2 |
block: Fix reopen flag inheritance
When reopening an image, the block layer already takes care to reopen
bs->file as well with recalculated inherited flags. The same must happen
for any other child (most notably missing before this patch: backing
files).
If bs->file (or any other child) didn't originally inherit from bs, e.g.
because it was created separately and then only referenced, it must not
inherit flags on reopen either, so check the inherited_from field before
propagation the reopen down.
VMDK already reopened its extents manually; this code can now be
dropped.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r-- | block.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -1615,6 +1615,8 @@ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue, assert(bs != NULL); BlockReopenQueueEntry *bs_entry; + BdrvChild *child; + if (bs_queue == NULL) { bs_queue = g_new0(BlockReopenQueue, 1); QSIMPLEQ_INIT(bs_queue); @@ -1623,8 +1625,15 @@ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue, /* bdrv_open() masks this flag out */ flags &= ~BDRV_O_PROTOCOL; - if (bs->file) { - bdrv_reopen_queue(bs_queue, bs->file, bdrv_inherited_flags(flags)); + QLIST_FOREACH(child, &bs->children, next) { + int child_flags; + + if (child->bs->inherits_from != bs) { + continue; + } + + child_flags = child->role->inherit_flags(flags); + bdrv_reopen_queue(bs_queue, child->bs, child_flags); } bs_entry = g_new0(BlockReopenQueueEntry, 1); |