All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alberto Garcia <berto@igalia.com>
To: qemu-devel@nongnu.org
Cc: Alberto Garcia <berto@igalia.com>,
	qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>,
	Kevin Wolf <kwolf@redhat.com>
Subject: [Qemu-devel] [PATCH v3 05/10] block: Allow child references on reopen
Date: Thu,  6 Sep 2018 12:37:05 +0300	[thread overview]
Message-ID: <70c436dbf3914d952a2839bf8383a436dc5267ce.1536226505.git.berto@igalia.com> (raw)
In-Reply-To: <cover.1536226505.git.berto@igalia.com>
In-Reply-To: <cover.1536226505.git.berto@igalia.com>

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 <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/block.c b/block.c
index aaa4cf6897..5223d16f1b 100644
--- a/block.c
+++ b/block.c
@@ -3241,6 +3241,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.11.0

  parent reply	other threads:[~2018-09-06  9:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-06  9:37 [Qemu-devel] [PATCH v3 00/10] Misc reopen-related patches Alberto Garcia
2018-09-06  9:37 ` [Qemu-devel] [PATCH v3 01/10] qemu-io: Fix writethrough check in reopen Alberto Garcia
2018-09-06  9:37 ` [Qemu-devel] [PATCH v3 02/10] file-posix: x-check-cache-dropped should default to false on reopen Alberto Garcia
2018-09-06  9:37 ` [Qemu-devel] [PATCH v3 03/10] block: Remove child references from bs->{options, explicit_options} Alberto Garcia
2018-09-06  9:37 ` [Qemu-devel] [PATCH v3 04/10] block: Don't look for child references in append_open_options() Alberto Garcia
2018-09-06  9:37 ` Alberto Garcia [this message]
2018-09-06  9:37 ` [Qemu-devel] [PATCH v3 06/10] block: Forbid trying to change unsupported options during reopen Alberto Garcia
2018-09-06  9:37 ` [Qemu-devel] [PATCH v3 07/10] file-posix: " Alberto Garcia
2018-09-06  9:37 ` [Qemu-devel] [PATCH v3 08/10] block: Allow changing 'discard' on reopen Alberto Garcia
2018-09-13 13:32   ` Max Reitz
2018-09-06  9:37 ` [Qemu-devel] [PATCH v3 09/10] block: Allow changing 'detect-zeroes' " Alberto Garcia
2018-09-13 13:34   ` Max Reitz
2018-09-06  9:37 ` [Qemu-devel] [PATCH v3 10/10] block: Allow changing 'force-share' " Alberto Garcia

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=70c436dbf3914d952a2839bf8383a436dc5267ce.1536226505.git.berto@igalia.com \
    --to=berto@igalia.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.