From: Paolo Bonzini <pbonzini@redhat.com>
To: Markus Armbruster <armbru@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: amit.shah@redhat.com, qemu-devel@nongnu.org, quintela@redhat.com
Subject: Re: [Qemu-devel] qapi: What does "'gen': false" actually do, and when should I use it?
Date: Fri, 19 Jun 2015 12:40:27 +0200 [thread overview]
Message-ID: <5583F19B.2010709@redhat.com> (raw)
In-Reply-To: <87fv61w9vn.fsf_-_@blackfin.pond.sub.org>
On 09/06/2015 10:42, Markus Armbruster wrote:
> Part 2: When to use it?
>
> We use 'gen': false when we can't (be bothered to) specify the exact
> type of an argument or result.
>
> Bad example: netdev_add
>
> We have arguments 'type': 'str' and '*props': '**'.
>
> We should have a union tagged by network backend type. For each
> type, the union holds the type's properties (if any).
The problem with this is that netdev_add was not type safe, because it
uses qemu_opts_from_qdict and QemuOpts is exclusively string-based. So
you could write 'port': '123' or 'port': 123, and both would work, the
conversion to integer is done by the QemuOptsVisitor.
Note that device_add would have the same problem.
Paolo
> Better example: device_add (but that's not even QAPIfied, yet)
>
> If QAPIfied, we'd have arguments like 'driver': 'str' and '*props':
> '**'.
>
> Looks just like netdev_add. The difference is that network backends
> and their properties are defined in one place, but device models and
> their properties aren't. They get collected at run time. As long
> as the schema is fixed at compile-time, it can't express the
> resulting tagged union.
>
> Another good example: qom-get
>
> We have a return value '**'.
>
> The run time type is the type of the property identified by the
> arguments. Therefore, the compile time type can only be the union
> of all property types, which effectively boils down to "anything".
>
> The only way to say "anything" right now is '**'. Requires 'gen':
> false. I figure we could extend the generators to support '**' in a
> few places, which may let us avoid 'gen': false here.
>
> Drawback of '**': introspection knows nothing.
>
> Introspection knowing nothing about netdev_add's and device_add's
> acceptable properties is a big, painful gap.
>
> Please don't invent new reasons for 'gen': false without a very
> compelling use case. If you think you have one, we need to talk to make
> sure use of 'gen': false really beats the alternatives. Alternatives
> may include extending the generators.
>
>
next prev parent reply other threads:[~2015-06-19 10:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-05 9:50 [Qemu-devel] Adding new migration-parameters - any easier way? Dr. David Alan Gilbert
2015-06-05 10:23 ` Dr. David Alan Gilbert
2015-06-05 12:30 ` Eric Blake
2015-06-05 14:00 ` Dr. David Alan Gilbert
2015-06-08 12:48 ` Markus Armbruster
2015-06-08 14:57 ` Dr. David Alan Gilbert
2015-06-09 6:36 ` Markus Armbruster
2015-06-09 8:42 ` [Qemu-devel] qapi: What does "'gen': false" actually do, and when should I use it? (was: Adding new migration-parameters - any easier way?) Markus Armbruster
2015-06-19 10:40 ` Paolo Bonzini [this message]
2015-07-02 12:07 ` [Qemu-devel] qapi: What does "'gen': false" actually do, and when should I use it? Markus Armbruster
2015-07-02 12:32 ` Markus Armbruster
2015-06-17 10:46 ` [Qemu-devel] Adding new migration-parameters - any easier way? zhanghailiang
2015-06-19 8:11 ` Markus Armbruster
2015-06-23 1:43 ` zhanghailiang
2015-06-23 7:50 ` Markus Armbruster
2015-06-23 8:03 ` zhanghailiang
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=5583F19B.2010709@redhat.com \
--to=pbonzini@redhat.com \
--cc=amit.shah@redhat.com \
--cc=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--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.