aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2012-08-23 08:03:21 -0500
committerMichael Roth <mdroth@linux.vnet.ibm.com>2012-08-28 01:50:02 -0500
commit50d0184cb7be68a521a19073c92c5ffc6adb728f (patch)
tree9776d4adc9353f9d4263a0f0dd88787c28f41428
parentc068d37020f8c0d10beaf4671c41b05b923d7896 (diff)
monitor: move json init from OPEN event to init
At some point in the past, the OPEN event was changed to be issued from a bottom half. This creates a small window whereas a data callback registered in init may be invoked before the OPEN event has been issued. This is reproducible with: echo "{'execute': 'qmp_capabilities'}" | qemu-system-x86_64 -M none -qmp stdio We can fix this for the monitor by moving the parser initialization to init. The remaining state that is set in OPEN appears harmless. Reported-by: Daniel Berrange <berrange@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> (cherry picked from commit 58617a795c8067b2f9800cffce60f38707d3aa31) Conflicts: monitor.c Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
-rw-r--r--monitor.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/monitor.c b/monitor.c
index 12a6fe25a..ab65a9aab 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4501,13 +4501,13 @@ static void monitor_control_event(void *opaque, int event)
switch (event) {
case CHR_EVENT_OPENED:
mon->mc->command_mode = 0;
- json_message_parser_init(&mon->mc->parser, handle_qmp_command);
data = get_qmp_greeting();
monitor_json_emitter(mon, data);
qobject_decref(data);
break;
case CHR_EVENT_CLOSED:
json_message_parser_destroy(&mon->mc->parser);
+ json_message_parser_init(&mon->mc->parser, handle_qmp_command);
break;
}
}
@@ -4610,6 +4610,8 @@ void monitor_init(CharDriverState *chr, int flags)
monitor_event, mon);
}
+ json_message_parser_init(&mon->mc->parser, handle_qmp_command);
+
QLIST_INSERT_HEAD(&mon_list, mon, entry);
if (!default_mon || (flags & MONITOR_IS_DEFAULT))
default_mon = mon;