qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH V2 3/3] HMP: add sub command table to info


From: Wenchao Xia
Subject: [Qemu-devel] [PATCH V2 3/3] HMP: add sub command table to info
Date: Thu, 27 Dec 2012 16:56:29 +0800

  Now info command takes a table of sub info commands,
and changed do_info() to do_info_help() to do help funtion
only.

Signed-off-by: Wenchao Xia <address@hidden>
---
 hmp-commands.hx |    3 ++-
 monitor.c       |   34 +++++++---------------------------
 2 files changed, 9 insertions(+), 28 deletions(-)

diff --git a/hmp-commands.hx b/hmp-commands.hx
index 010b8c9..87a411a 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1489,7 +1489,8 @@ ETEXI
         .args_type  = "item:s?",
         .params     = "[subcommand]",
         .help       = "show various information about the system state",
-        .mhandler.cmd = do_info,
+        .mhandler.cmd = do_info_help,
+        .sub_table = info_cmds,
     },
 
 STEXI
diff --git a/monitor.c b/monitor.c
index e4d4c59..e1bcaa2 100644
--- a/monitor.c
+++ b/monitor.c
@@ -807,28 +807,8 @@ static void user_async_cmd_handler(Monitor *mon, const 
mon_cmd_t *cmd,
     }
 }
 
-static void do_info(Monitor *mon, const QDict *qdict)
+static void do_info_help(Monitor *mon, const QDict *qdict)
 {
-    const mon_cmd_t *cmd;
-    const char *item = qdict_get_try_str(qdict, "item");
-
-    if (!item) {
-        goto help;
-    }
-
-    for (cmd = info_cmds; cmd->name != NULL; cmd++) {
-        if (compare_cmd(item, cmd->name))
-            break;
-    }
-
-    if (cmd->name == NULL) {
-        goto help;
-    }
-
-    cmd->mhandler.info(mon, NULL);
-    return;
-
-help:
     help_cmd(mon, "info");
 }
 
@@ -2422,12 +2402,6 @@ int monitor_handle_fd_param(Monitor *mon, const char 
*fdname)
     return fd;
 }
 
-/* mon_cmds and info_cmds would be sorted at runtime */
-static mon_cmd_t mon_cmds[] = {
-#include "hmp-commands.h"
-    { NULL, NULL, },
-};
-
 /* Please update hmp-commands.hx when adding or changing commands */
 static mon_cmd_t info_cmds[] = {
     {
@@ -2741,6 +2715,12 @@ static mon_cmd_t info_cmds[] = {
     },
 };
 
+/* mon_cmds and info_cmds would be sorted at runtime */
+static mon_cmd_t mon_cmds[] = {
+#include "hmp-commands.h"
+    { NULL, NULL, },
+};
+
 static const mon_cmd_t qmp_cmds[] = {
 #include "qmp-commands-old.h"
     { /* NULL */ },
-- 
1.7.1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]