From: Eric Blake <eblake@redhat.com>
To: "Daniel P. Berrange" <berrange@redhat.com>, qemu-devel@nongnu.org
Cc: Markus Armbruster <armbru@redhat.com>,
Luiz Capitulino <lcapitulino@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] qmp-shell: fix pretty printing of JSON responses
Date: Mon, 22 Feb 2016 15:02:03 -0700 [thread overview]
Message-ID: <56CB855B.1030906@redhat.com> (raw)
In-Reply-To: <1456160567-18072-1-git-send-email-berrange@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2596 bytes --]
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
>
> (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'}]}
>
> Unfortunately this was broken during the addition of
> the verbose flag in
>
> commit 1ceca07e48ead0dd2e41576c81d40e6a91cafefd
> Author: John Snow <jsnow@redhat.com>
> Date: Wed Apr 29 15:14:04 2015 -0400
>
> scripts: qmp-shell: Add verbose flag
>
> 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.
>
> This fixes pretty printing of the command responses
> and as an added benefit it will also pretty print
> command arguments in verbose mode
>
> (QEMU) object-add qom-type=secret id=sec0 props={"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 <eblake@redhat.com>
>
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
> scripts/qmp/qmp-shell | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> 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
>
> def _print(self, qmp):
> - jsobj = json.dumps(qmp)
> if self._pp is not None:
> - self._pp.pprint(jsobj)
> + self._pp.pprint(qmp)
> else:
> + jsobj = json.dumps(qmp)
> print str(jsobj)
>
> def _execute_cmd(self, cmdline):
>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2016-02-22 22:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-22 17:02 [Qemu-devel] [PATCH] qmp-shell: fix pretty printing of JSON responses Daniel P. Berrange
2016-02-22 22:02 ` Eric Blake [this message]
2016-02-23 10:53 ` Daniel P. Berrange
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56CB855B.1030906@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.