[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 18/19] Add option to turn on JSON pretty printing in
From: |
Daniel P. Berrange |
Subject: |
[Qemu-devel] [PATCH 18/19] Add option to turn on JSON pretty printing in monitor |
Date: |
Mon, 7 Jun 2010 15:42:31 +0100 |
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 <address@hidden>
---
monitor.c | 5 ++++-
monitor.h | 1 +
qemu-config.c | 3 +++
vl.c | 3 +++
4 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/monitor.c b/monitor.c
index 39f8150..6203f75 100644
--- a/monitor.c
+++ b/monitor.c
@@ -341,7 +341,10 @@ static void monitor_json_emitter(Monitor *mon, const
QObject *data)
{
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);
qstring_append_chr(json, '\n');
diff --git a/monitor.h b/monitor.h
index 46b7a0e..733485f 100644
--- a/monitor.h
+++ b/monitor.h
@@ -14,6 +14,7 @@ extern Monitor *default_mon;
#define MONITOR_IS_DEFAULT 0x01
#define MONITOR_USE_READLINE 0x02
#define MONITOR_USE_CONTROL 0x04
+#define MONITOR_USE_PRETTY 0x08
/* QMP events */
typedef enum MonitorEvent {
diff --git a/qemu-config.c b/qemu-config.c
index 925bd04..20ed8c2 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -362,6 +362,9 @@ QemuOptsList qemu_mon_opts = {
},{
.name = "default",
.type = QEMU_OPT_BOOL,
+ },{
+ .name = "pretty",
+ .type = QEMU_OPT_BOOL,
},
{ /* end if list */ }
},
diff --git a/vl.c b/vl.c
index 35d2b51..de010cc 100644
--- a/vl.c
+++ b/vl.c
@@ -2391,6 +2391,9 @@ static int mon_init_func(QemuOpts *opts, void *opaque)
exit(1);
}
+ if (qemu_opt_get_bool(opts, "pretty", 0))
+ flags |= MONITOR_USE_PRETTY;
+
if (qemu_opt_get_bool(opts, "default", 0))
flags |= MONITOR_IS_DEFAULT;
--
1.6.6.1
- Re: [Qemu-devel] [PATCH 14/19] Add a query-argv command to QMP, (continued)
[Qemu-devel] [PATCH 13/19] Add a query-target command to QMP, Daniel P. Berrange, 2010/06/07
[Qemu-devel] [PATCH 15/19] Expand query-argv to include help string, Daniel P. Berrange, 2010/06/07
[Qemu-devel] [PATCH 18/19] Add option to turn on JSON pretty printing in monitor,
Daniel P. Berrange <=
[Qemu-devel] [PATCH 17/19] Add a query-config command to QMP, Daniel P. Berrange, 2010/06/07
[Qemu-devel] [PATCH 16/19] Add a query-netdev command to QMP, Daniel P. Berrange, 2010/06/07
[Qemu-devel] [PATCH 19/19] Add a -capabilities argument to allow easy query for static QEMU info, Daniel P. Berrange, 2010/06/07