qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, armbru@redhat.com, aliguori@us.ibm.com,
	mdroth@linux.vnet.ibm.com, quintela@redhat.com
Subject: [Qemu-devel] [PATCH 17/19] QMP: Drop the query commands dispatch table
Date: Mon, 24 Oct 2011 11:27:10 -0200	[thread overview]
Message-ID: <1319462832-12199-18-git-send-email-lcapitulino@redhat.com> (raw)
In-Reply-To: <1319462832-12199-1-git-send-email-lcapitulino@redhat.com>

Because QMP development originated in the monitor, it has
inherited the monitor's distinction between query- and
non-query commands.

However, previous commits unified both commands and the
distinction is gone. This commit drops the query commands
dispatch table and does some simplifications along the way.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c |   63 ++++--------------------------------------------------------
 1 files changed, 5 insertions(+), 58 deletions(-)

diff --git a/monitor.c b/monitor.c
index edcacda..1e09b91 100644
--- a/monitor.c
+++ b/monitor.c
@@ -205,7 +205,6 @@ static const mon_cmd_t mon_cmds[];
 static const mon_cmd_t info_cmds[];
 
 static const mon_cmd_t qmp_cmds[];
-static const mon_cmd_t qmp_query_cmds[];
 
 Monitor *cur_mon;
 Monitor *default_mon;
@@ -663,11 +662,6 @@ static int qmp_async_cmd_handler(Monitor *mon, const mon_cmd_t *cmd,
     return cmd->mhandler.cmd_async(mon, params, qmp_monitor_complete, mon);
 }
 
-static void qmp_async_info_handler(Monitor *mon, const mon_cmd_t *cmd)
-{
-    cmd->mhandler.info_async(mon, qmp_monitor_complete, mon);
-}
-
 static void user_async_cmd_handler(Monitor *mon, const mon_cmd_t *cmd,
                                    const QDict *params)
 {
@@ -738,32 +732,16 @@ help:
     help_cmd(mon, "info");
 }
 
-static CommandInfoList *alloc_cmd_entry(const char *cmd_name)
-{
-    CommandInfoList *info;
-
-    info = g_malloc0(sizeof(*info));
-    info->value = g_malloc0(sizeof(*info->value));
-    info->value->name = g_strdup(cmd_name);
-
-    return info;
-}
-
 CommandInfoList *qmp_query_commands(Error **errp)
 {
     CommandInfoList *info, *cmd_list = NULL;
     const mon_cmd_t *cmd;
 
     for (cmd = qmp_cmds; cmd->name != NULL; cmd++) {
-        info = alloc_cmd_entry(cmd->name);
-        info->next = cmd_list;
-        cmd_list = info;
-    }
+        info = g_malloc0(sizeof(*info));
+        info->value = g_malloc0(sizeof(*info->value));
+        info->value->name = g_strdup(cmd->name);
 
-    for (cmd = qmp_query_cmds; cmd->name != NULL; cmd++) {
-        char buf[128];
-        snprintf(buf, sizeof(buf), "query-%s", cmd->name);
-        info = alloc_cmd_entry(buf);
         info->next = cmd_list;
         cmd_list = info;
     }
@@ -2952,10 +2930,6 @@ static const mon_cmd_t qmp_cmds[] = {
     { /* NULL */ },
 };
 
-static const mon_cmd_t qmp_query_cmds[] = {
-    { /* NULL */ },
-};
-
 /*******************************************************************/
 
 static const char *pch;
@@ -3750,11 +3724,6 @@ static const mon_cmd_t *monitor_find_command(const char *cmdname)
     return search_dispatch_table(mon_cmds, cmdname);
 }
 
-static const mon_cmd_t *qmp_find_query_cmd(const char *info_item)
-{
-    return search_dispatch_table(qmp_query_cmds, info_item);
-}
-
 static const mon_cmd_t *qmp_find_cmd(const char *cmdname)
 {
     return search_dispatch_table(qmp_cmds, cmdname);
@@ -4678,22 +4647,6 @@ static QDict *qmp_check_input_obj(QObject *input_obj)
     return input_dict;
 }
 
-static void qmp_call_query_cmd(Monitor *mon, const mon_cmd_t *cmd)
-{
-    QObject *ret_data = NULL;
-
-    if (handler_is_async(cmd)) {
-        qmp_async_info_handler(mon, cmd);
-        if (monitor_has_error(mon)) {
-            monitor_protocol_emitter(mon, NULL);
-        }
-    } else {
-        cmd->mhandler.info_new(mon, &ret_data);
-        monitor_protocol_emitter(mon, ret_data);
-        qobject_decref(ret_data);
-    }
-}
-
 static void qmp_call_cmd(Monitor *mon, const mon_cmd_t *cmd,
                          const QDict *params)
 {
@@ -4714,10 +4667,9 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens)
     QObject *obj;
     QDict *input, *args;
     const mon_cmd_t *cmd;
+    const char *cmd_name;
     Monitor *mon = cur_mon;
-    const char *cmd_name, *query_cmd;
 
-    query_cmd = NULL;
     args = input = NULL;
 
     obj = json_parser_parse(tokens, NULL);
@@ -4744,9 +4696,6 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens)
     }
 
     cmd = qmp_find_cmd(cmd_name);
-    if (!cmd && strstart(cmd_name, "query-", &query_cmd)) {
-        cmd = qmp_find_query_cmd(query_cmd);
-    }
     if (!cmd) {
         qerror_report(QERR_COMMAND_NOT_FOUND, cmd_name);
         goto err_out;
@@ -4765,9 +4714,7 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens)
         goto err_out;
     }
 
-    if (query_cmd) {
-        qmp_call_query_cmd(mon, cmd);
-    } else if (handler_is_async(cmd)) {
+    if (handler_is_async(cmd)) {
         err = qmp_async_cmd_handler(mon, cmd, args);
         if (err) {
             /* emit the error response */
-- 
1.7.7.1.431.g10b2a

  parent reply	other threads:[~2011-10-24 13:27 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-24 13:26 [Qemu-devel] [PATCH v1 00/19]: QAPI conversions round 2 Luiz Capitulino
2011-10-24 13:26 ` [Qemu-devel] [PATCH 01/19] qapi-commands.py: Don't call the output marshal on error Luiz Capitulino
2011-10-24 13:26 ` [Qemu-devel] [PATCH 02/19] qapi: Convert query-mice Luiz Capitulino
2011-10-24 13:26 ` [Qemu-devel] [PATCH 03/19] qapi: Convert query-migrate Luiz Capitulino
2011-10-24 13:26 ` [Qemu-devel] [PATCH 04/19] Monitor: Make mon_set_cpu() public Luiz Capitulino
2011-10-24 13:26 ` [Qemu-devel] [PATCH 05/19] Monitor: Introduce monitor_get_cpu_index() Luiz Capitulino
2011-10-24 13:26 ` [Qemu-devel] [PATCH 06/19] qapi: Convert the cpu command Luiz Capitulino
2011-10-24 13:27 ` [Qemu-devel] [PATCH 07/19] qapi: Convert query-cpus Luiz Capitulino
2011-10-24 13:27 ` [Qemu-devel] [PATCH 08/19] block: iostatus: Drop BDRV_IOS_INVAL Luiz Capitulino
2011-10-24 13:27 ` [Qemu-devel] [PATCH 09/19] block: Rename the BlockIOStatus enum values Luiz Capitulino
2011-10-24 13:27 ` [Qemu-devel] [PATCH 10/19] qapi: Convert query-block Luiz Capitulino
2011-10-24 13:27 ` [Qemu-devel] [PATCH 11/19] qapi: Convert query-blockstats Luiz Capitulino
2011-10-24 13:27 ` [Qemu-devel] [PATCH 12/19] qerror: Add a user string for QERR_FEATURE_DISABLED Luiz Capitulino
2011-10-24 13:27 ` [Qemu-devel] [PATCH 13/19] qapi: Convert query-vnc Luiz Capitulino
2011-10-24 13:27 ` [Qemu-devel] [PATCH 14/19] qapi: Convert query-spice Luiz Capitulino
2011-10-24 13:27 ` [Qemu-devel] [PATCH 15/19] qapi: Convert query-balloon Luiz Capitulino
2011-10-24 13:27 ` [Qemu-devel] [PATCH 16/19] qapi: Convert query-pci Luiz Capitulino
2011-10-24 13:27 ` Luiz Capitulino [this message]
2011-10-24 13:27 ` [Qemu-devel] [PATCH 18/19] Monitor: do_info(): Drop QMP command handling code Luiz Capitulino
2011-10-24 13:27 ` [Qemu-devel] [PATCH 19/19] Drop qemu-objects.h from modules that don't require it Luiz Capitulino
  -- strict thread matches above, loose matches on Subject: below --
2011-10-27 19:01 [Qemu-devel] [PULL 00/19]: QMP queue Luiz Capitulino
2011-10-27 19:02 ` [Qemu-devel] [PATCH 17/19] QMP: Drop the query commands dispatch table Luiz Capitulino

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=1319462832-12199-18-git-send-email-lcapitulino@redhat.com \
    --to=lcapitulino@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /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).