From: Eric Blake <eblake@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
armbru@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com,
lcapitulino@redhat.com
Subject: Re: [Qemu-devel] [RFC PATCH 02/11] qapi-types.py: Implement 'base' for unions
Date: Thu, 11 Jul 2013 06:46:52 -0600 [thread overview]
Message-ID: <51DEA93C.90500@redhat.com> (raw)
In-Reply-To: <51DE9DB1.90801@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1871 bytes --]
On 07/11/2013 05:57 AM, Eric Blake wrote:
> On 07/09/2013 03:53 AM, Kevin Wolf wrote:
>> The new 'base' key in a union definition refers to a struct type, which
>> is inlined into the union definition and can represent fields common to
>> all kinds.
>
> Is it worth listing an example of intended use in the commit message?
> If I understand correctly, then this qapi-schema.json file:
>
> { 'type': 'Base',
> 'data': { 'main': 'str' } }
> { 'type': 'Extra1',
> 'data': { 'foo': 'str' } }
> { 'type': 'Extra2',
> 'data': { 'bar': 'str' } }
> { 'union': 'Type',
> 'base': 'BaseType',
> 'data': { 'variant1': 'Extra1',
> 'variant2': 'Extra2' } }
> { 'command': 'test',
> 'data': { 'arg': 'Type' } }
>
> would then be used over the wire as:
>
> { "execute": "test",
> "arguments": { "arg": { "type": "variant1",
> "data": { "main": "hello", "foo": "world" } } } }
> { "execute": "test",
> "arguments": { "arg": { "type": "variant2",
> "data": { "main": "hi", "bar": "there" } } } }
I just read patch 6/11, and it looks like I'm a bit off; it looks like
the usage syntax with a base type is actually:
{ "execute": "test",
"arguments": { "arg": { "type": "variant1", "main": "hello",
"data": { "foo": "world" } } } }
{ "execute": "test",
"arguments": { "arg": { "type": "variant2", "main": "hi",
"data": { "bar": "there" } } } }
That is, a union type is automatically granted two top-level keys "type"
and "data", and a base type grants it additional top-level keys; nested
keys under "data" are still tied to just the type listed in the union.
See why a commit message can make a difference in understanding? :)
--
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: 621 bytes --]
next prev parent reply other threads:[~2013-07-11 12:46 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-09 9:53 [Qemu-devel] [RFC PATCH 00/11] qapi changes in preparation for blockdev-add Kevin Wolf
2013-07-09 9:53 ` [Qemu-devel] [RFC PATCH 01/11] qapi-types.py: Split off generate_struct_fields() Kevin Wolf
2013-07-11 11:45 ` Eric Blake
2013-07-09 9:53 ` [Qemu-devel] [RFC PATCH 02/11] qapi-types.py: Implement 'base' for unions Kevin Wolf
2013-07-11 11:57 ` Eric Blake
2013-07-11 12:46 ` Eric Blake [this message]
2013-07-09 9:53 ` [Qemu-devel] [RFC PATCH 03/11] qapi-visit.py: Split off generate_visit_struct_fields() Kevin Wolf
2013-07-11 12:18 ` Eric Blake
2013-07-09 9:53 ` [Qemu-devel] [RFC PATCH 04/11] qapi-visit.py: Implement 'base' for unions Kevin Wolf
2013-07-11 12:21 ` Eric Blake
2013-07-09 9:53 ` [Qemu-devel] [RFC PATCH 05/11] qapi: Add visitor for implicit structs Kevin Wolf
2013-07-11 12:41 ` Eric Blake
2013-07-11 12:51 ` Eric Blake
2013-07-09 9:53 ` [Qemu-devel] [RFC PATCH 06/11] qapi: Flat unions with arbitrary discriminator Kevin Wolf
2013-07-11 14:16 ` Eric Blake
2013-07-09 9:53 ` [Qemu-devel] [RFC PATCH 07/11] qapi: Add consume argument to qmp_input_get_object() Kevin Wolf
2013-07-11 19:17 ` Eric Blake
2013-07-09 9:53 ` [Qemu-devel] [RFC PATCH 08/11] qapi: Anonymous unions Kevin Wolf
2013-07-11 19:47 ` Eric Blake
2013-07-12 8:55 ` Kevin Wolf
2013-07-12 14:15 ` Eric Blake
2013-07-09 9:53 ` [Qemu-devel] [RFC PATCH 09/11] Implement qdict_flatten() Kevin Wolf
2013-07-11 20:25 ` Eric Blake
2013-07-16 8:59 ` Kevin Wolf
2013-07-09 9:53 ` [Qemu-devel] [RFC PATCH 10/11] block: Allow "driver" option on the top level Kevin Wolf
2013-07-11 22:30 ` Eric Blake
2013-07-09 9:53 ` [Qemu-devel] [RFC PATCH 11/11] [WIP] block: Implement 'blockdev-add' QMP command Kevin Wolf
2013-07-11 22:45 ` Eric Blake
2013-07-12 9:40 ` Kevin Wolf
2013-07-12 14:27 ` Eric Blake
2013-07-12 9:55 ` [Qemu-devel] [RFC PATCH 00/11] qapi changes in preparation for blockdev-add Laszlo Ersek
2013-07-12 10:53 ` 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=51DEA93C.90500@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=kwolf@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@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.