qemu/scripts
Daniel P. Berrange e55250c6cb qmp-shell: fix pretty printing of JSON responses
Pretty printing of JSON responses is important to be able to understand
large responses from query commands in particular. Unfortunately this
was broken during the addition of the verbose flag in

  commit 1ceca07e48
  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.

The original pretty printer would output python objects.

(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'}]}

This fixes the problem by switching to outputting pretty formatted JSON
text instead. This has the added benefit that the pretty printed output
is now valid JSON text. Due to the way the verbose flag was handled, the
pretty printing now applies to the command sent, as well as its response:

(QEMU) query-chardev
{
    "execute": "query-chardev",
    "arguments": {}
}
{
    "return": [
        {
            "frontend-open": false,
            "label": "parallel0",
            "filename": "vc"
        },
        {
            "frontend-open": true,
            "label": "serial0",
            "filename": "vc"
        },
        {
            "frontend-open": true,
            "label": "compat_monitor0",
            "filename": "unix:/tmp/qmp,server"
        }
    ]
}

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1456224706-1591-1-git-send-email-berrange@redhat.com>
Tested-by: Kashyap Chamarthy <kchamart@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
[Bonus fix: multiple -p now work]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-03-04 17:16:32 +01:00
..
kvm scripts/kvm/kvm_stat: Fix missing right parantheses and ".format(...)" 2016-02-22 18:40:22 +01:00
qemu-guest-agent
qemugdb
qmp qmp-shell: fix pretty printing of JSON responses 2016-03-04 17:16:32 +01:00
tracetool trace: Add a proper API to manage auto-generated events from the 'tcg' property 2016-03-01 13:34:38 +00:00
analyse-9p-simpletrace.py
analyze-migration.py
check-qerror.sh
checkpatch.pl checkpatch: Eliminate false positive in case of space before square bracket in a definition 2016-02-15 20:02:09 +01:00
clean-includes scripts/clean-includes: Ignore .inc.c files 2016-02-23 08:30:59 -08:00
cleanup-trace-events.pl
cocci-macro-file.h
coverity-model.c
create_config
disas-objdump.pl
dump-guest-memory.py
extract-vsssdk-headers
feature_to_c.sh scripts/feature_to_c.sh: Include qemu/osdep.h rather than config.h 2016-02-16 14:29:27 +00:00
get_maintainer.pl get_maintainer.pl: fall back to git if only lists are found 2016-02-09 17:07:55 +01:00
gtester-cat
hxtool
make-release
make_device_config.sh
ordereddict.py
qapi-commands.py qapi: Clean up includes in generated files 2016-02-16 14:29:27 +00:00
qapi-event.py qapi: Clean up includes in generated files 2016-02-16 14:29:27 +00:00
qapi-introspect.py qapi: Clean up includes in generated files 2016-02-16 14:29:27 +00:00
qapi-types.py qapi: Don't box branches of flat unions 2016-02-19 11:08:57 +01:00
qapi-visit.py qapi: Change visit_start_implicit_struct to visit_start_alternate 2016-02-19 11:08:57 +01:00
qapi.py qapi: rename InputAxis values. 2016-03-01 08:19:45 +01:00
qemu-binfmt-conf.sh
qemu-gdb.py
qtest.py
refresh-pxe-roms.sh
shaderinclude.pl
signrom.py
simpletrace.py
switch-timer-api
texi2pod.pl
tracetool.py Revert "tracetool: use Python 2.4-compatible exception handling syntax" 2016-02-08 17:29:54 +01:00
update-linux-headers.sh
vmstate-static-checker.py