mirror of
https://git.proxmox.com/git/qemu
synced 2025-06-15 14:09:38 +00:00
Add option to turn on JSON pretty printing in monitor
Expaned '-mon' arg to allow a 'pretty=on' flag. This makes the monitor pretty print its replies to easy human debugging / reading Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
parent
212b600868
commit
39eaab9ac2
@ -351,7 +351,10 @@ static void monitor_json_emitter(Monitor *mon, const QObject *data)
|
|||||||
{
|
{
|
||||||
QString *json;
|
QString *json;
|
||||||
|
|
||||||
json = qobject_to_json(data);
|
if (mon->flags & MONITOR_USE_PRETTY)
|
||||||
|
json = qobject_to_json_pretty(data);
|
||||||
|
else
|
||||||
|
json = qobject_to_json(data);
|
||||||
assert(json != NULL);
|
assert(json != NULL);
|
||||||
|
|
||||||
qstring_append_chr(json, '\n');
|
qstring_append_chr(json, '\n');
|
||||||
|
@ -14,6 +14,7 @@ extern Monitor *default_mon;
|
|||||||
#define MONITOR_IS_DEFAULT 0x01
|
#define MONITOR_IS_DEFAULT 0x01
|
||||||
#define MONITOR_USE_READLINE 0x02
|
#define MONITOR_USE_READLINE 0x02
|
||||||
#define MONITOR_USE_CONTROL 0x04
|
#define MONITOR_USE_CONTROL 0x04
|
||||||
|
#define MONITOR_USE_PRETTY 0x08
|
||||||
|
|
||||||
/* flags for monitor commands */
|
/* flags for monitor commands */
|
||||||
#define MONITOR_CMD_ASYNC 0x0001
|
#define MONITOR_CMD_ASYNC 0x0001
|
||||||
|
@ -283,6 +283,9 @@ static QemuOptsList qemu_mon_opts = {
|
|||||||
},{
|
},{
|
||||||
.name = "default",
|
.name = "default",
|
||||||
.type = QEMU_OPT_BOOL,
|
.type = QEMU_OPT_BOOL,
|
||||||
|
},{
|
||||||
|
.name = "pretty",
|
||||||
|
.type = QEMU_OPT_BOOL,
|
||||||
},
|
},
|
||||||
{ /* end of list */ }
|
{ /* end of list */ }
|
||||||
},
|
},
|
||||||
|
3
vl.c
3
vl.c
@ -1562,6 +1562,9 @@ static int mon_init_func(QemuOpts *opts, void *opaque)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (qemu_opt_get_bool(opts, "pretty", 0))
|
||||||
|
flags |= MONITOR_USE_PRETTY;
|
||||||
|
|
||||||
if (qemu_opt_get_bool(opts, "default", 0))
|
if (qemu_opt_get_bool(opts, "default", 0))
|
||||||
flags |= MONITOR_IS_DEFAULT;
|
flags |= MONITOR_IS_DEFAULT;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user