[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 23/25] monitor: start making qmp_human_monitor_command() async
From: |
Marc-André Lureau |
Subject: |
[PATCH v6 23/25] monitor: start making qmp_human_monitor_command() asynchronous |
Date: |
Fri, 8 Nov 2019 19:01:21 +0400 |
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 <address@hidden>
---
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
- [PATCH v6 14/25] qmp: add qmp_return_is_cancelled(), (continued)
- [PATCH v6 14/25] qmp: add qmp_return_is_cancelled(), Marc-André Lureau, 2019/11/08
- [PATCH v6 13/25] scripts: learn 'async' qapi commands, Marc-André Lureau, 2019/11/08
- [PATCH v6 15/25] console: add graphic_hw_update_done(), Marc-André Lureau, 2019/11/08
- [PATCH v6 16/25] ppm-save: pass opened fd, Marc-André Lureau, 2019/11/08
- [PATCH v6 17/25] ui: add pixman image g_autoptr support, Marc-André Lureau, 2019/11/08
- [PATCH v6 18/25] object: add g_autoptr support, Marc-André Lureau, 2019/11/08
- [PATCH v6 19/25] screendump: replace FILE with QIOChannel and fix close()/qemu_close(), Marc-André Lureau, 2019/11/08
- [PATCH v6 20/25] osdep: add qemu_unlink(), Marc-André Lureau, 2019/11/08
- [PATCH v6 21/25] screendump: use qemu_unlink(), Marc-André Lureau, 2019/11/08
- [PATCH v6 22/25] console: make screendump asynchronous, Marc-André Lureau, 2019/11/08
- [PATCH v6 23/25] monitor: start making qmp_human_monitor_command() asynchronous,
Marc-André Lureau <=
- [PATCH v6 24/25] monitor: teach HMP about asynchronous commands, Marc-André Lureau, 2019/11/08
- [PATCH v6 25/25] hmp: call the asynchronous QMP screendump to fix outdated/glitches, Marc-André Lureau, 2019/11/08