All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: qemu-devel@nongnu.org
Cc: eblake@redhat.com, armbru@redhat.com,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [Qemu-devel] [PATCH v5 13/20] monitor: implement 'qmp_query_commands' without qmp_cmds
Date: Wed, 17 Aug 2016 20:57:50 +0400	[thread overview]
Message-ID: <20160817165757.23486-14-marcandre.lureau@redhat.com> (raw)
In-Reply-To: <20160817165757.23486-1-marcandre.lureau@redhat.com>

One step towards getting rid of the static qmp_cmds table.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 monitor.c | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/monitor.c b/monitor.c
index e72804a..dad49b6 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");
 }
 
-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)
-- 
2.9.0

  parent reply	other threads:[~2016-08-17 16:58 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-17 16:57 [Qemu-devel] [PATCH v5 00/20] qapi: remove the 'middle' mode Marc-André Lureau
2016-08-17 16:57 ` [Qemu-devel] [PATCH v5 01/20] tests: do qmp introspect validation per target Marc-André Lureau
2016-08-17 16:57 ` [Qemu-devel] [PATCH v5 02/20] qapi.py: add a simple #ifdef conditional Marc-André Lureau
2016-09-06 12:35   ` Markus Armbruster
2016-09-06 13:17     ` Marc-André Lureau
2016-09-06 15:58       ` Markus Armbruster
2016-09-06 16:44         ` Marc-André Lureau
2016-09-07  8:44           ` Markus Armbruster
2016-09-07 13:40             ` Markus Armbruster
2016-09-07 14:23               ` Marc-André Lureau
2016-09-07 18:49               ` Eric Blake
2016-08-17 16:57 ` [Qemu-devel] [PATCH v5 03/20] build-sys: make qemu qapi per-target Marc-André Lureau
2016-08-17 16:57 ` [Qemu-devel] [PATCH v5 04/20] build-sys: use config headers to generate qapi Marc-André Lureau
2016-08-17 16:57 ` [Qemu-devel] [PATCH v5 05/20] qapi: configure the schema Marc-André Lureau
2016-08-17 16:57 ` [Qemu-devel] [PATCH v5 06/20] build-sys: define QEMU_VERSION_{MAJOR, MINOR, MICRO} Marc-André Lureau
2016-08-17 16:57 ` [Qemu-devel] [PATCH v5 07/20] qapi-schema: use generated marshaller for 'qmp_capabilities' Marc-André Lureau
2016-08-17 16:57 ` [Qemu-devel] [PATCH v5 08/20] qapi-schema: add 'device_add' Marc-André Lureau
2016-08-17 16:57 ` [Qemu-devel] [PATCH v5 09/20] monitor: simplify invalid_qmp_mode() Marc-André Lureau
2016-08-17 16:57 ` [Qemu-devel] [PATCH v5 10/20] monitor: register gen:false commands manually Marc-André Lureau
2016-08-17 16:57 ` [Qemu-devel] [PATCH v5 11/20] qapi: export the marshallers Marc-André Lureau
2016-08-17 16:57 ` [Qemu-devel] [PATCH v5 12/20] monitor: use qmp_find_command() (using generated qapi code) Marc-André Lureau
2016-08-17 16:57 ` Marc-André Lureau [this message]
2016-08-17 16:57 ` [Qemu-devel] [PATCH v5 14/20] monitor: remove mhandler.cmd_new Marc-André Lureau
2016-08-17 16:57 ` [Qemu-devel] [PATCH v5 15/20] qapi: remove the "middle" mode Marc-André Lureau
2016-08-17 16:57 ` [Qemu-devel] [PATCH v5 16/20] qapi: check invalid arguments on no-args commands Marc-André Lureau
2016-08-17 16:57 ` [Qemu-devel] [PATCH v5 17/20] monitor: use qmp_dispatch() Marc-André Lureau
2016-08-17 17:04   ` Marc-André Lureau
2016-08-17 16:57 ` [Qemu-devel] [PATCH v5 18/20] build-sys: remove qmp-commands-old.h Marc-André Lureau
2016-08-17 16:57 ` [Qemu-devel] [PATCH v5 19/20] qmp-commands.hx: fix some styling Marc-André Lureau
2016-08-17 16:57 ` [Qemu-devel] [PATCH v5 20/20] Replace qmp-commands.hx by doc/qmp-commands.txt Marc-André Lureau
2016-09-09 12:43   ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160817165757.23486-14-marcandre.lureau@redhat.com \
    --to=marcandre.lureau@redhat.com \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.