monitor: Clean up after previous commit
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 <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
parent
65207c59d9
commit
84add864eb
40
monitor.c
40
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)
|
static void handle_user_command(Monitor *mon, const char *cmdline)
|
||||||
{
|
{
|
||||||
QDict *qdict;
|
QDict *qdict;
|
||||||
@ -5013,28 +5001,17 @@ static QDict *qmp_check_input_obj(QObject *input_obj)
|
|||||||
return input_dict;
|
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)
|
static void handle_qmp_command(JSONMessageParser *parser, QList *tokens)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
QObject *obj;
|
QObject *obj, *data;
|
||||||
QDict *input, *args;
|
QDict *input, *args;
|
||||||
const mon_cmd_t *cmd;
|
const mon_cmd_t *cmd;
|
||||||
const char *cmd_name;
|
const char *cmd_name;
|
||||||
Monitor *mon = cur_mon;
|
Monitor *mon = cur_mon;
|
||||||
|
|
||||||
args = input = NULL;
|
args = input = NULL;
|
||||||
|
data = NULL;
|
||||||
|
|
||||||
obj = json_parser_parse(tokens, NULL);
|
obj = json_parser_parse(tokens, NULL);
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
@ -5077,12 +5054,17 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens)
|
|||||||
goto err_out;
|
goto err_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
qmp_call_cmd(mon, cmd, args);
|
if (cmd->mhandler.cmd_new(mon, args, &data)) {
|
||||||
goto out;
|
/* Command failed... */
|
||||||
|
if (!monitor_has_error(mon)) {
|
||||||
|
/* ... without setting an error, so make one up */
|
||||||
|
qerror_report(QERR_UNDEFINED_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
err_out:
|
err_out:
|
||||||
monitor_protocol_emitter(mon, NULL);
|
monitor_protocol_emitter(mon, data);
|
||||||
out:
|
qobject_decref(data);
|
||||||
QDECREF(input);
|
QDECREF(input);
|
||||||
QDECREF(args);
|
QDECREF(args);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user