From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAKMB-0002R7-KE for qemu-devel@nongnu.org; Tue, 07 Jun 2016 13:00:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAKMA-00059h-HV for qemu-devel@nongnu.org; Tue, 07 Jun 2016 12:59:59 -0400 References: <1465294275-8733-1-git-send-email-berrange@redhat.com> <1465294275-8733-7-git-send-email-berrange@redhat.com> From: Eric Blake Message-ID: <5756FD85.7060905@redhat.com> Date: Tue, 7 Jun 2016 10:59:49 -0600 MIME-Version: 1.0 In-Reply-To: <1465294275-8733-7-git-send-email-berrange@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="uG6tutrhoCMDHHGGMnNRI1H418ES24UNW" Subject: Re: [Qemu-devel] [PATCH v1 6/6] block: convert to use qapi_stringify_ImageInfoSpecific List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" , qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Max Reitz , Markus Armbruster , Michael Roth This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --uG6tutrhoCMDHHGGMnNRI1H418ES24UNW Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 06/07/2016 04:11 AM, Daniel P. Berrange wrote: > When 'qemu-img info' prints out format specific information, > it first converts the QAPI object into a JSON based QObject > data structure. Unfortunately structs have to be turned into > dicts, which looses all information about field ordering, s/looses/loses/ > so the data printed appears in a semi-random order. >=20 > Convert this to use the qapi_stringify_ImageInfoSpecific() > which uses a visitor to directly pretty-print the objects > without the intermediate QObject conversion, and thus will > maintain struct field ordering. >=20 The idea makes sense. I'm not sure we want to go all the way to qapi_stringify_ImageInfoSpecific(), vs. just having a nice accessor macro that takes care of type-punning through a common actor (the way I did it in my series for QAPI_CLONE()). > Signed-off-by: Daniel P. Berrange > --- > block/qapi.c | 101 ++-------------------------------------------------= -------- > 1 file changed, 3 insertions(+), 98 deletions(-) >=20 > @@ -599,107 +598,13 @@ void bdrv_snapshot_dump(fprintf_function func_fp= rintf, void *f, > } > } > =20 > -static void dump_qdict(fprintf_function func_fprintf, void *f, int ind= entation, > - QDict *dict); > -static void dump_qlist(fprintf_function func_fprintf, void *f, int ind= entation, > - QList *list); > - > -static void dump_qobject(fprintf_function func_fprintf, void *f, > - int comp_indent, QObject *obj) > -{ > - switch (qobject_type(obj)) { > - case QTYPE_QINT: { > - QInt *value =3D qobject_to_qint(obj); > - func_fprintf(f, "%" PRId64, qint_get_int(value)); > - break; It's also nice that we're moving some of this code into a more general-purpose visitor. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --uG6tutrhoCMDHHGGMnNRI1H418ES24UNW 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/ iQEcBAEBCAAGBQJXVv2FAAoJEKeha0olJ0NqDL0H/2dyLV4ny6cK8JOq93obkDXL tTycDwvQAB3K+4UVkigUZb7FG/x5W4BGvs80ATD1mc3EfDPTaQPRUQL8LC/O9/Wc ZTNO6nZf5MDiVTmFucudNYbOdkcQ9KN6YQH3oLgIG2kaVI+VL8z5/d/OAvlSaZzL 6dCHPt9gXeEVEYfRaw5I2sd4vwY7Xa3aHVmz7N55uyPACz703hiWGbkL/4zFZGZ0 lQX4hP6qDV6zaQzOBRBf22TDOoR+VWrheWGbbFFDBhFE7qRg5IDksIYBicrsAByM SZuY3SQT3KpGD2MTua61ILDXJ5xyCHq8kcwKm7rmsWKhtWS9h0EydzDpypOmmnE= =qTXZ -----END PGP SIGNATURE----- --uG6tutrhoCMDHHGGMnNRI1H418ES24UNW--