[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 13/15] block: Stop passing flags to bdrv_reopen_q
From: |
Alberto Garcia |
Subject: |
[Qemu-devel] [PATCH v3 13/15] block: Stop passing flags to bdrv_reopen_queue_child() |
Date: |
Fri, 19 Oct 2018 15:24:44 +0300 |
Now that all callers are passing the new options using the QDict we no
longer need the 'flags' parameter.
This patch makes the following changes:
1) The update_options_from_flags() call is no longer necessary
so it can be removed.
2) The update_flags_from_options() call is now used in all cases,
and is moved down a few lines so it happens after the options
QDict contains the final set of values.
3) The flags parameter is removed. Now the flags are initialized
using the current value (for the top-level node) or the parent
flags (after inherit_options()). In both cases the initial
values are updated to reflect the new options in the QDict. This
happens in bdrv_reopen_queue_child() (as explained above) and in
bdrv_reopen_prepare().
Signed-off-by: Alberto Garcia <address@hidden>
---
block.c | 48 +++++++++++++++++++-----------------------------
1 file changed, 19 insertions(+), 29 deletions(-)
diff --git a/block.c b/block.c
index c142773358..039f03703b 100644
--- a/block.c
+++ b/block.c
@@ -2876,7 +2876,6 @@ BlockDriverState *bdrv_open(const char *filename, const
char *reference,
static BlockReopenQueue *bdrv_reopen_queue_child(BlockReopenQueue *bs_queue,
BlockDriverState *bs,
QDict *options,
- int flags,
const BdrvChildRole *role,
QDict *parent_options,
int parent_flags)
@@ -2885,7 +2884,9 @@ static BlockReopenQueue
*bdrv_reopen_queue_child(BlockReopenQueue *bs_queue,
BlockReopenQueueEntry *bs_entry;
BdrvChild *child;
- QDict *old_options, *explicit_options;
+ QDict *old_options, *explicit_options, *options_copy;
+ int flags;
+ QemuOpts *opts;
/* Make sure that the caller remembered to use a drained section. This is
* important to avoid graph changes between the recursive queuing here and
@@ -2911,22 +2912,11 @@ static BlockReopenQueue
*bdrv_reopen_queue_child(BlockReopenQueue *bs_queue,
/*
* Precedence of options:
* 1. Explicitly passed in options (highest)
- * 2. Set in flags (only for top level)
- * 3. Retained from explicitly set options of bs
- * 4. Inherited from parent node
- * 5. Retained from effective options of bs
+ * 2. Retained from explicitly set options of bs
+ * 3. Inherited from parent node
+ * 4. Retained from effective options of bs
*/
- if (!parent_options) {
- /*
- * Any setting represented by flags is always updated. If the
- * corresponding QDict option is set, it takes precedence. Otherwise
- * the flag is translated into a QDict option. The old setting of bs is
- * not considered.
- */
- update_options_from_flags(options, flags);
- }
-
/* Old explicitly set values (don't overwrite by inherited value) */
if (bs_entry) {
old_options = qdict_clone_shallow(bs_entry->state.explicit_options);
@@ -2940,16 +2930,10 @@ static BlockReopenQueue
*bdrv_reopen_queue_child(BlockReopenQueue *bs_queue,
/* Inherit from parent node */
if (parent_options) {
- QemuOpts *opts;
- QDict *options_copy;
- assert(!flags);
+ flags = 0;
role->inherit_options(&flags, options, parent_flags, parent_options);
- options_copy = qdict_clone_shallow(options);
- opts = qemu_opts_create(&bdrv_runtime_opts, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, options_copy, NULL);
- update_flags_from_options(&flags, opts);
- qemu_opts_del(opts);
- qobject_unref(options_copy);
+ } else {
+ flags = bdrv_get_flags(bs);
}
/* Old values are used for options that aren't set yet */
@@ -2957,6 +2941,14 @@ static BlockReopenQueue
*bdrv_reopen_queue_child(BlockReopenQueue *bs_queue,
bdrv_join_options(bs, options, old_options);
qobject_unref(old_options);
+ /* We have the final set of options so let's update the flags */
+ options_copy = qdict_clone_shallow(options);
+ opts = qemu_opts_create(&bdrv_runtime_opts, NULL, 0, &error_abort);
+ qemu_opts_absorb_qdict(opts, options_copy, NULL);
+ update_flags_from_options(&flags, opts);
+ qemu_opts_del(opts);
+ qobject_unref(options_copy);
+
/* bdrv_open_inherit() sets and clears some additional flags internally */
flags &= ~BDRV_O_PROTOCOL;
if (flags & BDRV_O_RDWR) {
@@ -2996,7 +2988,7 @@ static BlockReopenQueue
*bdrv_reopen_queue_child(BlockReopenQueue *bs_queue,
qdict_extract_subqdict(options, &new_child_options, child_key_dot);
g_free(child_key_dot);
- bdrv_reopen_queue_child(bs_queue, child->bs, new_child_options, 0,
+ bdrv_reopen_queue_child(bs_queue, child->bs, new_child_options,
child->role, options, flags);
}
@@ -3007,9 +2999,7 @@ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue
*bs_queue,
BlockDriverState *bs,
QDict *options)
{
- int flags = bdrv_get_flags(bs);
- return bdrv_reopen_queue_child(bs_queue, bs, options, flags,
- NULL, NULL, 0);
+ return bdrv_reopen_queue_child(bs_queue, bs, options, NULL, NULL, 0);
}
/*
--
2.11.0
- [Qemu-devel] [PATCH v3 00/15] Don't pass flags to bdrv_reopen_queue(), Alberto Garcia, 2018/10/19
- [Qemu-devel] [PATCH v3 11/15] block: Clean up reopen_backing_file() in block/replication.c, Alberto Garcia, 2018/10/19
- [Qemu-devel] [PATCH v3 15/15] block: Assert that flags are up-to-date in bdrv_reopen_prepare(), Alberto Garcia, 2018/10/19
- [Qemu-devel] [PATCH v3 04/15] block: Use bdrv_reopen_set_read_only() in bdrv_commit(), Alberto Garcia, 2018/10/19
- [Qemu-devel] [PATCH v3 02/15] block: Use bdrv_reopen_set_read_only() in bdrv_backing_update_filename(), Alberto Garcia, 2018/10/19
- [Qemu-devel] [PATCH v3 07/15] block: Use bdrv_reopen_set_read_only() in external_snapshot_commit(), Alberto Garcia, 2018/10/19
- [Qemu-devel] [PATCH v3 08/15] block: Use bdrv_reopen_set_read_only() in the mirror driver, Alberto Garcia, 2018/10/19
- [Qemu-devel] [PATCH v3 01/15] block: Add bdrv_reopen_set_read_only(), Alberto Garcia, 2018/10/19
- [Qemu-devel] [PATCH v3 10/15] qemu-io: Put flag changes in the options QDict in reopen_f(), Alberto Garcia, 2018/10/19
- [Qemu-devel] [PATCH v3 13/15] block: Stop passing flags to bdrv_reopen_queue_child(),
Alberto Garcia <=
- [Qemu-devel] [PATCH v3 12/15] block: Remove flags parameter from bdrv_reopen_queue(), Alberto Garcia, 2018/10/19
- [Qemu-devel] [PATCH v3 09/15] block: Drop bdrv_reopen(), Alberto Garcia, 2018/10/19
- [Qemu-devel] [PATCH v3 03/15] block: Use bdrv_reopen_set_read_only() in commit_start/complete(), Alberto Garcia, 2018/10/19
- [Qemu-devel] [PATCH v3 14/15] block: Remove assertions from update_flags_from_options(), Alberto Garcia, 2018/10/19
- [Qemu-devel] [PATCH v3 06/15] block: Use bdrv_reopen_set_read_only() in qmp_change_backing_file(), Alberto Garcia, 2018/10/19
- [Qemu-devel] [PATCH v3 05/15] block: Use bdrv_reopen_set_read_only() in stream_start/complete(), Alberto Garcia, 2018/10/19