[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 10/18] monitor: implement 'qmp_query_commands' withou
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PULL 10/18] monitor: implement 'qmp_query_commands' without qmp_cmds |
Date: |
Mon, 19 Sep 2016 18:41:26 +0200 |
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>
Message-Id: <address@hidden>
Reviewed-by: Markus Armbruster <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
---
monitor.c | 29 ++++++++++++++++++-----------
1 file changed, 18 insertions(+), 11 deletions(-)
diff --git a/monitor.c b/monitor.c
index 6e0ae81..f50aa6e 100644
--- a/monitor.c
+++ b/monitor.c
@@ -957,21 +957,28 @@ static void hmp_info_help(Monitor *mon, const QDict
*qdict)
help_cmd(mon, "info");
}
+static void query_commands_cb(QmpCommand *cmd, void *opaque)
+{
+ CommandInfoList *info, **list = opaque;
+
+ if (!cmd->enabled) {
+ return;
+ }
+
+ 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 *info, *cmd_list = NULL;
- const mon_cmd_t *cmd;
+ CommandInfoList *list = NULL;
- 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);
+ qmp_for_each_command(query_commands_cb, &list);
- info->next = cmd_list;
- cmd_list = info;
- }
-
- return cmd_list;
+ return list;
}
EventInfoList *qmp_query_events(Error **errp)
--
2.5.5
- [Qemu-devel] [PULL 00/18] QAPI patches for 2016-09-19, Markus Armbruster, 2016/09/19
- [Qemu-devel] [PULL 03/18] qapi-schema: add 'device_add', Markus Armbruster, 2016/09/19
- [Qemu-devel] [PULL 05/18] monitor: register gen:false commands manually, Markus Armbruster, 2016/09/19
- [Qemu-devel] [PULL 08/18] qapi: export the marshallers, Markus Armbruster, 2016/09/19
- [Qemu-devel] [PULL 10/18] monitor: implement 'qmp_query_commands' without qmp_cmds,
Markus Armbruster <=
- [Qemu-devel] [PULL 13/18] qapi: check invalid arguments on no-args commands, Markus Armbruster, 2016/09/19
- [Qemu-devel] [PULL 14/18] tests: add a test to check invalid args, Markus Armbruster, 2016/09/19
- [Qemu-devel] [PULL 04/18] monitor: simplify invalid_qmp_mode(), Markus Armbruster, 2016/09/19
- [Qemu-devel] [PULL 01/18] build-sys: define QEMU_VERSION_{MAJOR, MINOR, MICRO}, Markus Armbruster, 2016/09/19
- [Qemu-devel] [PULL 06/18] qapi: Support unregistering QMP commands, Markus Armbruster, 2016/09/19
- [Qemu-devel] [PULL 02/18] qapi-schema: use generated marshaller for 'qmp_capabilities', Markus Armbruster, 2016/09/19
- [Qemu-devel] [PULL 17/18] qmp-commands.hx: fix some styling, Markus Armbruster, 2016/09/19
- [Qemu-devel] [PULL 16/18] build-sys: remove qmp-commands-old.h, Markus Armbruster, 2016/09/19
- [Qemu-devel] [PULL 12/18] qapi: remove the "middle" mode, Markus Armbruster, 2016/09/19
- [Qemu-devel] [PULL 18/18] Replace qmp-commands.hx by docs/qmp-commands.txt, Markus Armbruster, 2016/09/19