From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41697) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQgB5-00056J-5i for qemu-devel@nongnu.org; Mon, 30 Sep 2013 12:18:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VQgAz-00066V-IZ for qemu-devel@nongnu.org; Mon, 30 Sep 2013 12:18:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14968) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQgAz-00066H-Aa for qemu-devel@nongnu.org; Mon, 30 Sep 2013 12:18:25 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r8UGIO9M026877 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 30 Sep 2013 12:18:24 -0400 Message-ID: <5249A44F.2050802@redhat.com> Date: Mon, 30 Sep 2013 10:18:23 -0600 From: Eric Blake MIME-Version: 1.0 References: <1379938162-14005-1-git-send-email-mreitz@redhat.com> <1379938162-14005-4-git-send-email-mreitz@redhat.com> In-Reply-To: <1379938162-14005-4-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="I0vdiKvS8oaoMkS3Tu9MsxQCm6E5I4GpX" Subject: Re: [Qemu-devel] [PATCH v5 3/6] block/qapi: Human-readable ImageInfoSpecific dump List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Kevin Wolf , Fam Zheng , qemu-devel@nongnu.org, Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --I0vdiKvS8oaoMkS3Tu9MsxQCm6E5I4GpX Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 09/23/2013 06:09 AM, Max Reitz wrote: > Add a function for generically dumping the ImageInfoSpecific informatio= n > in a human-readable format to block/qapi.c. >=20 > Use this function in bdrv_image_info_dump and qemu-io-cmds.c:info_f to > allow qemu-img info resp. qemu-io -c info to print that format specific= > information. >=20 > Signed-off-by: Max Reitz > --- > block/qapi.c | 121 +++++++++++++++++++++++++++++++++++++++++++= ++++++++ > include/block/qapi.h | 2 + > qemu-io-cmds.c | 9 ++++ > 3 files changed, 132 insertions(+) >=20 > + > +static void dump_qdict(fprintf_function func_fprintf, void *f, int ind= entation, > + QDict *dict) > +{ > + const QDictEntry *entry; > + > + for (entry =3D qdict_first(dict); entry; entry =3D qdict_next(dict= , entry)) { > + qtype_code type =3D qobject_type(entry->value); > + bool composite =3D (type =3D=3D QTYPE_QDICT || type =3D=3D QTY= PE_QLIST); > + const char *format =3D composite ? "%*s%s:\n" : "%*s%s: "; > + char key[strlen(entry->key) + 1]; > + int i; > + > + /* replace dashes with spaces in key (variable) names */ > + for (i =3D 0; entry->key[i]; i++) { > + key[i] =3D entry->key[i] =3D=3D '-' ? ' ' : entry->key[i];= I wonder if this should replace underscores, too. For now, this function is only being used on types that happen to use - in key names, but it seems generic enough that we may want to use it on older types that followed older conventions. But I won't force a respin for just that (if someone DOES reuse this function in the future, they can tweak underscores at that time, if you don't do it now). Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --I0vdiKvS8oaoMkS3Tu9MsxQCm6E5I4GpX Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJSSaRPAAoJEKeha0olJ0NqBK8IAKV1Zdl/XpsmJaz8aMROt3ET U1VG9wIBRhp3KomzDPVkBXVcW0lLxttrxjo0JuJSlWtootX4jxP58vC9WJIVszGv 2qRWOxCJRt72CiPpLJo//COSzLGoFyNHssxmYKBHrRQgZZi5vZ1RitZ0guh/C0UU diwXqnGmXyYt8WMGsyDtu5EVAfGxP9Zj8zgW7bwm1+EKXHUScPd8dBJn40EJxPZs iYcOo8SLURL/el8/NkSJbdYz8Jo0hg0oj3/nDBD4+d8141Vw2q9qVYjS2ZLBAdrm wwGBPpnrIwcd5sVHd75vZmGXSpmLAMIPOA+qnBwdTo5aypfSGWF+j6XTPZYMzIE= =xD5z -----END PGP SIGNATURE----- --I0vdiKvS8oaoMkS3Tu9MsxQCm6E5I4GpX--