From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42477) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGlOE-0005Ya-9o for qemu-devel@nongnu.org; Thu, 29 Jan 2015 04:28:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGlO5-0004GJ-14 for qemu-devel@nongnu.org; Thu, 29 Jan 2015 04:27:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59606) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGlO4-0004Fy-Q8 for qemu-devel@nongnu.org; Thu, 29 Jan 2015 04:27:44 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0T9RiTm003194 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 29 Jan 2015 04:27:44 -0500 From: Markus Armbruster Date: Thu, 29 Jan 2015 10:27:34 +0100 Message-Id: <1422523658-3503-6-git-send-email-armbru@redhat.com> In-Reply-To: <1422523658-3503-1-git-send-email-armbru@redhat.com> References: <1422523658-3503-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH v2 5/9] qmp: Simplify recognition of capability negotiation command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, lcapitulino@redhat.com Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- monitor.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/monitor.c b/monitor.c index 8323de3..2ac40c9 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; } -- 1.9.3