From: Eric Blake <eblake@redhat.com>
To: "Kővágó, Zoltán" <dirty.ice.hu@gmail.com>, qemu-devel@nongnu.org
Cc: Markus Armbruster <armbru@redhat.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Eduardo Habkost <ehabkost@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 03/49] qapi: convert NumaOptions into a flat union
Date: Fri, 4 Sep 2015 15:02:41 -0600 [thread overview]
Message-ID: <55EA06F1.2000602@redhat.com> (raw)
In-Reply-To: <7dcbdc8169de6b0090aa1ba89e7426fb3cd0e6cf.1440171025.git.DirtY.iCE.hu@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 5895 bytes --]
On 08/21/2015 09:36 AM, Kővágó, Zoltán wrote:
> Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com>
The subject line is a one-line "what", and the commit body should be the
"why" - all but the most trivial "what" deserve a non-empty commit body.
In particular, I think you NEED to mention in the commit body that the
conversion does not strictly follow the QMP wire equivalency between
simple and flat unions as spelled out in docs/qapi-code-gen.txt, but
that this is okay because we do not have any QMP commands that use the
NumaOptions type to begin with (so there is no observable change to any
commands sent over QMP). Meanwhile, mention that the change is made to
convert the generated C code into something that will ultimately be
easier to work with.
> ---
> numa.c | 2 +-
> qapi-schema.json | 47 ++++++++++++++++++++++++++++++++++++-----------
> 2 files changed, 37 insertions(+), 12 deletions(-)
>
>
> +++ b/numa.c
> @@ -227,7 +227,7 @@ static int parse_numa(void *opaque, QemuOpts *opts, Error **errp)
> }
>
> switch (object->kind) {
> - case NUMA_OPTIONS_KIND_NODE:
> + case NUMA_DRIVER_NODE:
Now that commit 0f61af3 has landed, you'll have to rebase your patch to
use 'switch (object->type) {' here. Basically, the conversion from
simple to flat union now (temporarily) generates a different tag name
for simple unions than for flat unions (although I have a pending patch
[1] that solves that, but by using object->type everywhere).
[1] https://lists.gnu.org/archive/html/qemu-devel/2015-08/msg02061.html
> +++ b/qapi-schema.json
> @@ -3536,17 +3536,6 @@
> 'data': { '*console':'int', 'events': [ 'InputEvent' ] } }
>
> ##
> -# @NumaOptions
> -#
> -# A discriminated record of NUMA options. (for OptsVisitor)
> -#
> -# Since 2.1
> -##
> -{ 'union': 'NumaOptions',
> - 'data': {
> - 'node': 'NumaNodeOptions' }}
If we were following the equivalency documented in
docs/qapi-code-gen.txt, then this part is okay (you are removing the
simple union),...
> ##
> +# @NumaDriver
> +#
> +# List of possible numa drivers.
> +#
> +# Since: 2.5
> +##
> +{ 'enum': 'NumaDriver',
> + 'data': [ 'node' ] }
...this part is okay (you are creating a new enum, which covers all
branches present in the former simple union),...
> +
> +##
> +# @NumaCommonOptions
> +#
> +# Common set of numa options.
> +#
> +# @type: the numa driver to use
> +#
> +# Since: 2.5
> +##
> +{ 'struct': 'NumaCommonOptions',
> + 'data': {
> + 'type': 'NumaDriver' } }
...this part is okay (you are creating a new base type, which consists
of a single common member named 'type' of the new enum type),...
[By the way, while the base type is currently required, I have a pending
patch that would add syntax sugar to avoid it, so maybe you want to wait
for my patch [2] to land?
[2] https://lists.gnu.org/archive/html/qemu-devel/2015-08/msg02321.html
so you could write 'base': { 'type': 'NumaDriver' } directly in the flat
union, instead of having to declare NumaCommonOptions]
> +
> +##
> +# @NumaOptions
> +#
> +# A discriminated record of NUMA options. (for OptsVisitor)
> +#
> +# Since 2.1
> +##
> +{ 'union': 'NumaOptions',
> + 'base': 'NumaCommonOptions',
> + 'discriminator': 'type',
> + 'data': {
> + 'node': 'NumaNodeOptions' }}
...but this part is missing one piece of the conversion (to be strictly
QMP compatible with the simple union, each branch of the flat union must
be a NEW type that contains a single member 'data' of the old type).
That is, if we were TRYING to preserve QMP compatibility, we'd need:
{ 'struct': 'NumaNodeOptionsWrapper',
'data': { 'data': 'NumaNodeOptions' } }
{ 'union': 'NumaOptions', 'base': 'NumaCommonOptions',
'discriminator': 'type', 'data': {
'node': 'NumaNodeOptionsWrapper' } }
The difference on the wire is that the old simple union, or with my
version of the flat union, would allow:
{ 'command': 'foo', 'arguments': {
'type': 'numa', 'data': { 'nodeid': 1 } } }
while the new flat union as you wrote it reduces nesting:
{ 'command': 'foo', 'arguments': {
'type': 'numa', 'nodeid': 1 } }
That said, there is another point of view to worry about, which is what
C structures get generated. Here, I'm using output after Markus' v4
series is applied (since it is slightly more legible than current
qemu.git mainline generated output) (and although I still have further
pending patches that improve it further). The pre-patch simple union
would generate:
struct NumaOptions {
NumaOptionsKind kind;
union { /* union tag is @kind */
void *data;
NumaNodeOptions *node;
};
};
and your version would generate (notice the rename from 'kind' to 'type'):
struct NumaOptions {
/* Members inherited from NumaCommonOptions: */
NumaDriver type;
/* Own members: */
union { /* union tag is @type */
void *data;
NumaNodeOptions *node;
};
};
but my proposal to keep QMP compatibility would generate an incompatible
layer of boxing:
struct NumaOptions {
/* Members inherited from NumaCommonOptions: */
NumaDriver type;
/* Own members: */
union { /* union tag is @type */
void *data;
NumaNodeOptionsWrapper *node;
};
};
So, in conclusion, since no existing QMP command used the old type, and
your choice of changes preserved the generated struct layout, it means
we have no change to command line parsing and no user-visible changes to
worry about. And I'm fine with this patch, once you improve the commit
message and rebase to mainline:
Reviewed-by: Eric Blake <eblake@redhat.com>
--
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:[~2015-09-04 21:02 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-21 15:36 [Qemu-devel] [PATCH v2 00/49] audio: -audiodev option, multiple options Kővágó, Zoltán
2015-08-21 15:36 ` [Qemu-devel] [PATCH v2 01/49] opts: produce valid command line in qemu_opts_print Kővágó, Zoltán
2015-09-04 20:20 ` Eric Blake
2015-08-21 15:36 ` [Qemu-devel] [PATCH v2 02/49] qapi: support implicit structs in OptsVisitor Kővágó, Zoltán
2015-09-04 20:26 ` Eric Blake
2015-08-21 15:36 ` [Qemu-devel] [PATCH v2 03/49] qapi: convert NumaOptions into a flat union Kővágó, Zoltán
2015-08-21 23:13 ` Eduardo Habkost
2015-08-22 15:56 ` Kővágó Zoltán
2015-08-26 15:31 ` Eduardo Habkost
2015-09-04 21:11 ` Eric Blake
2015-09-04 21:02 ` Eric Blake [this message]
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 04/49] net: remove NetLegacy struct Kővágó, Zoltán
2015-09-04 21:25 ` Eric Blake
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 05/49] net: use Netdev instead of NetClientOptions in client init Kővágó, Zoltán
2015-09-04 21:36 ` Eric Blake
2015-09-04 21:49 ` Eric Blake
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 06/49] qapi: change Netdev into a flat union Kővágó, Zoltán
2015-09-04 23:13 ` Eric Blake
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 07/49] qapi: reorder NetdevBase and Netdev Kővágó, Zoltán
2015-09-04 23:18 ` Eric Blake
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 08/49] qapi: qapi for audio backends Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 09/49] qapi: support nested structs in OptsVisitor Kővágó, Zoltán
2015-09-04 23:21 ` Eric Blake
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 10/49] audio: use qapi AudioFormat instead of audfmt_e Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 11/49] audio: -audiodev command line option: documentation Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 12/49] audio: -audiodev command line option basic implementation Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 13/49] alsaaudio: port to -audiodev config Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 14/49] coreaudio: " Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 15/49] dsoundaudio: " Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 16/49] noaudio: " Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 17/49] ossaudio: " Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 18/49] paaudio: " Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 19/49] sdlaudio: " Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 20/49] spiceaudio: " Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 21/49] wavaudio: " Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 22/49] audio: -audiodev command line option: cleanup Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 23/49] audio: reduce glob_audio_state usage Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 24/49] audio: basic support for multi backend audio Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 25/49] audio: add audiodev properties to frontends Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 26/49] audio: audiodev= parameters no longer optional when -audiodev present Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 27/49] paaudio: do not create multiple connections to the same server Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 28/49] paaudio: do not move stream when sink/source name is specified Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 29/49] paaudio: properly disconnect streams in fini_* Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 30/49] audio: remove audio_MIN, audio_MAX Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 31/49] audio: do not run each backend in audio_run Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 32/49] paaudio: fix playback glitches Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 33/49] audio: remove read and write pcm_ops Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 34/49] audio: use size_t where makes sense Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 35/49] audio: api for mixeng code free backends Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 36/49] alsaaudio: port to the new audio backend api Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 37/49] coreaudio: " Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 38/49] dsoundaudio: " Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 39/49] noaudio: " Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 40/49] ossaudio: " Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 41/49] paaudio: " Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 42/49] sdlaudio: " Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 44/49] wavaudio: " Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 45/49] audio: remove remains of the old " Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 46/49] audio: unify input and output mixeng buffer management Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 47/49] audio: remove hw->samples, buffer_size_in/out pcm_ops Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 48/49] audio: common rate control code for timer based outputs Kővágó, Zoltán
2015-08-21 15:37 ` [Qemu-devel] [PATCH v2 49/49] audio: split ctl_* functions into enable_* and volume_* Kővágó, Zoltán
2015-09-03 10:15 ` [Qemu-devel] [PATCH v2 00/49] audio: -audiodev option, multiple options Gerd Hoffmann
2015-09-03 12:52 ` Kővágó Zoltán
2015-09-03 15:07 ` Eric Blake
2015-09-06 16:38 ` Kővágó Zoltán
2015-09-07 6:49 ` Markus Armbruster
2015-09-03 10:42 ` Gerd Hoffmann
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=55EA06F1.2000602@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=dirty.ice.hu@gmail.com \
--cc=ehabkost@redhat.com \
--cc=kraxel@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.