From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: Fam Zheng <famz@redhat.com>,
qemu-devel@nongnu.org, wenchaoqemu@gmail.com,
Luiz Capitulino <lcapitulino@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v4 04/19] qapi: Document type-safety considerations
Date: Mon, 22 Sep 2014 10:53:25 -0600 [thread overview]
Message-ID: <54205405.3020700@redhat.com> (raw)
In-Reply-To: <87zjdrhlw3.fsf@blackfin.pond.sub.org>
[-- Attachment #1: Type: text/plain, Size: 3363 bytes --]
On 09/22/2014 06:37 AM, Markus Armbruster wrote:
> Eric Blake <eblake@redhat.com> writes:
>
>> === Union types ===
>>
>> +Usage: { 'union': 'str', 'data': 'dict', '*base': 'complex-type-name',
>> + '*discriminator': 'enum-type-name' }
>> +or: { 'union': 'str', 'data': 'dict', 'discriminator': {} }
>> +
>
> Suggest to split usage into simple union, flat union and anonymous
> union, like this:
>
> Usage: { 'union': 'str', 'data': 'dict', '*base': 'complex-type-name' }
^ simple
> or: { 'union': 'str', 'data': 'dict', 'base': 'complex-type-name',
> '*discriminator': 'enum-type-name' }
^ flat
> or: { 'union': 'str', 'data': 'dict', 'discriminator': {} }
^ anonymous
Except that someday, I'd like to have:
{ 'union': str', 'data': 'dict', 'discriminator': 'enum-type-name' }
which, when compared with the simple and flat versions, means that base
and discriminator are equally optional. But you are right that we don't
have that form yet, and that the code currently requires that if base is
specified, then discriminator is non-optional. I'll have to tweak this.
>> +
>> +In rare cases, QAPI cannot express a type-safe representation of a
>> +corresponding QMP command. In these cases, if the command expression
>> +includes the key 'gen' with value 'no', then the 'data' or 'returns'
>
> The implementation actually ignores the value of 'gen', but specifying
> it must be 'no' doesn't hurt.
Actually, see patch 14/19 later in the series, where I fix the code to
enforce that it must be 'no' :)
>
>> +member that intends to bypass generated type-safety and do its own
>> +manual validation should use '**' rather than a valid type name.
>> +Please try to avoid adding new commands that rely on this, and instead
>> +use type-safe unions. For an example of bypass usage:
>> +
>> + { 'command': 'netdev_add',
>> + 'data': {'type': 'str', 'id': 'str', '*props': '**'},
>> + 'gen': 'no' }
>> +
>> +Normally, the QAPI schema is used to describe synchronous exchanges,
>> +where a response is expected. But in some cases, the action of a
>> +command is expected to change state in a way that a successful
>> +response is not possible (a failure message still returns a
>> +dictionary). In this case, the command expression should include the
>> +optional key 'success-response' with value 'no'.
>
> Learned something new here.
To date, only qga uses this form.
>> +
>> +Events are defined with the keyword 'event'. It is not allowed to
>> +name an event 'MAX', since the generator also produces a C enumeration
>> +of all event names with a generated _MAX value at the end.
>
> One of the several places where the generator can thoughtlessly produce
> clashing identifiers. You're documenting one of them, which is an
> improvement of sorts.
I also enhance things later in the series to enforce this documentation :)
>
> Major improvement, thank you very much!
I've trimmed your other comments (such as suggested line breaks) because
I agree with them, and will incorporate them into either v5 (if the
series needs respinning) or a followup patch (if this is the only patch
that needs improvement).
--
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: 539 bytes --]
next prev parent reply other threads:[~2014-09-22 16:53 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-19 22:24 [Qemu-devel] [PATCH v4 00/19] drop qapi nested structs Eric Blake
2014-09-19 22:24 ` [Qemu-devel] [PATCH v4 01/19] qapi: Consistent whitespace in tests/Makefile Eric Blake
2014-09-22 12:40 ` Markus Armbruster
2014-09-19 22:24 ` [Qemu-devel] [PATCH v4 02/19] qapi: Ignore files created during make check Eric Blake
2014-09-23 8:07 ` Markus Armbruster
2014-09-19 22:24 ` [Qemu-devel] [PATCH v4 03/19] qapi: Update docs given recent event, spacing fixes Eric Blake
2014-09-22 12:40 ` Markus Armbruster
2014-09-19 22:24 ` [Qemu-devel] [PATCH v4 04/19] qapi: Document type-safety considerations Eric Blake
2014-09-22 12:37 ` Markus Armbruster
2014-09-22 16:53 ` Eric Blake [this message]
2014-09-19 22:24 ` [Qemu-devel] [PATCH v4 05/19] qapi: Add some enum tests Eric Blake
2014-09-22 12:43 ` Markus Armbruster
2014-09-19 22:24 ` [Qemu-devel] [PATCH v4 06/19] qapi: Better error messages for bad enums Eric Blake
2014-09-23 14:23 ` Markus Armbruster
2014-09-23 15:59 ` Eric Blake
2014-09-24 7:46 ` Markus Armbruster
2014-09-19 22:24 ` [Qemu-devel] [PATCH v4 07/19] qapi: Add some expr tests Eric Blake
2014-09-23 14:26 ` Markus Armbruster
2014-09-19 22:24 ` [Qemu-devel] [PATCH v4 08/19] qapi: Better error messages for bad expressions Eric Blake
2014-09-23 14:56 ` Markus Armbruster
2014-09-23 16:11 ` Eric Blake
2014-09-24 7:34 ` Markus Armbruster
2014-09-24 9:25 ` Kevin Wolf
2014-09-24 11:14 ` Markus Armbruster
2014-09-26 9:15 ` Markus Armbruster
2014-09-26 9:25 ` Kevin Wolf
2014-09-26 11:40 ` Markus Armbruster
2014-09-19 22:24 ` [Qemu-devel] [PATCH v4 09/19] qapi: Add tests of redefined expressions Eric Blake
2014-09-24 11:24 ` Markus Armbruster
2014-09-19 22:24 ` [Qemu-devel] [PATCH v4 10/19] qapi: Better error messages for duplicated expressions Eric Blake
2014-09-24 11:58 ` Markus Armbruster
2014-09-24 14:10 ` Eric Blake
2014-09-24 15:29 ` Markus Armbruster
2014-09-19 22:24 ` [Qemu-devel] [PATCH v4 11/19] qapi: Add tests of type bypass Eric Blake
2014-09-24 16:10 ` Markus Armbruster
2014-09-19 22:24 ` [Qemu-devel] [PATCH v4 12/19] qapi: Add some type check tests Eric Blake
2014-09-25 7:34 ` Markus Armbruster
2014-09-25 8:06 ` Markus Armbruster
2014-09-25 14:00 ` Eric Blake
2014-09-25 16:19 ` Markus Armbruster
2015-03-23 15:33 ` [Qemu-devel] RFC: 'alternate' qapi top-level expression [was: [PATCH v4 12/19] qapi: Add some type check tests] Eric Blake
2015-03-23 19:28 ` Markus Armbruster
2014-09-25 13:54 ` [Qemu-devel] [PATCH v4 12/19] qapi: Add some type check tests Eric Blake
2014-09-25 16:12 ` Markus Armbruster
2014-09-25 16:32 ` Eric Blake
2014-09-19 22:24 ` [Qemu-devel] [PATCH v4 13/19] qapi: More rigourous checking of types Eric Blake
2014-09-26 9:26 ` Markus Armbruster
2014-09-29 8:27 ` Markus Armbruster
2014-09-29 14:26 ` Eric Blake
2014-09-29 14:35 ` Eric Blake
2014-09-19 22:24 ` [Qemu-devel] [PATCH v4 14/19] qapi: More rigorous checking for type safety bypass Eric Blake
2014-09-29 8:38 ` Markus Armbruster
2014-09-29 14:33 ` Eric Blake
2014-09-29 16:35 ` Markus Armbruster
2014-09-19 22:25 ` [Qemu-devel] [PATCH v4 15/19] qapi: Merge UserDefTwo and UserDefNested in tests Eric Blake
2014-09-19 22:25 ` [Qemu-devel] [PATCH v4 16/19] qapi: Drop tests for inline subtypes Eric Blake
2014-09-19 22:25 ` [Qemu-devel] [PATCH v4 17/19] qapi: Drop inline subtype in query-version Eric Blake
2014-09-30 17:40 ` Markus Armbruster
2014-09-19 22:25 ` [Qemu-devel] [PATCH v4 18/19] qapi: Drop inline subtype in query-pci Eric Blake
2014-09-19 22:25 ` [Qemu-devel] [PATCH v4 19/19] qapi: Drop support for inline subtypes Eric Blake
2014-09-30 17:47 ` Markus Armbruster
2014-09-26 15:42 ` [Qemu-devel] [PATCH v4 00/19] drop qapi nested structs Eric Blake
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=54205405.3020700@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=famz@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=wenchaoqemu@gmail.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 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).