aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2015-01-13 16:14:04 +0100
committerMarkus Armbruster <armbru@redhat.com>2015-01-29 10:01:58 +0100
commitbb5224edfb1e6f94aabaa8070d11c8f95f8ae277 (patch)
tree6f2b2bb99173ad9ed225763d5861e89e865db427
parentad0ec14bad645d9c0402047e858ea323151c8e9b (diff)
qmp: Simplify recognition of capability negotiation command
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
-rw-r--r--monitor.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/monitor.c b/monitor.c
index 8323de3ebc..2ac40c9e2b 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4783,9 +4783,9 @@ static int monitor_can_read(void *opaque)
return (mon->suspend_cnt == 0) ? 1 : 0;
}
-static int invalid_qmp_mode(const Monitor *mon, const char *cmd_name)
+static int invalid_qmp_mode(const Monitor *mon, const mon_cmd_t *cmd)
{
- int is_cap = compare_cmd(cmd_name, "qmp_capabilities");
+ int is_cap = cmd->mhandler.cmd_new == do_qmp_capabilities;
return (qmp_cmd_mode(mon) ? is_cap : !is_cap);
}
@@ -5079,13 +5079,8 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens)
cmd_name = qdict_get_str(input, "execute");
trace_handle_qmp_command(mon, cmd_name);
- if (invalid_qmp_mode(mon, cmd_name)) {
- qerror_report(QERR_COMMAND_NOT_FOUND, cmd_name);
- goto err_out;
- }
-
cmd = qmp_find_cmd(cmd_name);
- if (!cmd) {
+ if (!cmd || invalid_qmp_mode(mon, cmd)) {
qerror_report(QERR_COMMAND_NOT_FOUND, cmd_name);
goto err_out;
}