qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [Qemu-devel] [PULL 04/18] monitor: simplify invalid_qmp_mode()
Date: Mon, 19 Sep 2016 18:41:20 +0200	[thread overview]
Message-ID: <1474303294-13952-5-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1474303294-13952-1-git-send-email-armbru@redhat.com>

From: Marc-André Lureau <marcandre.lureau@redhat.com>

handle_qmp_command() will switch to use qmp_dispatch().  It won't have a
pointer to the marshaller function anymore, but only the name of the
command to invoke. Simplify invalid_qmp_mode() so it can just be called
with the command name.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20160912091913.15831-5-marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 monitor.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/monitor.c b/monitor.c
index 991eaf7..e156026 100644
--- a/monitor.c
+++ b/monitor.c
@@ -3653,21 +3653,21 @@ static int monitor_can_read(void *opaque)
     return (mon->suspend_cnt == 0) ? 1 : 0;
 }
 
-static bool invalid_qmp_mode(const Monitor *mon, const mon_cmd_t *cmd,
+static bool invalid_qmp_mode(const Monitor *mon, const char *cmd,
                              Error **errp)
 {
-    bool is_cap = cmd->mhandler.cmd_new == qmp_marshal_qmp_capabilities;
+    bool is_cap = g_str_equal(cmd, "qmp_capabilities");
 
     if (is_cap && mon->qmp.in_command_mode) {
         error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND,
                   "Capabilities negotiation is already complete, command "
-                  "'%s' ignored", cmd->name);
+                  "'%s' ignored", cmd);
         return true;
     }
     if (!is_cap && !mon->qmp.in_command_mode) {
         error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND,
                   "Expecting capabilities negotiation with "
-                  "'qmp_capabilities' before command '%s'", cmd->name);
+                  "'qmp_capabilities' before command '%s'", cmd);
         return true;
     }
     return false;
@@ -3958,7 +3958,7 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
                   "The command %s has not been found", cmd_name);
         goto err_out;
     }
-    if (invalid_qmp_mode(mon, cmd, &local_err)) {
+    if (invalid_qmp_mode(mon, cmd_name, &local_err)) {
         goto err_out;
     }
 
-- 
2.5.5

  parent reply	other threads:[~2016-09-19 16:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-19 16:41 [Qemu-devel] [PULL 00/18] QAPI patches for 2016-09-19 Markus Armbruster
2016-09-19 16:41 ` [Qemu-devel] [PULL 01/18] build-sys: define QEMU_VERSION_{MAJOR, MINOR, MICRO} Markus Armbruster
2016-09-19 16:41 ` [Qemu-devel] [PULL 02/18] qapi-schema: use generated marshaller for 'qmp_capabilities' Markus Armbruster
2016-09-19 16:41 ` [Qemu-devel] [PULL 03/18] qapi-schema: add 'device_add' Markus Armbruster
2016-09-19 16:41 ` Markus Armbruster [this message]
2016-09-19 16:41 ` [Qemu-devel] [PULL 05/18] monitor: register gen:false commands manually Markus Armbruster
2016-09-19 16:41 ` [Qemu-devel] [PULL 06/18] qapi: Support unregistering QMP commands Markus Armbruster
2016-09-19 16:41 ` [Qemu-devel] [PULL 07/18] qmp: Hack to keep commands configuration-specific Markus Armbruster
2016-09-19 16:41 ` [Qemu-devel] [PULL 08/18] qapi: export the marshallers Markus Armbruster
2016-09-19 16:41 ` [Qemu-devel] [PULL 09/18] monitor: use qmp_find_command() (using generated qapi code) Markus Armbruster
2016-09-19 16:41 ` [Qemu-devel] [PULL 10/18] monitor: implement 'qmp_query_commands' without qmp_cmds Markus Armbruster
2016-09-19 16:41 ` [Qemu-devel] [PULL 11/18] monitor: remove mhandler.cmd_new Markus Armbruster
2016-09-19 16:41 ` [Qemu-devel] [PULL 12/18] qapi: remove the "middle" mode Markus Armbruster
2016-09-19 16:41 ` [Qemu-devel] [PULL 13/18] qapi: check invalid arguments on no-args commands Markus Armbruster
2016-09-19 16:41 ` [Qemu-devel] [PULL 14/18] tests: add a test to check invalid args Markus Armbruster
2016-09-19 16:41 ` [Qemu-devel] [PULL 15/18] monitor: use qmp_dispatch() Markus Armbruster
2016-09-19 16:41 ` [Qemu-devel] [PULL 16/18] build-sys: remove qmp-commands-old.h Markus Armbruster
2016-09-19 16:41 ` [Qemu-devel] [PULL 17/18] qmp-commands.hx: fix some styling Markus Armbruster
2016-09-19 16:41 ` [Qemu-devel] [PULL 18/18] Replace qmp-commands.hx by docs/qmp-commands.txt Markus Armbruster
2016-09-19 18:05 ` [Qemu-devel] [PULL 00/18] QAPI patches for 2016-09-19 Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1474303294-13952-5-git-send-email-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).