From: "Daniel P. Berrange" <berrange@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org, eblake@redhat.com, kwolf@redhat.com,
mreitz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com,
dgilbert@redhat.com
Subject: Re: [Qemu-devel] [PATCH for-2.10 05/10] block: Use JSON null instead of "" to disable backing file
Date: Tue, 18 Jul 2017 16:53:06 +0100 [thread overview]
Message-ID: <20170718155306.GP11927@redhat.com> (raw)
In-Reply-To: <1500385286-21142-6-git-send-email-armbru@redhat.com>
On Tue, Jul 18, 2017 at 03:41:21PM +0200, Markus Armbruster wrote:
> BlockdevRef is an alternate of BlockdevOptions (inline definition) and
> str (reference to an existing block device by name). BlockdevRef
> value "" is special: "no block device should be referenced." It's
> actually interpreted that way in just one place: optional member
> @backing of COW formats. Semantics:
>
> * Present means "use this block device" as backing storage
>
> * Absent means "default to the one stored in the image"
>
> * Except "" means "don't use backing storage at all"
>
> The first two are perfectly normal: when the parameter is absent, it
> defaults to an implied value, but the value's meaning is the same.
>
> The third one overloads the parameter with a second meaning. The
> overloading is *implicit*, i.e. it's not visible in the types. Works
> here, because "" is not a value block device ID.
>
> Pressing argument values the schema accepts, but are semantically
> invalid, into service to mean "do something else entirely" is not
> general, as suitable invalid values need not exist. I also find it
> ugly.
>
> To clean this up, we could add a separate flag argument to suppress
> @backing, or add a distinct value to @backing. This commit implements
> the latter: add JSON null to the values of @backing, deprecate "".
>
> Because we're so close to the 2.10 freeze, implement it in the
> stupidest way possible: have qmp_blockdev_add() rewrite null to ""
> before anything else can see the null. Works, because BlockdevRef
> occurs only within arguments of blockdev-add. The proper way to do it
> would be rewriting "" to null, preferably in a cleaner way, but that
> requires fixing up code to work with null. Add a TODO comment for
> that.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
> blockdev.c | 14 ++++++++++++++
> qapi/block-core.json | 29 ++++++++++++++++++++++-------
> tests/qemu-iotests/085 | 2 +-
> tests/qemu-iotests/139 | 2 +-
> 4 files changed, 38 insertions(+), 9 deletions(-)
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
>
> diff --git a/blockdev.c b/blockdev.c
> index 9c6dd27..1c42699 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -3886,6 +3886,7 @@ void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
> QObject *obj;
> Visitor *v = qobject_output_visitor_new(&obj);
> QDict *qdict;
> + const QDictEntry *ent;
> Error *local_err = NULL;
>
> visit_type_BlockdevOptions(v, NULL, &options, &local_err);
> @@ -3899,6 +3900,19 @@ void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
>
> qdict_flatten(qdict);
>
> + /*
> + * Rewrite "backing": null to "backing": ""
> + * TODO Rewrite "" to null instead, and perhaps not even here
> + */
> + for (ent = qdict_first(qdict); ent; ent = qdict_next(qdict, ent)) {
> + char *dot = strrchr(ent->key, '.');
> +
> + if (!strcmp(dot ? dot + 1 : ent->key, "backing")
> + && qobject_type(ent->value) == QTYPE_QNULL) {
> + qdict_put(qdict, ent->key, qstring_new());
> + }
> + }
I find it a little yucky that we're modifying the qdict, rather than
the original "options" object, but I guess this is simpler for a quick
hack
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2017-07-18 15:53 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-18 13:41 [Qemu-devel] [PATCH for-2.10 00/10] Correct two minor QMP interface design flaws Markus Armbruster
2017-07-18 13:41 ` [Qemu-devel] [PATCH for-2.10 01/10] qapi: Separate type QNull from QObject Markus Armbruster
2017-07-18 14:24 ` Eric Blake
2017-07-18 15:44 ` Daniel P. Berrange
2017-07-18 13:41 ` [Qemu-devel] [PATCH for-2.10 02/10] qapi: Use QNull for a more regular visit_type_null() Markus Armbruster
2017-07-18 14:36 ` Eric Blake
2017-07-18 15:05 ` Markus Armbruster
2017-07-18 15:46 ` Daniel P. Berrange
2017-07-18 13:41 ` [Qemu-devel] [PATCH for-2.10 03/10] qapi: Introduce a first class 'null' type Markus Armbruster
2017-07-18 14:53 ` Eric Blake
2017-07-18 14:54 ` Eric Blake
2017-07-18 15:21 ` Markus Armbruster
2017-07-18 19:43 ` Markus Armbruster
2017-07-18 19:47 ` Eric Blake
2017-07-18 20:02 ` Markus Armbruster
2017-07-18 20:08 ` Eric Blake
2017-07-18 20:27 ` Markus Armbruster
2017-07-18 15:20 ` Markus Armbruster
2017-07-18 15:47 ` Daniel P. Berrange
2017-07-18 13:41 ` [Qemu-devel] [PATCH for-2.10 04/10] tests/test-qobject-input-visitor: Drop redundant test Markus Armbruster
2017-07-18 15:13 ` Eric Blake
2017-07-18 15:47 ` Daniel P. Berrange
2017-07-18 13:41 ` [Qemu-devel] [PATCH for-2.10 05/10] block: Use JSON null instead of "" to disable backing file Markus Armbruster
2017-07-18 15:53 ` Daniel P. Berrange [this message]
2017-07-18 17:27 ` Eric Blake
2017-07-18 13:41 ` [Qemu-devel] [PATCH for-2.10 06/10] hmp: Clean up and simplify hmp_migrate_set_parameter() Markus Armbruster
2017-07-18 15:54 ` Daniel P. Berrange
2017-07-18 17:09 ` Dr. David Alan Gilbert
2017-07-18 17:34 ` Eric Blake
2017-07-18 18:28 ` Markus Armbruster
2017-07-18 13:41 ` [Qemu-devel] [PATCH for-2.10 07/10] migration: Clean up around tls_creds, tls_hostname Markus Armbruster
2017-07-18 15:57 ` Daniel P. Berrange
2017-07-18 17:36 ` Eric Blake
2017-07-18 17:37 ` Dr. David Alan Gilbert
2017-07-18 13:41 ` [Qemu-devel] [PATCH for-2.10 08/10] migration: Add TODO comments on duplication of QAPI_CLONE() Markus Armbruster
2017-07-18 15:57 ` Daniel P. Berrange
2017-07-18 17:36 ` Eric Blake
2017-07-18 13:41 ` [Qemu-devel] [PATCH for-2.10 09/10] migration: Unshare MigrationParameters struct for now Markus Armbruster
2017-07-18 16:01 ` Daniel P. Berrange
2017-07-18 17:42 ` Eric Blake
2017-07-18 13:41 ` [Qemu-devel] [PATCH for-2.10 10/10] migration: Use JSON null instead of "" to reset parameter to default Markus Armbruster
2017-07-18 16:03 ` Daniel P. Berrange
2017-07-18 17:46 ` Eric Blake
2017-07-18 18:37 ` Markus Armbruster
2017-07-18 18:39 ` Markus Armbruster
2017-07-18 19:09 ` Eric Blake
2017-07-18 19:32 ` Markus Armbruster
2017-07-18 19:55 ` Eric Blake
2017-07-18 17:52 ` Dr. David Alan Gilbert
2017-07-18 19:24 ` Markus Armbruster
2017-07-19 8:32 ` Daniel P. Berrange
2017-07-18 14:02 ` [Qemu-devel] [PATCH for-2.10 00/10] Correct two minor QMP interface design flaws no-reply
2017-07-18 16:08 ` Daniel P. Berrange
2017-07-19 6:12 ` Kevin Wolf
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=20170718155306.GP11927@redhat.com \
--to=berrange@redhat.com \
--cc=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/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.