From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49274) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXyYV-0007nd-7M for qemu-devel@nongnu.org; Mon, 22 Feb 2016 17:02:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aXyYQ-000366-8i for qemu-devel@nongnu.org; Mon, 22 Feb 2016 17:02:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49900) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXyYQ-00035t-1K for qemu-devel@nongnu.org; Mon, 22 Feb 2016 17:02:06 -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 79E575A63 for ; Mon, 22 Feb 2016 22:02:05 +0000 (UTC) References: <1456160567-18072-1-git-send-email-berrange@redhat.com> From: Eric Blake Message-ID: <56CB855B.1030906@redhat.com> Date: Mon, 22 Feb 2016 15:02:03 -0700 MIME-Version: 1.0 In-Reply-To: <1456160567-18072-1-git-send-email-berrange@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="iPwIUiG5LSnXHsaxxTMI1t1ncv6353RaK" Subject: Re: [Qemu-devel] [PATCH] qmp-shell: fix pretty printing of JSON responses List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" , qemu-devel@nongnu.org Cc: Markus Armbruster , Luiz Capitulino This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --iPwIUiG5LSnXHsaxxTMI1t1ncv6353RaK Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 02/22/2016 10:02 AM, Daniel P. Berrange wrote: > Pretty printing of JSON responses is important to be able > to understand large responses from query commands in > particular, eg >=20 > (QEMU) query-chardev > { u'return': [ { u'filename': u'vc', > u'frontend-open': False, > u'label': u'parallel0'}, > { u'filename': u'vc', > u'frontend-open': True, > u'label': u'serial0'}, > { u'filename': u'unix:/tmp/qemp,server', > u'frontend-open': True, > u'label': u'compat_monitor0'}]} >=20 > Unfortunately this was broken during the addition of > the verbose flag in >=20 > commit 1ceca07e48ead0dd2e41576c81d40e6a91cafefd > Author: John Snow > Date: Wed Apr 29 15:14:04 2015 -0400 >=20 > scripts: qmp-shell: Add verbose flag >=20 > This is because that change turned the python data > structure into a formatted JSON string before the > pretty print was given it. So we're just pretty > printing a string, which is a no-op. >=20 > This fixes pretty printing of the command responses > and as an added benefit it will also pretty print > command arguments in verbose mode >=20 > (QEMU) object-add qom-type=3Dsecret id=3Dsec0 props=3D{"data":"123456"}= > { 'arguments': { 'id': 'sec0', > 'props': { u'data': u'123456'}, > 'qom-type': 'secret'}, > 'execute': 'object-add'} > { u'return': { }} That's an odd mix of regular and Unicode strings. Any ideas why it is happening? But the patch is a strict improvement, so: Reviewed-by: Eric Blake >=20 > Signed-off-by: Daniel P. Berrange > --- > scripts/qmp/qmp-shell | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell > index 7a402ed..15bbc5e 100755 > --- a/scripts/qmp/qmp-shell > +++ b/scripts/qmp/qmp-shell > @@ -231,10 +231,10 @@ class QMPShell(qmp.QEMUMonitorProtocol): > return qmpcmd > =20 > def _print(self, qmp): > - jsobj =3D json.dumps(qmp) > if self._pp is not None: > - self._pp.pprint(jsobj) > + self._pp.pprint(qmp) > else: > + jsobj =3D json.dumps(qmp) > print str(jsobj) > =20 > def _execute_cmd(self, cmdline): >=20 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --iPwIUiG5LSnXHsaxxTMI1t1ncv6353RaK 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/ iQEcBAEBCAAGBQJWy4VbAAoJEKeha0olJ0NqbNwIAIP0GEhRwsNhZpKZdjgQADHr jLJ40arnkjT71tIdj6CLDIhf8iiNbwGfdLmxA7mmHY4xdtaVNkoO1AJwtFy8ITpa GTg4hGN7E/xfOMjCCcdPQAacfQJ0AT5ayHkoNfxGNS7nFBpxxlae+0pVYQ70QBWl 1e06WY0nEy/OQacv8jdBTILKTYMlrYenNrbdRAmdxi8/BKUePGCY8WA2GDjf6YSJ cSYTaf1LU1VPEyhX7FqMlYeYFkwxkuScxi/NcH56fgjc7ar3oaUd9q7sJHElnun0 eF8AKelFJ+F0E6/vnzsc0fF1fcwLomA7Z+M+JVEm2o5e5mJZqBZe8/W1XSJpisA= =J1Ap -----END PGP SIGNATURE----- --iPwIUiG5LSnXHsaxxTMI1t1ncv6353RaK--