From: Markus Armbruster <armbru@redhat.com>
To: marcandre.lureau@redhat.com
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v4 09/17] monitor: implement 'qmp_query_commands' without qmp_cmds
Date: Tue, 16 Aug 2016 18:22:56 +0200 [thread overview]
Message-ID: <87pop8y97j.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20160810180235.32469-10-marcandre.lureau@redhat.com> (marcandre lureau's message of "Wed, 10 Aug 2016 22:02:27 +0400")
marcandre.lureau@redhat.com writes:
> From: Marc-André Lureau <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 2050698..cddc737 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)
This patch flips query-commands from qmp-commands.hx / qmp_cmds[] to
QAPI / qmp_for_each_command(). PATCH 06 "monitor: unregister
conditional commands" is needed here to keep the compile-time
conditional commands out of query-commands.
The previous patch started the transition from qmp-commands.hx /
qmp_cmds[] to QAPI / qmp_find_command(). It'll be completed in patch
14. PATCH 06 will be needed then so we keep rejecting the compile-time
conditional commands.
The compile-time conditional commands remain in query-qmp-schema despite
PATCH 06. No change. Okay.
PATCH 06's commit message could perhaps spell out these connections more
clearly. Here's my attempt:
monitor: unregister conditional commands
QMP commands are currently defined in two places: the QAPI schema
and qmp-commands.hx.
qmp-commands.hx uses the C preprocessor to define a number of
commands only conditionally. For instance, query-spice is #ifdef
CONFIG_SPICE.
The QAPI schema does no such thing.
The current QMP command dispatch and query-commands use a command
table generated from qmp-commands.hx. This table contains the
conditionally defined commands only when their conditions are met.
For instance, query-spice is accepted by command dispatch and shown
by query-commands only when CONFIG_SPICE is defined.
In contrast, query-qmp-schema uses the QAPI schema, and shows
conditional commands whether they're defined or not.
We're going to change QMP command dispatch and query-commands to use
QAPI, so we can define QMP commands in just one place. We need to
do something to avoid changing dispatch and query-spice.
Fortunately, a suitable mechanism already exists: we can make
commands disabled. Do that now. The patches that change dispatch
and query-commands will use it to avoid undue change.
Feel free to edit to taste. If you're happy with it as is, I can
replace the message on commit.
next prev parent reply other threads:[~2016-08-16 16:23 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-10 18:02 [Qemu-devel] [PATCH v4 00/17] qapi: remove the 'middle' mode marcandre.lureau
2016-08-10 18:02 ` [Qemu-devel] [PATCH v4 01/17] build-sys: define QEMU_VERSION_{MAJOR, MINOR, MICRO} marcandre.lureau
2016-08-10 18:02 ` [Qemu-devel] [PATCH v4 02/17] qapi-schema: use generated marshaller for 'qmp_capabilities' marcandre.lureau
2016-08-10 18:02 ` [Qemu-devel] [PATCH v4 03/17] qapi-schema: add 'device_add' marcandre.lureau
2016-08-10 18:02 ` [Qemu-devel] [PATCH v4 04/17] monitor: simplify invalid_qmp_mode() marcandre.lureau
2016-08-10 18:02 ` [Qemu-devel] [PATCH v4 05/17] monitor: register gen:false commands manually marcandre.lureau
2016-08-16 12:27 ` Markus Armbruster
2016-08-10 18:02 ` [Qemu-devel] [PATCH v4 06/17] monitor: unregister conditional commands marcandre.lureau
2016-08-16 14:26 ` Markus Armbruster
2016-08-16 14:34 ` Marc-André Lureau
2016-08-16 15:32 ` Markus Armbruster
2016-09-09 13:59 ` Markus Armbruster
2016-08-17 13:36 ` Markus Armbruster
2016-08-10 18:02 ` [Qemu-devel] [PATCH v4 07/17] qapi: export the marshallers marcandre.lureau
2016-08-10 18:02 ` [Qemu-devel] [PATCH v4 08/17] monitor: use qmp_find_command() (using generated qapi code) marcandre.lureau
2016-08-10 18:02 ` [Qemu-devel] [PATCH v4 09/17] monitor: implement 'qmp_query_commands' without qmp_cmds marcandre.lureau
2016-08-16 16:22 ` Markus Armbruster [this message]
2016-08-10 18:02 ` [Qemu-devel] [PATCH v4 10/17] monitor: remove mhandler.cmd_new marcandre.lureau
2016-08-10 18:02 ` [Qemu-devel] [PATCH v4 11/17] qapi: remove the "middle" mode marcandre.lureau
2016-08-10 18:02 ` [Qemu-devel] [PATCH v4 12/17] qapi: check invalid arguments on no-args commands marcandre.lureau
2016-08-17 14:47 ` Markus Armbruster
2016-08-17 15:49 ` Marc-André Lureau
2016-08-18 6:50 ` Markus Armbruster
2016-08-18 8:38 ` Marc-André Lureau
2016-08-10 18:02 ` [Qemu-devel] [PATCH v4 13/17] qmp: update qmp_query_spice fallback marcandre.lureau
2016-08-10 18:02 ` [Qemu-devel] [PATCH v4 14/17] monitor: use qmp_dispatch() marcandre.lureau
2016-08-10 18:02 ` [Qemu-devel] [PATCH v4 15/17] build-sys: remove qmp-commands-old.h marcandre.lureau
2016-08-10 18:02 ` [Qemu-devel] [PATCH v4 16/17] Replace qmp-commands.hx by doc/qmp-commands.txt marcandre.lureau
2016-08-17 15:01 ` Markus Armbruster
2016-08-10 18:02 ` [Qemu-devel] [PATCH v4 17/17] qmp-commands.txt: fix some styling marcandre.lureau
2016-08-11 4:45 ` [Qemu-devel] [PATCH v4 00/17] qapi: remove the 'middle' mode no-reply
2016-08-17 15:03 ` 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=87pop8y97j.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=marcandre.lureau@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.