From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48409) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYEjs-0004ZE-Sr for qemu-devel@nongnu.org; Tue, 23 Feb 2016 10:19:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aYEjo-0007tD-OR for qemu-devel@nongnu.org; Tue, 23 Feb 2016 10:19:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50818) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYEjo-0007so-Fj for qemu-devel@nongnu.org; Tue, 23 Feb 2016 10:18:56 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 0BD1D30248F for ; Tue, 23 Feb 2016 15:18:56 +0000 (UTC) References: <1455884286-26272-1-git-send-email-armbru@redhat.com> <1455884286-26272-15-git-send-email-armbru@redhat.com> <20160223145039.GH22780@redhat.com> From: Eric Blake Message-ID: <56CC785F.9020708@redhat.com> Date: Tue, 23 Feb 2016 08:18:55 -0700 MIME-Version: 1.0 In-Reply-To: <20160223145039.GH22780@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="t09lrvwsf3cxjv5SuK7THd3TEKJk5Lqsh" Subject: Re: [Qemu-devel] [PULL 14/15] qapi: Don't box branches of flat unions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" , Markus Armbruster Cc: qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --t09lrvwsf3cxjv5SuK7THd3TEKJk5Lqsh Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 >> >> 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. >> >=20 > 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: >=20 > QCryptoBlockOptions *opts =3D NULL; >=20 > opts =3D g_new0(QCryptoBlockOptions, 1); > opts.format =3D Q_CRYPTO_BLOCK_FORMAT_LUKS >=20 > 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. >=20 >=20 > 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? >=20 > 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. >=20 > 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. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --t09lrvwsf3cxjv5SuK7THd3TEKJk5Lqsh Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWzHhfAAoJEKeha0olJ0NqgHMH/3IdDPYo+vLzl2OpFUszcLmt B1CtuM9/b1tCgXswhCGB2tFqkuuVY+xi/o0o8qWeEvj2aXsr9+dPaSjlcsqUsyah bjg4awvQ1DS5zto9B4AHIUGhC5Hgas9BQgVj+z6RNC9lcxx4UY1JbQNzp+UxIFLd nQujaMy63FZkn4eg6PlFDJv5x+ZStAj3FcCNrYsOrmVyeUB7odPN6I/89fogLtI2 ta+1ZA6o+x/Zw67bwtnn8zoq4HZU2FIwlusZU1CaEs9WFgedgm+pSX2xukaXP0x0 wEAF+aBPSiN7H1Mu/VVs5hC5/t2GNqjwUjAGfyarZaXg01FE+q+oBBSMO+/qnxA= =dXDn -----END PGP SIGNATURE----- --t09lrvwsf3cxjv5SuK7THd3TEKJk5Lqsh--