[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 06/23] block: Allow child references on reopen
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 06/23] block: Allow child references on reopen |
Date: |
Mon, 1 Oct 2018 19:18:44 +0200 |
From: Alberto Garcia <address@hidden>
In the previous patches we removed all child references from
bs->{options,explicit_options} because keeping them is useless and
wrong.
Because of this, any attempt to reopen a BlockDriverState using a
child reference as one of its options would result in a failure,
because bdrv_reopen_prepare() would detect that there's a new option
(the child reference) that wasn't present in bs->options.
But passing child references on reopen can be useful. It's a way to
specify a BDS's child without having to pass recursively all of the
child's options, and if the reference points to a different BDS then
this can allow us to replace the child.
However, replacing the child is something that needs to be implemented
case by case and only when it makes sense. For now, this patch allows
passing a child reference as long as it points to the current child of
the BlockDriverState.
It's also important to remember that, as a consequence of the
previous patches, this child reference will be removed from
bs->{options,explicit_options} after the reopening has been completed.
Signed-off-by: Alberto Garcia <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/block.c b/block.c
index 98aca56785..ff1aded4b8 100644
--- a/block.c
+++ b/block.c
@@ -3242,6 +3242,24 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state,
BlockReopenQueue *queue,
QObject *new = entry->value;
QObject *old = qdict_get(reopen_state->bs->options, entry->key);
+ /* Allow child references (child_name=node_name) as long as they
+ * point to the current child (i.e. everything stays the same). */
+ if (qobject_type(new) == QTYPE_QSTRING) {
+ BdrvChild *child;
+ QLIST_FOREACH(child, &reopen_state->bs->children, next) {
+ if (!strcmp(child->name, entry->key)) {
+ break;
+ }
+ }
+
+ if (child) {
+ const char *str = qobject_get_try_str(new);
+ if (!strcmp(child->bs->node_name, str)) {
+ continue; /* Found child with this name, skip option */
+ }
+ }
+ }
+
/*
* TODO: When using -drive to specify blockdev options, all values
* will be strings; however, when using -blockdev, blockdev-add or
--
2.13.6
- [Qemu-devel] [PULL 00/23] Block layer patches, Kevin Wolf, 2018/10/01
- [Qemu-devel] [PULL 02/23] qemu-io: Fix writethrough check in reopen, Kevin Wolf, 2018/10/01
- [Qemu-devel] [PULL 01/23] file-posix: Include filename in locking error message, Kevin Wolf, 2018/10/01
- [Qemu-devel] [PULL 03/23] file-posix: x-check-cache-dropped should default to false on reopen, Kevin Wolf, 2018/10/01
- [Qemu-devel] [PULL 04/23] block: Remove child references from bs->{options, explicit_options}, Kevin Wolf, 2018/10/01
- [Qemu-devel] [PULL 06/23] block: Allow child references on reopen,
Kevin Wolf <=
- [Qemu-devel] [PULL 07/23] block: Forbid trying to change unsupported options during reopen, Kevin Wolf, 2018/10/01
- [Qemu-devel] [PULL 05/23] block: Don't look for child references in append_open_options(), Kevin Wolf, 2018/10/01
- [Qemu-devel] [PULL 10/23] block: Allow changing 'detect-zeroes' on reopen, Kevin Wolf, 2018/10/01
- [Qemu-devel] [PULL 09/23] block: Allow changing 'discard' on reopen, Kevin Wolf, 2018/10/01
- [Qemu-devel] [PULL 08/23] file-posix: Forbid trying to change unsupported options during reopen, Kevin Wolf, 2018/10/01