diff options
-rw-r--r-- | monitor.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -3765,7 +3765,9 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens) { QObject *req, *rsp = NULL, *id = NULL; QDict *qdict = NULL; - Monitor *mon = cur_mon; + MonitorQMP *mon_qmp = container_of(parser, MonitorQMP, parser); + Monitor *old_mon, *mon = container_of(mon_qmp, Monitor, qmp); + Error *err = NULL; req = json_parser_parse_err(tokens, NULL, &err); @@ -3790,8 +3792,13 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens) QDECREF(req_json); } + old_mon = cur_mon; + cur_mon = mon; + rsp = qmp_dispatch(cur_mon->qmp.commands, req); + cur_mon = old_mon; + if (mon->qmp.commands == &qmp_cap_negotiation_commands) { qdict = qdict_get_qdict(qobject_to(QDict, rsp), "error"); if (qdict @@ -3828,13 +3835,9 @@ err_out: static void monitor_qmp_read(void *opaque, const uint8_t *buf, int size) { - Monitor *old_mon = cur_mon; - - cur_mon = opaque; - - json_message_parser_feed(&cur_mon->qmp.parser, (const char *) buf, size); + Monitor *mon = opaque; - cur_mon = old_mon; + json_message_parser_feed(&mon->qmp.parser, (const char *) buf, size); } static void monitor_read(void *opaque, const uint8_t *buf, int size) |