From: Eric Blake <eblake@redhat.com>
To: "Daniel P. Berrange" <berrange@redhat.com>, qemu-devel@nongnu.org
Cc: "Markus Armbruster" <armbru@redhat.com>,
"Max Reitz" <mreitz@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@gmail.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH v7 4/7] qom: support arbitrary non-scalar properties with -object
Date: Wed, 13 Jul 2016 22:00:21 -0600 [thread overview]
Message-ID: <57870E55.1020205@redhat.com> (raw)
In-Reply-To: <1467724312-9378-5-git-send-email-berrange@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2661 bytes --]
On 07/05/2016 07:11 AM, Daniel P. Berrange wrote:
> The current -object command line syntax only allows for
> creation of objects with scalar properties, or a list
> with a fixed scalar element type. Objects which have
> properties that are represented as structs in the QAPI
> schema cannot be created using -object.
>
> Thus -object can now support non-scalar properties,
> for example the QMP object
>
> {
> "execute": "object-add",
> "arguments": {
> "qom-type": "demo",
> "id": "demo0",
> "parameters": {
> "foo": [
> { "bar": "one", "wizz": "1" },
> { "bar": "two", "wizz": "2" }
> ]
> }
> }
> }
>
> Would be creatable via the CLI now using
>
> $QEMU \
> -object demo,id=demo0,\
> foo.0.bar=one,foo.0.wizz=1,\
> foo.1.bar=two,foo.1.wizz=2
Overall, I like it.
>
> Notice that this syntax is intentionally compatible
> with that currently used by block drivers.
And this gives me hope that someday we may replace blockdev-add from
QemuOpts munging to direct QAPI type handling. Maybe :) But certainly
not for 2.7.
> @@ -1721,20 +1721,12 @@ void hmp_netdev_del(Monitor *mon, const QDict *qdict)
> void hmp_object_add(Monitor *mon, const QDict *qdict)
> {
> Error *err = NULL;
> - QemuOpts *opts;
> - OptsVisitor *ov;
> + QmpInputVisitor *qiv;
Will need rebasing now that some of my qapi cleanups have landed in
master, and also depending on whether my adoption of your patch 3/7 in
my 'qapi subset F' series also lands first, since I tweaked your string
input visitor interface slightly. But the idea is right on track.
> Object *obj = NULL;
>
> - opts = qemu_opts_from_qdict(qemu_find_opts("object"), qdict, &err);
> - if (err) {
> - hmp_handle_error(mon, &err);
> - return;
> - }
> -
> - ov = opts_visitor_new(opts);
> - obj = user_creatable_add(qdict, opts_get_visitor(ov), &err);
> - opts_visitor_cleanup(ov);
> - qemu_opts_del(opts);
> + qiv = qmp_string_input_visitor_new((QObject *)qdict, true);
While this cast happens to work (because QDict currently has QObject as
its first member), it is not necessarily safe to future layout changes,
and you should probably be using QOBJECT(qdict) instead.
> + obj = user_creatable_add(qdict, qmp_input_get_visitor(qiv), &err);
> + qmp_input_visitor_cleanup(qiv);
That looks so much simpler, even if it does need rebasing!
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2016-07-14 4:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-05 13:11 [Qemu-devel] [PATCH v7 0/7] Provide a QOM-based authorization API Daniel P. Berrange
2016-07-05 13:11 ` [Qemu-devel] [PATCH v7 1/7] qdict: implement a qdict_crumple method for un-flattening a dict Daniel P. Berrange
2016-07-05 13:11 ` [Qemu-devel] [PATCH v7 2/7] option: make parse_option_bool/number non-static Daniel P. Berrange
2016-07-14 1:33 ` Eric Blake
2016-07-05 13:11 ` [Qemu-devel] [PATCH v7 3/7] qapi: add a QmpInputVisitor that does string conversion Daniel P. Berrange
2016-07-14 1:34 ` Eric Blake
2016-07-05 13:11 ` [Qemu-devel] [PATCH v7 4/7] qom: support arbitrary non-scalar properties with -object Daniel P. Berrange
2016-07-14 4:00 ` Eric Blake [this message]
2016-07-05 13:11 ` [Qemu-devel] [PATCH v7 5/7] util: add QAuthZ object as an authorization base class Daniel P. Berrange
2016-07-05 13:11 ` [Qemu-devel] [PATCH v7 6/7] util: add QAuthZSimple object type for a simple access control list Daniel P. Berrange
2016-07-05 13:11 ` [Qemu-devel] [PATCH v7 7/7] acl: delete existing ACL implementation Daniel P. Berrange
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=57870E55.1020205@redhat.com \
--to=eblake@redhat.com \
--cc=afaerber@suse.de \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=marcandre.lureau@gmail.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--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.