[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 02/21] block: Fix reopen with semantically overla
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH v3 02/21] block: Fix reopen with semantically overlapping options |
Date: |
Fri, 4 Dec 2015 14:35:05 +0100 |
This fixes bdrv_reopen() calls like the following one:
qemu-io -c 'open -o overlap-check.template=all /tmp/test.qcow2' \
-c 'reopen -o overlap-check=none'
The approach taken so far would result in an options QDict that has both
"overlap-check.template=all" and "overlap-check=none", which obviously
conflicts. In this case, the old option should be overridden by the
newly specified option.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Reviewed-by: Alberto Garcia <address@hidden>
---
block.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/block.c b/block.c
index 3a7324b..675e5a8 100644
--- a/block.c
+++ b/block.c
@@ -624,6 +624,20 @@ static int refresh_total_sectors(BlockDriverState *bs,
int64_t hint)
}
/**
+ * Combines a QDict of new block driver @options with any missing options taken
+ * from @old_options, so that leaving out an option defaults to its old value.
+ */
+static void bdrv_join_options(BlockDriverState *bs, QDict *options,
+ QDict *old_options)
+{
+ if (bs->drv && bs->drv->bdrv_join_options) {
+ bs->drv->bdrv_join_options(options, old_options);
+ } else {
+ qdict_join(options, old_options, false);
+ }
+}
+
+/**
* Set open flags for a given discard mode
*
* Return 0 on success, -1 if the discard mode was invalid.
@@ -1663,7 +1677,7 @@ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue
*bs_queue,
}
old_options = qdict_clone_shallow(bs->options);
- qdict_join(options, old_options, false);
+ bdrv_join_options(bs, options, old_options);
QDECREF(old_options);
/* bdrv_open() masks this flag out */
--
1.8.3.1
- [Qemu-devel] [PATCH v3 00/21] block: Cache mode for children etc., Kevin Wolf, 2015/12/04
- [Qemu-devel] [PATCH v3 02/21] block: Fix reopen with semantically overlapping options,
Kevin Wolf <=
- [Qemu-devel] [PATCH v3 01/21] qcow2: Add .bdrv_join_options callback, Kevin Wolf, 2015/12/04
- [Qemu-devel] [PATCH v3 03/21] mirror: Error out when a BDS would get two BBs, Kevin Wolf, 2015/12/04
- [Qemu-devel] [PATCH v3 06/21] block: Exclude nested options only for children in append_open_options(), Kevin Wolf, 2015/12/04
- [Qemu-devel] [PATCH v3 04/21] block: Allow references for backing files, Kevin Wolf, 2015/12/04
- [Qemu-devel] [PATCH v3 07/21] block: Pass driver-specific options to .bdrv_refresh_filename(), Kevin Wolf, 2015/12/04
- [Qemu-devel] [PATCH v3 05/21] block: Consider all block layer options in append_open_options, Kevin Wolf, 2015/12/04
- [Qemu-devel] [PATCH v3 09/21] block: Allow specifying child options in reopen, Kevin Wolf, 2015/12/04
- [Qemu-devel] [PATCH v3 08/21] block: Keep "driver" in bs->options, Kevin Wolf, 2015/12/04