[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 08/15] monitor: implement 'qmp_query_commands' wi
From: |
marcandre . lureau |
Subject: |
[Qemu-devel] [PATCH v3 08/15] monitor: implement 'qmp_query_commands' without qmp_cmds |
Date: |
Mon, 8 Aug 2016 18:14:32 +0400 |
From: Marc-André Lureau <address@hidden>
One step towards getting rid of the static qmp_cmds table.
Signed-off-by: Marc-André Lureau <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
monitor.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/monitor.c b/monitor.c
index 6e96873..e7549b1 100644
--- a/monitor.c
+++ b/monitor.c
@@ -947,21 +947,24 @@ 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;
+ CommandInfoList *info, **list = opaque;
- 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);
+ info = g_malloc0(sizeof(*info));
+ info->value = g_malloc0(sizeof(*info->value));
+ info->value->name = g_strdup(cmd->name);
+ info->next = *list;
+ *list = info;
+}
- info->next = cmd_list;
- cmd_list = info;
- }
+CommandInfoList *qmp_query_commands(Error **errp)
+{
+ CommandInfoList *list = NULL;
+
+ qmp_for_each_command(query_commands_cb, &list);
- return cmd_list;
+ return list;
}
EventInfoList *qmp_query_events(Error **errp)
--
2.9.0
- [Qemu-devel] [PATCH v3 03/15] monitor: register gen:false commands manually, (continued)
- [Qemu-devel] [PATCH v3 03/15] monitor: register gen:false commands manually, marcandre . lureau, 2016/08/08
- [Qemu-devel] [PATCH v3 04/15] monitor: remove usage of generated marshal functions, marcandre . lureau, 2016/08/08
- [Qemu-devel] [PATCH v3 05/15] qapi: add 'export-marshal' command key, marcandre . lureau, 2016/08/08
- [Qemu-devel] [PATCH v3 06/15] monitor: register the qapi generated commands, marcandre . lureau, 2016/08/08
- [Qemu-devel] [PATCH v3 07/15] monitor: remove mhandler.cmd_new, marcandre . lureau, 2016/08/08
- [Qemu-devel] [PATCH v3 08/15] monitor: implement 'qmp_query_commands' without qmp_cmds,
marcandre . lureau <=
- [Qemu-devel] [PATCH v3 09/15] qapi: remove the "middle" mode, marcandre . lureau, 2016/08/08
- [Qemu-devel] [PATCH v3 10/15] qapi: check invalid arguments on no-args commands, marcandre . lureau, 2016/08/08
- [Qemu-devel] [PATCH v3 11/15] qmp: update qmp_query_spice fallback, marcandre . lureau, 2016/08/08
- [Qemu-devel] [PATCH v3 12/15] monitor: use qmp_dispatch(), marcandre . lureau, 2016/08/08