]> Git Repo - qemu.git/commitdiff
monitor: implement 'qmp_query_commands' without qmp_cmds
authorMarc-André Lureau <[email protected]>
Mon, 12 Sep 2016 09:19:05 +0000 (13:19 +0400)
committerMarkus Armbruster <[email protected]>
Mon, 19 Sep 2016 15:32:21 +0000 (17:32 +0200)
One step towards getting rid of the static qmp_cmds table.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Message-Id: <20160912091913[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
monitor.c

index 6e0ae814542e6e4f18c67db28af31bbd86086d29..f50aa6e5d02b08e6c23b0e3239d59505661a6f62 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -957,21 +957,28 @@ static void hmp_info_help(Monitor *mon, const QDict *qdict)
     help_cmd(mon, "info");
 }
 
-CommandInfoList *qmp_query_commands(Error **errp)
+static void query_commands_cb(QmpCommand *cmd, void *opaque)
 {
-    CommandInfoList *info, *cmd_list = NULL;
-    const mon_cmd_t *cmd;
-
-    for (cmd = qmp_cmds; cmd->name != NULL; cmd++) {
-        info = g_malloc0(sizeof(*info));
-        info->value = g_malloc0(sizeof(*info->value));
-        info->value->name = g_strdup(cmd->name);
+    CommandInfoList *info, **list = opaque;
 
-        info->next = cmd_list;
-        cmd_list = info;
+    if (!cmd->enabled) {
+        return;
     }
 
-    return cmd_list;
+    info = g_malloc0(sizeof(*info));
+    info->value = g_malloc0(sizeof(*info->value));
+    info->value->name = g_strdup(cmd->name);
+    info->next = *list;
+    *list = info;
+}
+
+CommandInfoList *qmp_query_commands(Error **errp)
+{
+    CommandInfoList *list = NULL;
+
+    qmp_for_each_command(query_commands_cb, &list);
+
+    return list;
 }
 
 EventInfoList *qmp_query_events(Error **errp)
This page took 0.031918 seconds and 4 git commands to generate.