All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>, Fam Zheng <famz@redhat.com>,
	Eduardo Habkost <ehabkost@redhat.com>,
	"open list:Block layer core" <qemu-block@nongnu.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	Jason Wang <jasowang@redhat.com>,
	qemu-devel@nongnu.org, Vincenzo Maffione <v.maffione@gmail.com>,
	armbru@redhat.com, Igor Mammedov <imammedo@redhat.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Giuseppe Lettieri <g.lettieri@iet.unipi.it>,
	Luiz Capitulino <lcapitulino@redhat.com>,
	Luigi Rizzo <rizzo@iet.unipi.it>,
	Michael Roth <mdroth@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH 12/17] qapi: Don't special-case simple union wrappers
Date: Mon, 22 Feb 2016 10:48:25 +0000	[thread overview]
Message-ID: <20160222104825.GI28195@redhat.com> (raw)
In-Reply-To: <1455927587-28033-13-git-send-email-eblake@redhat.com>

On Fri, Feb 19, 2016 at 05:19:42PM -0700, Eric Blake wrote:
> Simple unions were carrying a special case that hid their 'data'
> QMP member from the resulting C struct, via the hack method
> QAPISchemaObjectTypeVariant.simple_union_type().  But using the
> work we started by unboxing flat union and alternate branches, we
> expose the simple union's implicit type in qapi-types.h as an
> anonymous type, and drop our last use of the hack.
> 
> | struct ImageInfoSpecific {
> |     ImageInfoSpecificKind type;
> |     union { /* union tag is @type */
> |         void *data;
> |-        ImageInfoSpecificQCow2 *qcow2;
> |-        ImageInfoSpecificVmdk *vmdk;
> |+        struct {
> |+            ImageInfoSpecificQCow2 *data;
> |+        } qcow2;
> |+        struct {
> |+            ImageInfoSpecificVmdk *data;
> |+        } vmdk;
> |     } u;
> | };
> 
> All clients of simple unions have to adjust from using su->u.member
> to now using su->u.member.data; while this touches a number of
> files in the tree, some earlier cleanup patches helped minimize
> the change to the initialization of a temporary variable rather
> than every single field access.  The generated qapi-visit.c code
> is included in the files affected by the layout change, with a
> diff that looks like:
> 
> |@@ -4510,10 +4567,16 @@ static void visit_type_ImageInfoSpecific
> |     }
> |     switch (obj->type) {
> |     case IMAGE_INFO_SPECIFIC_KIND_QCOW2:
> |-        visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2, &err);
> |+        visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2.data, &err);
> |+        if (err) {
> |+            goto out;
> |+        }
> |         break;
> |     case IMAGE_INFO_SPECIFIC_KIND_VMDK:
> |-        visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk, &err);
> |+        visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk.data, &err);
> |+        if (err) {
> |+            goto out;
> |+        }
> |         break;
> |     default:
> |         abort();
> |     }
> |
> | out:
> |     error_propagate(errp, err);
> 
> The added error checks there are a side effect of visiting all
> fields of each implicit struct (there is only one such field for
> simple unions); but do not change semantics, and will be important
> when later patches allow for flat unions with anonymous branches
> with more than one field.  That future work will look like:
> { 'union': 'Foo', 'base': 'Base', 'discriminator': 'type',
>   'data': { 'branch1': { 'anonymous': 'str', 'number': 'int' },
>             'branch2': 'Named' } }
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  scripts/qapi.py                 | 10 -----
>  scripts/qapi-types.py           | 22 ++++++++---
>  scripts/qapi-visit.py           | 15 +++-----
>  backends/baum.c                 |  2 +-
>  backends/msmouse.c              |  2 +-
>  block/nbd.c                     |  6 +--
>  block/qcow2.c                   |  6 +--
>  block/vmdk.c                    |  8 ++--
>  blockdev.c                      | 24 ++++++------
>  hmp.c                           |  8 ++--
>  hw/char/escc.c                  |  2 +-
>  hw/input/hid.c                  |  8 ++--
>  hw/input/ps2.c                  |  6 +--
>  hw/input/virtio-input-hid.c     |  8 ++--
>  hw/mem/pc-dimm.c                |  4 +-
>  net/dump.c                      |  2 +-
>  net/hub.c                       |  2 +-
>  net/l2tpv3.c                    |  2 +-
>  net/net.c                       |  4 +-
>  net/netmap.c                    |  2 +-
>  net/slirp.c                     |  2 +-
>  net/socket.c                    |  2 +-
>  net/tap.c                       |  4 +-
>  net/vhost-user.c                |  2 +-
>  numa.c                          |  4 +-
>  qemu-char.c                     | 82 +++++++++++++++++++++--------------------
>  qemu-nbd.c                      |  6 +--
>  replay/replay-input.c           | 44 +++++++++++-----------
>  spice-qemu-char.c               | 14 ++++---
>  tests/test-io-channel-socket.c  | 40 ++++++++++----------
>  tests/test-qmp-commands.c       |  2 +-
>  tests/test-qmp-input-visitor.c  | 25 +++++++------
>  tests/test-qmp-output-visitor.c | 24 ++++++------
>  tpm.c                           |  2 +-
>  ui/console.c                    |  4 +-
>  ui/input-keymap.c               | 10 ++---
>  ui/input-legacy.c               |  8 ++--
>  ui/input.c                      | 34 ++++++++---------
>  ui/vnc-auth-sasl.c              |  3 +-
>  ui/vnc.c                        | 29 ++++++++-------
>  util/qemu-sockets.c             | 35 +++++++++---------
>  41 files changed, 262 insertions(+), 257 deletions(-)

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>


Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

  reply	other threads:[~2016-02-22 10:48 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-20  0:19 [Qemu-devel] [PATCH 00/17] qapi implicit types (continuing the qapi cleanup theme) Eric Blake
2016-02-20  0:19 ` [Qemu-devel] [PATCH 01/17] chardev: Properly initialize ChardevCommon components Eric Blake
2016-02-22 10:13   ` Daniel P. Berrange
2016-02-22 10:18   ` Paolo Bonzini
2016-02-20  0:19 ` [Qemu-devel] [PATCH 02/17] chardev: Shorten references into ChardevBackend Eric Blake
2016-02-22 10:16   ` Daniel P. Berrange
2016-02-20  0:19 ` [Qemu-devel] [PATCH 03/17] util: Shorten references into SocketAddress Eric Blake
2016-02-22 10:18   ` Daniel P. Berrange
2016-02-20  0:19 ` [Qemu-devel] [PATCH 04/17] ui: Shorten references into InputEvent Eric Blake
2016-02-22 10:27   ` Daniel P. Berrange
2016-02-20  0:19 ` [Qemu-devel] [PATCH 05/17] qapi: Avoid use of 'data' member of qapi unions Eric Blake
2016-02-22 10:34   ` Daniel P. Berrange
2016-02-20  0:19 ` [Qemu-devel] [PATCH 06/17] chardev: Drop useless ChardevDummy type Eric Blake
2016-02-22 10:36   ` Daniel P. Berrange
2016-02-20  0:19 ` [Qemu-devel] [PATCH 07/17] qapi: Drop useless 'data' member of unions Eric Blake
2016-02-22 10:39   ` Daniel P. Berrange
2016-02-20  0:19 ` [Qemu-devel] [PATCH 08/17] qapi-visit: Factor out gen_visit_fields_call() Eric Blake
2016-02-20  0:19 ` [Qemu-devel] [PATCH 09/17] qapi: Add type.is_empty() helper Eric Blake
2016-02-20  0:19 ` [Qemu-devel] [PATCH 10/17] qapi: Fix command with named empty argument type Eric Blake
2016-02-20  0:19 ` [Qemu-devel] [PATCH 11/17] qapi-visit: Simplify visit of empty branch in union Eric Blake
2016-02-20  0:19 ` [Qemu-devel] [PATCH 12/17] qapi: Don't special-case simple union wrappers Eric Blake
2016-02-22 10:48   ` Daniel P. Berrange [this message]
2016-02-20  0:19 ` [Qemu-devel] [PATCH 13/17] qapi-visit: Move error check into gen_visit_fields_call() Eric Blake
2016-02-20  0:19 ` [Qemu-devel] [PATCH 14/17] qapi: Allow anonymous base for flat union Eric Blake
2016-02-20  0:19 ` [Qemu-devel] [PATCH 15/17] qapi: Use anonymous base in SchemaInfo Eric Blake
2016-02-20  0:19 ` [Qemu-devel] [PATCH 16/17] qapi: Use anonymous base in CpuInfo Eric Blake
2016-02-20  0:19 ` [Qemu-devel] [PATCH 17/17] qapi: Make c_type() more OO-like 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=20160222104825.GI28195@redhat.com \
    --to=berrange@redhat.com \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=famz@redhat.com \
    --cc=g.lettieri@iet.unipi.it \
    --cc=imammedo@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=jasowang@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rizzo@iet.unipi.it \
    --cc=samuel.thibault@ens-lyon.org \
    --cc=v.maffione@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 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.