[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 25/25] block: Fix reopen flag inheritance
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 25/25] block: Fix reopen flag inheritance |
Date: |
Fri, 12 Jun 2015 18:23:34 +0200 |
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 <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
block.c | 13 +++++++++++--
block/vmdk.c | 28 ++--------------------------
2 files changed, 13 insertions(+), 28 deletions(-)
diff --git a/block.c b/block.c
index 58d12c0..777753c 100644
--- a/block.c
+++ b/block.c
@@ -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);
diff --git a/block/vmdk.c b/block/vmdk.c
index 3284bec..be9263a 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -321,37 +321,13 @@ static int vmdk_is_cid_valid(BlockDriverState *bs)
return 1;
}
-/* Queue extents, if any, for reopen() */
+/* We have nothing to do for VMDK reopen, stubs just return success */
static int vmdk_reopen_prepare(BDRVReopenState *state,
BlockReopenQueue *queue, Error **errp)
{
- BDRVVmdkState *s;
- int ret = -1;
- int i;
- VmdkExtent *e;
-
assert(state != NULL);
assert(state->bs != NULL);
-
- if (queue == NULL) {
- error_setg(errp, "No reopen queue for VMDK extents");
- goto exit;
- }
-
- s = state->bs->opaque;
-
- assert(s != NULL);
-
- for (i = 0; i < s->num_extents; i++) {
- e = &s->extents[i];
- if (e->file != state->bs->file) {
- bdrv_reopen_queue(queue, e->file, state->flags);
- }
- }
- ret = 0;
-
-exit:
- return ret;
+ return 0;
}
static int vmdk_parent_open(BlockDriverState *bs)
--
1.8.3.1
- [Qemu-block] [PULL 15/25] check-qdict: Test cases for new functions, (continued)
- [Qemu-block] [PULL 15/25] check-qdict: Test cases for new functions, Kevin Wolf, 2015/06/12
- [Qemu-block] [PULL 16/25] quorum: Use bdrv_open_image(), Kevin Wolf, 2015/06/12
- [Qemu-block] [PULL 19/25] block: Use QemuOpts in bdrv_open_common(), Kevin Wolf, 2015/06/12
- [Qemu-block] [PULL 18/25] block: Use macro for cache option names, Kevin Wolf, 2015/06/12
- [Qemu-block] [PULL 21/25] block: Drain requests before swapping nodes in bdrv_swap(), Kevin Wolf, 2015/06/12
- [Qemu-block] [PULL 17/25] vmdk: Use bdrv_open_image(), Kevin Wolf, 2015/06/12
- [Qemu-block] [PULL 22/25] queue.h: Add QLIST_FIX_HEAD_PTR(), Kevin Wolf, 2015/06/12
- [Qemu-block] [PULL 20/25] block: Move flag inheritance to bdrv_open_inherit(), Kevin Wolf, 2015/06/12
- [Qemu-block] [PULL 23/25] block: Add list of children to BlockDriverState, Kevin Wolf, 2015/06/12
- [Qemu-block] [PULL 24/25] block: Add BlockDriverState.inherits_from, Kevin Wolf, 2015/06/12
- [Qemu-block] [PULL 25/25] block: Fix reopen flag inheritance,
Kevin Wolf <=
- Re: [Qemu-block] [Qemu-devel] [PULL 00/25] Block layer core and image format patches, Peter Maydell, 2015/06/15