From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1cDh-0001Tv-L8 for qemu-devel@nongnu.org; Wed, 25 Nov 2015 10:42:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a1cDd-0004Ig-Kc for qemu-devel@nongnu.org; Wed, 25 Nov 2015 10:42:57 -0500 References: <1448437153-27090-1-git-send-email-famz@redhat.com> <1448437153-27090-14-git-send-email-famz@redhat.com> From: Eric Blake Message-ID: <5655D6F7.30707@redhat.com> Date: Wed, 25 Nov 2015 08:42:47 -0700 MIME-Version: 1.0 In-Reply-To: <1448437153-27090-14-git-send-email-famz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="9BdTWwm79hwMksoGtT7rQ3h32kE4odLsl" Subject: Re: [Qemu-devel] [PATCH v2 13/14] qemu-img: Use QAPI visitor to generate JSON List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: Kevin Wolf , qemu-block@nongnu.org, Jeff Cody , Peter Lieven , Markus Armbruster , Stefan Hajnoczi , Paolo Bonzini This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --9BdTWwm79hwMksoGtT7rQ3h32kE4odLsl Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/25/2015 12:39 AM, Fam Zheng wrote: > A visible improvement is that "filename" is now included in the output > if it's valid. >=20 > Signed-off-by: Fam Zheng > --- > qemu-img.c | 39 ++++++++++++------- > tests/qemu-iotests/122.out | 96 ++++++++++++++++++++++++++------------= -------- > 2 files changed, 79 insertions(+), 56 deletions(-) >=20 > @@ -2155,21 +2161,26 @@ static void dump_map_entry(OutputFormat output_= format, MapEntry *e, > } > break; > case OFORMAT_JSON: > - printf("%s{ \"start\": %"PRId64", \"length\": %"PRId64"," > - " \"depth\": %ld," > - " \"zero\": %s, \"data\": %s", > - (e->start =3D=3D 0 ? "[" : ",\n"), > - e->start, e->length, e->depth, > - e->zero ? "true" : "false", > - e->data ? "true" : "false"); > - if (e->has_offset) { > - printf(", \"offset\": %"PRId64"", e->offset); > - } > - putchar('}'); > + ov =3D qmp_output_visitor_new(); > + visit_type_MapEntry(qmp_output_get_visitor(ov), > + &e, NULL, &error_abort); > + obj =3D qmp_output_get_qobject(ov); > + str =3D qobject_to_json(obj); It would be nice to someday add a visitor that goes directly to json, instead of through an intermediate QObject. But that's not for this series; your conversion here is sane. > @@ -2213,9 +2224,9 @@ static int get_block_status(BlockDriverState *bs,= int64_t sector_num, > e->offset =3D ret & BDRV_BLOCK_OFFSET_MASK; > e->has_offset =3D !!(ret & BDRV_BLOCK_OFFSET_VALID); > e->depth =3D depth; > - if (e->has_offset) { > + if (file && e->has_offset) { > e->has_filename =3D true; > - e->filename =3D bs->filename; > + e->filename =3D file->filename; Does this hunk belong in a different patch? Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --9BdTWwm79hwMksoGtT7rQ3h32kE4odLsl 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/ iQEcBAEBCAAGBQJWVdb3AAoJEKeha0olJ0NqoXcH+gK/TMDeZSIS4joF0aijEb5I YZmUPxJg4XecKDNmfaZ+F0GkOpK88vHl+fAKEQx8waJH5UlBFd9BVUyLVDxTIAYe zGKIGkeGyiGMTyRyW5ohvRmACr9yNFwAYZYAvIFWYyVaFW06EdFy11n2ZnreOecu 9LUdPOTpmMnxcZ5R4q4EXJ29LJaKciovUzrsQd10nyUEIGNTVoM2rfhzWGQhNpbp 1MBaFGE7FraU5hdnE52wGPS/k58HSV2HBFMS86FcsfTLyg3vYZjCoDqLNqGRiXXw mbmuchW9bXhZoKONl2cCRbFiJiWQ0pDBH6ca8gKtTRpCXOLI2ZVJMetfSlbG1b0= =qV2x -----END PGP SIGNATURE----- --9BdTWwm79hwMksoGtT7rQ3h32kE4odLsl--