[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 17/21] block: Remove children options from bs->{optio
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 17/21] block: Remove children options from bs->{options, explicit_options} |
Date: |
Wed, 15 Aug 2018 14:55:33 +0200 |
From: Alberto Garcia <address@hidden>
When bdrv_open_inherit() opens a BlockDriverState the options QDict
can contain options for some of its children, passed in the form of
child-name.option=value
So while each child is opened with that subset of options, those same
options remain stored in the parent BDS, leaving (at least) two copies
of each one of them ("child-name.option=value" in the parent and
"option=value" in the child).
Having the children options stored in the parent is unnecessary and it
can easily lead to an inconsistent state:
$ qemu-img create -f qcow2 hd0.qcow2 10M
$ qemu-img create -f qcow2 -b hd0.qcow2 hd1.qcow2
$ qemu-img create -f qcow2 -b hd1.qcow2 hd2.qcow2
$ $QEMU -drive file=hd2.qcow2,node-name=hd2,backing.node-name=hd1
This opens a chain of images hd0 <- hd1 <- hd2. Now let's remove hd1
using block_stream:
(qemu) block_stream hd2 0 hd0.qcow2
After this hd2 contains backing.node-name=hd1, which is no longer
correct because hd1 doesn't exist anymore.
This patch removes all children options from the parent dictionaries
at the end of bdrv_open_inherit() and bdrv_reopen_queue_child().
Signed-off-by: Alberto Garcia <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/block.c b/block.c
index 9694018a68..a8fbab396d 100644
--- a/block.c
+++ b/block.c
@@ -2584,6 +2584,7 @@ static BlockDriverState *bdrv_open_inherit(const char
*filename,
BlockBackend *file = NULL;
BlockDriverState *bs;
BlockDriver *drv = NULL;
+ BdrvChild *child;
const char *drvname;
const char *backing;
Error *local_err = NULL;
@@ -2767,6 +2768,15 @@ static BlockDriverState *bdrv_open_inherit(const char
*filename,
}
}
+ /* Remove all children options from bs->options and bs->explicit_options */
+ QLIST_FOREACH(child, &bs->children, next) {
+ char *child_key_dot;
+ child_key_dot = g_strdup_printf("%s.", child->name);
+ qdict_extract_subqdict(bs->explicit_options, NULL, child_key_dot);
+ qdict_extract_subqdict(bs->options, NULL, child_key_dot);
+ g_free(child_key_dot);
+ }
+
bdrv_refresh_filename(bs);
/* Check if any unknown options were used */
@@ -2976,6 +2986,7 @@ static BlockReopenQueue
*bdrv_reopen_queue_child(BlockReopenQueue *bs_queue,
}
child_key_dot = g_strdup_printf("%s.", child->name);
+ qdict_extract_subqdict(explicit_options, NULL, child_key_dot);
qdict_extract_subqdict(options, &new_child_options, child_key_dot);
g_free(child_key_dot);
--
2.13.6
- [Qemu-devel] [PULL 01/21] block/qapi: Fix memory leak in qmp_query_blockstats(), (continued)
- [Qemu-devel] [PULL 01/21] block/qapi: Fix memory leak in qmp_query_blockstats(), Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 06/21] luks: Allow share-rw=on, Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 02/21] qemu-iotests: Test removing a throttle group member with a pending timer, Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 04/21] qemu-iotests: Update 093 to improve the draining test, Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 05/21] throttle-groups: Don't allow timers without throttled requests, Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 07/21] block: Remove deprecated -drive geometry options, Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 15/21] block: drop empty .bdrv_close handlers, Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 13/21] qemu-img: fix regression copying secrets during convert, Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 11/21] qapi/block: Document restrictions for node names, Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 09/21] block: Remove deprecated -drive option serial, Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 17/21] block: Remove children options from bs->{options, explicit_options},
Kevin Wolf <=
- [Qemu-devel] [PULL 12/21] mirror: Fail gracefully for source == target, Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 21/21] qapi: block: Remove mentions of error types which were removed, Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 10/21] block: Remove dead deprecation warning code, Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 20/21] block: Simplify append_open_options(), Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 19/21] block: Update bs->options if bdrv_reopen() succeeds, Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 14/21] block: make .bdrv_close optional, Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 18/21] block: Simplify bdrv_reopen_abort(), Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 16/21] qdict: Make qdict_extract_subqdict() accept dst = NULL, Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 08/21] block: Remove deprecated -drive option addr, Kevin Wolf, 2018/08/15
- Re: [Qemu-devel] [PULL 00/21] Block layer patches, Peter Maydell, 2018/08/16