[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 13/48] block: reopen: Document option precedence and
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 13/48] block: reopen: Document option precedence and refactor accordingly |
Date: |
Fri, 18 Dec 2015 16:07:19 +0100 |
The interesting part of reopening an image is from which sources the
effective options should be taken, i.e. which options take precedence
over which other options. This patch documents the precedence that will
be implemented in the following patches.
It also refactors bdrv_reopen_queue(), so that the top-level reopened
node is handled the same way as children are. Option/flag inheritance
from the parent becomes just one item in the list and is done at the
beginning of the function, similar to how the other items are/will be
handled.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
---
block.c | 39 +++++++++++++++++++++++++++++++++------
1 file changed, 33 insertions(+), 6 deletions(-)
diff --git a/block.c b/block.c
index 9c42b17..5fd6c44 100644
--- a/block.c
+++ b/block.c
@@ -1693,9 +1693,13 @@ typedef struct BlockReopenQueueEntry {
* bs_queue, or the existing bs_queue being used.
*
*/
-BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue,
- BlockDriverState *bs,
- QDict *options, int flags)
+static BlockReopenQueue *bdrv_reopen_queue_child(BlockReopenQueue *bs_queue,
+ BlockDriverState *bs,
+ QDict *options,
+ int flags,
+ const BdrvChildRole *role,
+ QDict *parent_options,
+ int parent_flags)
{
assert(bs != NULL);
@@ -1712,6 +1716,22 @@ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue
*bs_queue,
options = qdict_new();
}
+ /*
+ * Precedence of options:
+ * 1. Explicitly passed in options (highest)
+ * 2. TODO Set in flags (only for top level)
+ * 3. TODO Retained from explicitly set options of bs
+ * 4. TODO Inherited from parent node
+ * 5. Retained from effective options of bs
+ */
+
+ /* Inherit from parent node */
+ if (parent_options) {
+ assert(!flags);
+ flags = role->inherit_flags(parent_flags);
+ }
+
+ /* Old values are used for options that aren't set yet */
old_options = qdict_clone_shallow(bs->options);
bdrv_join_options(bs, options, old_options);
QDECREF(old_options);
@@ -1722,7 +1742,6 @@ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue
*bs_queue,
QLIST_FOREACH(child, &bs->children, next) {
QDict *new_child_options;
char *child_key_dot;
- int child_flags;
/* reopen can only change the options of block devices that were
* implicitly created and inherited options. For other (referenced)
@@ -1735,8 +1754,8 @@ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue
*bs_queue,
qdict_extract_subqdict(options, &new_child_options, child_key_dot);
g_free(child_key_dot);
- child_flags = child->role->inherit_flags(flags);
- bdrv_reopen_queue(bs_queue, child->bs, new_child_options, child_flags);
+ bdrv_reopen_queue_child(bs_queue, child->bs, new_child_options, 0,
+ child->role, options, flags);
}
bs_entry = g_new0(BlockReopenQueueEntry, 1);
@@ -1749,6 +1768,14 @@ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue
*bs_queue,
return bs_queue;
}
+BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue,
+ BlockDriverState *bs,
+ QDict *options, int flags)
+{
+ return bdrv_reopen_queue_child(bs_queue, bs, options, flags,
+ NULL, NULL, 0);
+}
+
/*
* Reopen multiple BlockDriverStates atomically & transactionally.
*
--
1.8.3.1
- [Qemu-devel] [PULL 47/48] qemu-img: abort when full_backing_filename not present, (continued)
- [Qemu-devel] [PULL 47/48] qemu-img: abort when full_backing_filename not present, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 28/48] qcow2: Use abort() instead of assert(false), Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 21/48] blkdebug: Enable reopen, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 05/48] block: Fix reopen with semantically overlapping options, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 43/48] qemu-iotests: s390x: fix test 068, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 06/48] mirror: Error out when a BDS would get two BBs, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 34/48] iotests: Extend test 112 for qemu-img amend, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 07/48] block: Allow references for backing files, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 27/48] qcow2: Use error_report() in qcow2_amend_options(), Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 36/48] raw-posix: Make aio=native option binding, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 13/48] block: reopen: Document option precedence and refactor accordingly,
Kevin Wolf <=
- [Qemu-devel] [PULL 18/48] qemu-iotests: Remove cache mode test without medium, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 25/48] progress: Allow regressing progress, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 08/48] block: Consider all block layer options in append_open_options, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 22/48] qemu-iotests: Try setting cache mode for children, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 04/48] qcow2: Add .bdrv_join_options callback, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 12/48] block: Allow specifying child options in reopen, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 26/48] block: Add opaque value to the amend CB, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 48/48] block/qapi: allow best-effort query, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 35/48] qcow2: insert assert into qcow2_get_specific_info(), Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 44/48] block/qapi: do not redundantly print "actual path", Kevin Wolf, 2015/12/18