diff options
-rw-r--r-- | monitor.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -4404,16 +4404,20 @@ static QObject *get_qmp_greeting(void) */ static void monitor_control_event(void *opaque, int event) { - if (event == CHR_EVENT_OPENED) { - QObject *data; - Monitor *mon = opaque; + QObject *data; + Monitor *mon = opaque; + 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); + break; } } |