Patchwork [V4,4/4] HMP: add sub command table to info

login
register
mail settings
Submitter Wayne Xia
Date Jan. 10, 2013, 8:32 a.m.
Message ID <1357806754-8552-5-git-send-email-xiawenc@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/210950/
State New
Headers show

Comments

Wayne Xia - Jan. 10, 2013, 8:32 a.m.
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 <xiawenc@linux.vnet.ibm.com>
---
 hmp-commands.hx |    3 ++-
 monitor.c       |   22 +---------------------
 2 files changed, 3 insertions(+), 22 deletions(-)
Markus Armbruster - Jan. 10, 2013, 10:24 a.m.
Wenchao Xia <xiawenc@linux.vnet.ibm.com> writes:

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

Commit message should document that info <unknown-topic> no longer lists
the topics.
Wayne Xia - Jan. 11, 2013, 3:13 a.m.
于 2013-1-10 18:24, Markus Armbruster 写道:
> Wenchao Xia <xiawenc@linux.vnet.ibm.com> writes:
> 
>>    Now info command takes a table of sub info commands,
>> and changed do_info() to do_info_help() to do help funtion
>> only.
> 
> Commit message should document that info <unknown-topic> no longer lists
> the topics.
> 
  OK.

Patch

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 3657224..9daaa63 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");
 }