From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: Markus Armbruster <armbru@redhat.com>,
Luiz Capitulino <lcapitulino@redhat.com>
Cc: qemu-devel@nongnu.org, Anthony Liguori <aliguori@amazon.com>,
imammedo@redhat.com, Paolo Bonzini <pbonzini@redhat.com>,
akong@redhat.com
Subject: Re: [Qemu-devel] [PATCH 4/5] monitor: add object-add (QMP) and object_add (HMP) command
Date: Thu, 19 Dec 2013 15:53:32 -0600 [thread overview]
Message-ID: <20131219215332.11040.45527@loki> (raw)
In-Reply-To: <87haa83pvz.fsf@blackfin.pond.sub.org>
Quoting Markus Armbruster (2013-12-17 01:20:16)
> [Cc: Anthony, Mike for QAPI schema expertise]
>
> Luiz Capitulino <lcapitulino@redhat.com> writes:
>
> > On Tue, 10 Dec 2013 19:15:05 +0100
> > Paolo Bonzini <pbonzini@redhat.com> wrote:
> >
> >> -----BEGIN PGP SIGNED MESSAGE-----
> >> Hash: SHA1
> >>
> >> Il 10/12/2013 19:00, Eric Blake ha scritto:
> >> >>> + 'data': {'qom-type': 'str', 'id': 'str', '*props': 'dict'},
> >> >>> + 'gen': 'no' }
> >> >
> >> > This feels VERY open-coded. No where else in qapi-schema do we
> >> > have 'dict' as a type
> >>
> >> Yes, in fact the "data" field is entirely skipped by the code
> >> generator (that's 'gen':'no').
> >>
> >> > ; using it violates all sorts of type-safety (which, I guess, is
> >> > the point), making it impossible to introspect what keys are valid
> >> > for use in the "props":{...} dictionary. Do we really want to
> >> > play this fast and loose with the type system, or should we try
> >> > harder to make this a robust self-describing union of types?
> >> >
> >> > That is, why can't we have object-add use a discriminated union,
> >> > where qom-type is the discriminator, and where props is an
> >> > appropriate JSON struct type that corresponds to the branch of the
> >> > union, so that we get full introspection on the set of valid keys
> >> > to put in props for any given qom-type?
> >>
> >> The point of "props" is passing arbitrary data to a QOM object. We
> >> should indeed have introspection for QOM objects, where each QOM class
> >> name can be introspected separately. However, the union of all
> >> possible QOM objects need not have a "C struct" representation.
> >
> > The "props" key was added to represent the "O" argument type of
> > early QMP (which is used by commands like device_add), so that
> > we could convert them to the QAPI. IIRC, we didn't plan for it
> > to be used by new commands... But I don't have anything better
> > to suggest, so I won't object to its usage here.
>
> We created monitor argument type "O" to have name=val,... arguments in
> the human monitor exactly like command line option arguments. Currently
> used by device_add and netdev_add.
>
> We shoehorned type "O" into QMP in a bout of QMP feature-completeness
> desperation. This was before QAPI.
>
> device_add still isn't in qapi-schema.json, but netdev_add is:
>
> { 'command': 'netdev_add',
> 'data': {'type': 'str', 'id': 'str', '*props': '**'},
> 'gen': 'no' }
>
> Note the magic "'*props': '**'" (I'll be hanged if I know what that
> means[*]), and "'gen': 'no'".
>
> Yes, a proper schema for netdev_add and device_add is desirable. In
> both cases (but especially for device_add), the arguments are the
> obligatory id plus a union discriminated by the device type, contraining
> that device's properties.
>
> Unless we move device properties definition to qapi-schema.json (bad),
> or duplicate them there (worse), we need to derive that part of the
> schema dynamically from device information available in QOM.
Is dumping static properties based on class name sufficient, or do we
need introspection for dynamic properties as well? (or are those not
exposed outside of qom-set?) We could maybe introduce a QAPI 'built-in'
such as 'ObjectProperties' that automatically does the query based on the
now-special 'type' param and handles all the type-checking up-front. This
would avoid an open-ended 'dict' type proliferating too much and provide
infrastructure for introspection.
>
>
> [*] Can we have a definition of QAPI schema semantics other than code?
> Pretty-please?
next prev parent reply other threads:[~2013-12-19 21:53 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-10 17:00 [Qemu-devel] [PATCH 0/5] Monitor commands for object-add/del Paolo Bonzini
2013-12-10 17:00 ` [Qemu-devel] [PATCH 1/5] rng: initialize file descriptor to -1 Paolo Bonzini
2013-12-11 23:14 ` Eric Blake
2013-12-10 17:00 ` [Qemu-devel] [PATCH 2/5] qom: fix leak for objects created with -object Paolo Bonzini
2013-12-11 23:15 ` Eric Blake
2013-12-10 17:00 ` [Qemu-devel] [PATCH 3/5] qom: catch errors in object_property_add_child Paolo Bonzini
2013-12-11 23:16 ` Eric Blake
2013-12-10 17:00 ` [Qemu-devel] [PATCH 4/5] monitor: add object-add (QMP) and object_add (HMP) command Paolo Bonzini
2013-12-10 18:00 ` Eric Blake
2013-12-10 18:15 ` Paolo Bonzini
2013-12-13 2:55 ` Wenchao Xia
2013-12-13 12:19 ` Paolo Bonzini
2013-12-16 20:02 ` Luiz Capitulino
2013-12-17 7:20 ` Markus Armbruster
2013-12-19 21:53 ` Michael Roth [this message]
2014-01-07 12:00 ` Markus Armbruster
2014-01-07 12:51 ` Paolo Bonzini
2013-12-10 17:00 ` [Qemu-devel] [PATCH 5/5] monitor: add object-del (QMP) and object_del " Paolo Bonzini
2013-12-10 18:01 ` Eric Blake
2013-12-10 18:17 ` Paolo Bonzini
2013-12-12 15:43 ` [Qemu-devel] [PATCH 0/5] Monitor commands for object-add/del Igor Mammedov
2013-12-16 20:03 ` Luiz Capitulino
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=20131219215332.11040.45527@loki \
--to=mdroth@linux.vnet.ibm.com \
--cc=akong@redhat.com \
--cc=aliguori@amazon.com \
--cc=armbru@redhat.com \
--cc=imammedo@redhat.com \
--cc=lcapitulino@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).