summary refs log tree commit diff stats
path: root/monitor/qmp.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2019-06-13 17:34:03 +0200
committerMarkus Armbruster <armbru@redhat.com>2019-06-18 08:14:17 +0200
commit920824165c49bfbd1e0e9e07fd92e0bbbf32aea3 (patch)
treee338c3af03ec3f86d017b581cf5d7f86fc8b2e65 /monitor/qmp.c
parent1d95db745b78439e9eec0782eca9cc0d679d6224 (diff)
downloadfocaccia-qemu-920824165c49bfbd1e0e9e07fd92e0bbbf32aea3.tar.gz
focaccia-qemu-920824165c49bfbd1e0e9e07fd92e0bbbf32aea3.zip
monitor: Split Monitor.flags into separate bools
Monitor.flags contains three different flags: One to distinguish HMP
from QMP; one specific to HMP (MONITOR_USE_READLINE) that is ignored
with QMP; and another one specific to QMP (MONITOR_USE_PRETTY) that is
ignored with HMP.

Split the flags field into three bools and move them to the right
subclass. Flags are still in use for the monitor_init() interface.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20190613153405.24769-14-kwolf@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'monitor/qmp.c')
-rw-r--r--monitor/qmp.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/monitor/qmp.c b/monitor/qmp.c
index 7c3d081a72..940649f688 100644
--- a/monitor/qmp.c
+++ b/monitor/qmp.c
@@ -87,8 +87,7 @@ void qmp_send_response(MonitorQMP *mon, const QDict *rsp)
     const QObject *data = QOBJECT(rsp);
     QString *json;
 
-    json = mon->common.flags & MONITOR_USE_PRETTY ?
-           qobject_to_json_pretty(data) : qobject_to_json(data);
+    json = mon->pretty ? qobject_to_json_pretty(data) : qobject_to_json(data);
     assert(json != NULL);
 
     qstring_append_chr(json, '\n');
@@ -373,9 +372,11 @@ void monitor_init_qmp(Chardev *chr, int flags)
     assert(!(flags & MONITOR_USE_READLINE));
 
     /* Note: we run QMP monitor in I/O thread when @chr supports that */
-    monitor_data_init(&mon->common, flags, false,
+    monitor_data_init(&mon->common, true, false,
                       qemu_chr_has_feature(chr, QEMU_CHAR_FEATURE_GCONTEXT));
 
+    mon->pretty = flags & MONITOR_USE_PRETTY;
+
     qemu_mutex_init(&mon->qmp_queue_lock);
     mon->qmp_requests = g_queue_new();