[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 02/21] monitor: Clean up after previous commit
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PULL 02/21] monitor: Clean up after previous commit |
Date: |
Tue, 2 Jun 2015 10:23:40 +0200 |
Inline qmp_call_cmd() along with its helper handler_audit() into its
only caller handle_qmp_command(), and simplify the result.
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Luiz Capitulino <address@hidden>
---
monitor.c | 40 +++++++++++-----------------------------
1 file changed, 11 insertions(+), 29 deletions(-)
diff --git a/monitor.c b/monitor.c
index 27efeb6..416ba10 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4045,18 +4045,6 @@ void monitor_set_error(Monitor *mon, QError *qerror)
}
}
-static void handler_audit(Monitor *mon, const mon_cmd_t *cmd, int ret)
-{
- if (ret && !monitor_has_error(mon)) {
- /*
- * If it returns failure, it must have passed on error.
- *
- * Action: Report an internal error to the client if in QMP.
- */
- qerror_report(QERR_UNDEFINED_ERROR);
- }
-}
-
static void handle_user_command(Monitor *mon, const char *cmdline)
{
QDict *qdict;
@@ -5013,28 +5001,17 @@ static QDict *qmp_check_input_obj(QObject *input_obj)
return input_dict;
}
-static void qmp_call_cmd(Monitor *mon, const mon_cmd_t *cmd,
- const QDict *params)
-{
- int ret;
- QObject *data = NULL;
-
- ret = cmd->mhandler.cmd_new(mon, params, &data);
- handler_audit(mon, cmd, ret);
- monitor_protocol_emitter(mon, data);
- qobject_decref(data);
-}
-
static void handle_qmp_command(JSONMessageParser *parser, QList *tokens)
{
int err;
- QObject *obj;
+ QObject *obj, *data;
QDict *input, *args;
const mon_cmd_t *cmd;
const char *cmd_name;
Monitor *mon = cur_mon;
args = input = NULL;
+ data = NULL;
obj = json_parser_parse(tokens, NULL);
if (!obj) {
@@ -5077,12 +5054,17 @@ static void handle_qmp_command(JSONMessageParser
*parser, QList *tokens)
goto err_out;
}
- qmp_call_cmd(mon, cmd, args);
- goto out;
+ if (cmd->mhandler.cmd_new(mon, args, &data)) {
+ /* Command failed... */
+ if (!monitor_has_error(mon)) {
+ /* ... without setting an error, so make one up */
+ qerror_report(QERR_UNDEFINED_ERROR);
+ }
+ }
err_out:
- monitor_protocol_emitter(mon, NULL);
-out:
+ monitor_protocol_emitter(mon, data);
+ qobject_decref(data);
QDECREF(input);
QDECREF(args);
}
--
1.9.3
- [Qemu-devel] [PULL 00/21] Monitor patches, Markus Armbruster, 2015/06/02
- [Qemu-devel] [PULL 08/21] monitor: Drop unused "new" HMP command interface, Markus Armbruster, 2015/06/02
- [Qemu-devel] [PULL 11/21] monitor: Propagate errors through invalid_qmp_mode(), Markus Armbruster, 2015/06/02
- [Qemu-devel] [PULL 02/21] monitor: Clean up after previous commit,
Markus Armbruster <=
- [Qemu-devel] [PULL 12/21] monitor: Wean monitor_protocol_emitter() off mon->error, Markus Armbruster, 2015/06/02
- [Qemu-devel] [PULL 05/21] monitor: Use traditional command interface for HMP drive_del, Markus Armbruster, 2015/06/02
- [Qemu-devel] [PULL 06/21] monitor: Use traditional command interface for HMP device_add, Markus Armbruster, 2015/06/02
- [Qemu-devel] [PULL 09/21] monitor: Propagate errors through qmp_check_client_args(), Markus Armbruster, 2015/06/02
- [Qemu-devel] [PULL 07/21] monitor: Use trad. command interface for HMP pcie_aer_inject_error, Markus Armbruster, 2015/06/02
- [Qemu-devel] [PULL 03/21] monitor: Improve and document client_migrate_info protocol error, Markus Armbruster, 2015/06/02
- [Qemu-devel] [PULL 04/21] monitor: Convert client_migrate_info to QAPI, Markus Armbruster, 2015/06/02
- [Qemu-devel] [PULL 01/21] monitor: Drop broken, unused asynchronous command interface, Markus Armbruster, 2015/06/02
- [Qemu-devel] [PULL 13/21] monitor: Inline monitor_has_error() into its only caller, Markus Armbruster, 2015/06/02
- [Qemu-devel] [PULL 20/21] monitor: Rename monitor_ctrl_mode() to monitor_is_qmp(), Markus Armbruster, 2015/06/02