This prepares the work for HMP commands to be asynchronous. Start making QMP human-monitor-command asynchronous, although QmpReturn is used synchronously on error or after handle_hmp_command().
Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> --- monitor/misc.c | 14 ++++++++------ qapi/misc.json | 3 ++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/monitor/misc.c b/monitor/misc.c index bb33ca73cf..3617f855f5 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -115,8 +115,8 @@ static QLIST_HEAD(, MonFdset) mon_fdsets; static HMPCommand hmp_info_cmds[]; -char *qmp_human_monitor_command(const char *command_line, bool has_cpu_index, - int64_t cpu_index, Error **errp) +void qmp_human_monitor_command(const char *command_line, bool has_cpu_index, + int64_t cpu_index, QmpReturn *qret) { char *output = NULL; Monitor *old_mon; @@ -130,15 +130,15 @@ char *qmp_human_monitor_command(const char *command_line, bool has_cpu_index, if (has_cpu_index) { int ret = monitor_set_cpu(cpu_index); if (ret < 0) { - cur_mon = old_mon; - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index", + Error *err = NULL; + error_setg(&err, QERR_INVALID_PARAMETER_VALUE, "cpu-index", "a CPU number"); + qmp_return_error(qret, err); goto out; } } handle_hmp_command(&hmp, command_line); - cur_mon = old_mon; qemu_mutex_lock(&hmp.common.mon_lock); if (qstring_get_length(hmp.common.outbuf) > 0) { @@ -148,9 +148,11 @@ char *qmp_human_monitor_command(const char *command_line, bool has_cpu_index, } qemu_mutex_unlock(&hmp.common.mon_lock); + qmp_human_monitor_command_return(qret, output); + out: + cur_mon = old_mon; monitor_data_destroy(&hmp.common); - return output; } /** diff --git a/qapi/misc.json b/qapi/misc.json index 33b94e3589..15a8bc0d0d 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -1054,7 +1054,8 @@ { 'command': 'human-monitor-command', 'data': {'command-line': 'str', '*cpu-index': 'int'}, 'returns': 'str', - 'features': [ 'savevm-monitor-nodes' ] } + 'features': [ 'savevm-monitor-nodes' ], + 'async': true } ## # @change: -- 2.24.0