From: Eric Blake <eblake@redhat.com>
To: "Daniel P. Berrange" <berrange@redhat.com>,
Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PULL 14/15] qapi: Don't box branches of flat unions
Date: Tue, 23 Feb 2016 08:18:55 -0700 [thread overview]
Message-ID: <56CC785F.9020708@redhat.com> (raw)
In-Reply-To: <20160223145039.GH22780@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1884 bytes --]
On 02/23/2016 07:50 AM, Daniel P. Berrange wrote:
> On Fri, Feb 19, 2016 at 01:18:05PM +0100, Markus Armbruster wrote:
>> From: Eric Blake <eblake@redhat.com>
>>
>> There's no reason to do two malloc's for a flat union; let's just
>> inline the branch struct directly into the C union branch of the
>> flat union.
>>
>
> My code needs todo something a little different though - it needs
> to directly visit one of the union branches. Previously, I could
> allocate a QCryptoBlockOptions and then visit a specific union
> branch like this:
>
> QCryptoBlockOptions *opts = NULL;
>
> opts = g_new0(QCryptoBlockOptions, 1);
> opts.format = Q_CRYPTO_BLOCK_FORMAT_LUKS
>
> visit_type_QCryptoBlockOptionsLUKS(v, "luks", &opts.u.luks, errp)
which allocated a pointer and visited the fields. We no longer need the
pointer, but still need the fields visited.
>
>
> I need todo this, because my visitor instance does not have any
> 'format' field to visit - we know the format upfront from the
> block layer driver choice. So we need to directly visit the
> appropriate inline union branch. This no longer works, because
> the opts.u.luks field is now inlined instead of being boxed :-(
You're using OptsVisitor, right? Is it possible to hack the QemuOpts
that you feed to opts_visitor_new() to include a 'format' field?
>
> I could visit_type_QCryptoBlockOptionsLUKS_fields(v, opts.u.luks, errp)
> but the '_fields' methods are all declared static in qapi-visit.c
> preventing their use.
>
> IMHO, now that QAPI inlines the flat unions, we should be making
> the _fields() methods public.
But my suggestion would just be a hack. Yours makes more sense in the
long run, so I'll go ahead and propose that patch.
--
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:[~2016-02-23 15:19 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-19 12:17 [Qemu-devel] [PULL 00/15] QAPI patches for 2016-02-19 Markus Armbruster
2016-02-19 12:17 ` [Qemu-devel] [PULL 01/15] qapi-visit: Honor prefix of discriminator enum Markus Armbruster
2016-02-19 12:17 ` [Qemu-devel] [PULL 02/15] qapi: Simplify excess input reporting in input visitors Markus Armbruster
2016-02-19 12:17 ` [Qemu-devel] [PULL 03/15] qapi: Forbid empty unions and useless alternates Markus Armbruster
2016-02-19 12:17 ` [Qemu-devel] [PULL 04/15] qapi: Forbid 'any' inside an alternate Markus Armbruster
2016-02-19 12:17 ` [Qemu-devel] [PULL 05/15] qapi: Add tests of complex objects within alternate Markus Armbruster
2016-02-19 12:17 ` [Qemu-devel] [PULL 06/15] qapi-visit: Simplify how we visit common union members Markus Armbruster
2016-02-19 12:17 ` [Qemu-devel] [PULL 07/15] qapi: Visit variants in visit_type_FOO_fields() Markus Armbruster
2016-02-19 12:17 ` [Qemu-devel] [PULL 08/15] qapi-visit: Unify struct and union visit Markus Armbruster
2016-02-19 12:18 ` [Qemu-devel] [PULL 09/15] qapi-visit: Less indirection in visit_type_Foo_fields() Markus Armbruster
2016-02-19 12:18 ` [Qemu-devel] [PULL 10/15] qapi: Adjust layout of FooList types Markus Armbruster
2016-02-19 12:18 ` [Qemu-devel] [PULL 11/15] qapi: Emit structs used as variants in topological order Markus Armbruster
2016-02-19 12:18 ` [Qemu-devel] [PULL 12/15] qapi-visit: Use common idiom in gen_visit_fields_decl() Markus Armbruster
2016-02-19 12:18 ` [Qemu-devel] [PULL 13/15] qapi: Don't box struct branch of alternate Markus Armbruster
2016-02-19 12:18 ` [Qemu-devel] [PULL 14/15] qapi: Don't box branches of flat unions Markus Armbruster
2016-02-23 14:50 ` Daniel P. Berrange
2016-02-23 15:18 ` Eric Blake [this message]
2016-02-23 15:30 ` Eric Blake
2016-02-23 15:33 ` Daniel P. Berrange
2016-02-19 12:18 ` [Qemu-devel] [PULL 15/15] qapi: Change visit_start_implicit_struct to visit_start_alternate Markus Armbruster
2016-02-19 15:19 ` [Qemu-devel] [PULL 00/15] QAPI patches for 2016-02-19 Peter Maydell
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=56CC785F.9020708@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@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 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).