From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59632) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aA46Q-0002yo-MD for qemu-devel@nongnu.org; Fri, 18 Dec 2015 18:06:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aA46N-0000k1-GD for qemu-devel@nongnu.org; Fri, 18 Dec 2015 18:06:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50756) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aA46N-0000jw-87 for qemu-devel@nongnu.org; Fri, 18 Dec 2015 18:06:19 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 3DF0F33E7F3 for ; Fri, 18 Dec 2015 23:06:18 +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: <56749160.8010604@redhat.com> Date: Fri, 18 Dec 2015 16:06:08 -0700 MIME-Version: 1.0 In-Reply-To: <566AAF3A.8090902@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="PW5xBNK4u9DfPiiA4aEi9rlVsLOdJhiAj" 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) --PW5xBNK4u9DfPiiA4aEi9rlVsLOdJhiAj 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: >=20 > if (vmdesc) { > - json_prop_int(vmdesc, "size", size); > - json_start_array(vmdesc, "fields"); > - json_start_object(vmdesc, NULL); > - json_prop_str(vmdesc, "name", "data"); > - json_prop_int(vmdesc, "size", size); > - json_prop_str(vmdesc, "type", "buffer"); > - json_end_object(vmdesc); > - json_end_array(vmdesc); > + visit_type_int(vmdesc, size, "size", &error_abort); visit_type_int() takes 'int64_t*', not 'int'. In places, that means I'd have to add a temporary variable to cover the fact that the input is not the right type for writing '&size' > @@ -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= ); =2E..or even cover the case where it is a constant whose address does not= even exist. >=20 > 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. So the patch to avoid qjson.c is not quite 1:1. Still, I'll go ahead and complete the patch for my v2, to see if you still like it. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --PW5xBNK4u9DfPiiA4aEi9rlVsLOdJhiAj 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/ iQEcBAEBCAAGBQJWdJFhAAoJEKeha0olJ0NqicwH/0mUBbP6trONDCG0fDn307SC fHuzeHxKMqf0rU9PlIRkSwf0TppKkU7Ff5Nyo97bUgAGZNyUfyQlk5Q0/qAaBGce dtpv/SMb7ezXglywwY+B+6UBExsHO+RFvKVzPJ1jkKTKrKyEJH8g6luZVszFhNBI pAiWzV79qILOi2QbRgfBr6eVgwsHtSkvV78L75Qxl32sqc7T33yffWJHXGuvNzEd jvsAmrU27ZLBPNqaxc0AmYva43OQsen1I1XK3oxg40NIAV4Y+kThd8CxeoZuEkeG iB8xxrCe6ENQy1Rox6Hiq40hZz0raJR66Jncjs3ZpybDmYH14G4kmJ3iyPOPRkw= =rrk7 -----END PGP SIGNATURE----- --PW5xBNK4u9DfPiiA4aEi9rlVsLOdJhiAj--