[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v5 18/20] monitor: start making qmp_human_monitor_co
From: |
Marc-André Lureau |
Subject: |
[Qemu-devel] [PATCH v5 18/20] monitor: start making qmp_human_monitor_command() asynchronous |
Date: |
Mon, 15 Jul 2019 23:09:59 +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 a23c1b8ba4..0645667e1b 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 a7fba7230c..8c6ca46b8b 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -1047,7 +1047,8 @@
##
{ 'command': 'human-monitor-command',
'data': {'command-line': 'str', '*cpu-index': 'int'},
- 'returns': 'str' }
+ 'returns': 'str',
+ 'async': true }
##
# @change:
--
2.22.0.428.g6d5b264208
- [Qemu-devel] [PATCH v5 08/20] QmpSession: introduce QmpReturn, (continued)
- [Qemu-devel] [PATCH v5 08/20] QmpSession: introduce QmpReturn, Marc-André Lureau, 2019/07/15
- [Qemu-devel] [PATCH v5 09/20] qmp: simplify qmp_return_error(), Marc-André Lureau, 2019/07/15
- [Qemu-devel] [PATCH v5 10/20] QmpSession: keep a queue of pending commands, Marc-André Lureau, 2019/07/15
- [Qemu-devel] [PATCH v5 11/20] QmpSession: return orderly, Marc-André Lureau, 2019/07/15
- [Qemu-devel] [PATCH v5 12/20] qmp: introduce asynchronous command type, Marc-André Lureau, 2019/07/15
- [Qemu-devel] [PATCH v5 13/20] scripts: learn 'async' qapi commands, Marc-André Lureau, 2019/07/15
- [Qemu-devel] [PATCH v5 14/20] qmp: add qmp_return_is_cancelled(), Marc-André Lureau, 2019/07/15
- [Qemu-devel] [PATCH v5 15/20] monitor: add qmp_return_get_monitor(), Marc-André Lureau, 2019/07/15
- [Qemu-devel] [PATCH v5 16/20] console: add graphic_hw_update_done(), Marc-André Lureau, 2019/07/15
- [Qemu-devel] [PATCH v5 17/20] console: make screendump asynchronous, Marc-André Lureau, 2019/07/15
- [Qemu-devel] [PATCH v5 18/20] monitor: start making qmp_human_monitor_command() asynchronous,
Marc-André Lureau <=
- [Qemu-devel] [PATCH v5 19/20] monitor: teach HMP about asynchronous commands, Marc-André Lureau, 2019/07/15
- [Qemu-devel] [PATCH v5 20/20] hmp: call the asynchronous QMP screendump to fix outdated/glitches, Marc-André Lureau, 2019/07/15