From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46816) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a7NyU-0002gJ-1W for qemu-devel@nongnu.org; Fri, 11 Dec 2015 08:43:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a7NyQ-0001Rv-Qb for qemu-devel@nongnu.org; Fri, 11 Dec 2015 08:43:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57785) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a7NyQ-0001Rr-JI for qemu-devel@nongnu.org; Fri, 11 Dec 2015 08:43:02 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 2156DC076602 for ; Fri, 11 Dec 2015 13:43:01 +0000 (UTC) References: <1449791621-16185-1-git-send-email-eblake@redhat.com> <1449791621-16185-9-git-send-email-eblake@redhat.com> <566AAF3A.8090902@redhat.com> From: Eric Blake Message-ID: <566AD2E0.90006@redhat.com> Date: Fri, 11 Dec 2015 06:42:56 -0700 MIME-Version: 1.0 In-Reply-To: <566AAF3A.8090902@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="nBUSnqrJh9eisx74BusV8kmXR6Is7fG1B" Subject: Re: [Qemu-devel] [PATCH 08/11] qjson: Simplify by using json-output-visitor List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --nBUSnqrJh9eisx74BusV8kmXR6Is7fG1B Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 12/11/2015 04:10 AM, Paolo Bonzini wrote: >=20 >=20 > On 11/12/2015 00:53, Eric Blake wrote: >> Instead of rolling our own limited JSON outputter, we can just >> wrap the more full-featured JSON output Visitor. >> >> This slightly changes the output (different spacing), but the >> result is still equivalent JSON contents. >> >> Signed-off-by: Eric Blake >> --- >> qjson.c | 61 ++++++++++++++++++++++----------------------------------= ----- >> 1 file changed, 22 insertions(+), 39 deletions(-) >=20 > I didn't find out which tree your patches apply to, but this: Mentioned in the cover letter: + v8 or later of my qapi subset E patches (at the time of this mail, only v7 has been posted): https://lists.gnu.org/archive/html/qemu-devel/2015-12/msg01181.html Also available as a tag at this location (with prerequisites applied): git fetch git://repo.or.cz/qemu/ericb.git qapi-jsonv1 (note that it is only a tag, not a branch, and you are right that it doesn't yet apply to any maintainer's tree). > @@ -1068,9 +1070,11 @@ void qemu_savevm_state_complete_precopy(QEMUFile= *f, bool iterable_only) > return; > } > =20 > - vmdesc =3D qjson_new(); > - json_prop_int(vmdesc, "page_size", TARGET_PAGE_SIZE); > - json_start_array(vmdesc, "devices"); > + vmdesc_jov =3D json_output_visitor_new(); > + vmdesc =3D json_output_get_visitor(vmdesc_jov); > + visit_start_struct(vmdesc, NULL, 0, NULL, &error_abort); > + visit_type_int(vmdesc, TARGET_PAGE_SIZE, "page_size", &error_abort= ); > + visit_start_list(vmdesc, NULL, 0, "devices", &error_abort); > QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { Nice idea. > compiles and is pretty much a 1:1 translation from the qjson.c API to t= he > visitor API (using this patch as a guide). Feel free to include it and= > remove qjson.c. Alternatively, you can leave out this patch and I'll t= est > and submit the transition. Should I squash the two together, or keep my current patch and drop qjson.c as a separate patch? Also, while reading this, I noticed that qjson.h has signatures that match JSON ('name' comes before 'value', when generating a "name":value pair), while visitor.h has signatures that are backwards ('obj' comes before 'name', even though the output will be "name":value-of-obj). I'm seriously debating about a tree-wide coccinelle patch to reverse the order or arguments of all the visit_type_* functions. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --nBUSnqrJh9eisx74BusV8kmXR6Is7fG1B 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/ iQEcBAEBCAAGBQJWatLgAAoJEKeha0olJ0NqsqMH/2ra7Npli2JVEhD8d6N7VNBW Yr3flNj74VD3i7ycoes0BRFwokkHxWrweGVUYOextenm6KSL5OMrL115xX0tK7CI OtnIb8dpbnzPEU+yaCPIKkGI/2AaNrdKcAJL3ASYsex9K37Hf1w6E7ZzlJNmbHbI 1MuqrRlvGvhsVurZgYW2zZMQ5nLPiM6VaXhnH7eQq6ZJaWR5iMutVVzC47PcbRzD +3k1KiJ+X1OqbBWOM3zR+aCXX0WsoR2JztrZYaqf/Fx2mDxKfKm1tSRyJD2gXMDY kc3b5AK8dGSo1moBnZDpGFmRC9ZDh6RykH8uhhwz+W/NHkhsmC7EACx7YsS/WIQ= =Rd6f -----END PGP SIGNATURE----- --nBUSnqrJh9eisx74BusV8kmXR6Is7fG1B--