From: Markus Armbruster <armbru@redhat.com>
To: marcandre.lureau@redhat.com
Cc: qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 05/12] monitor: register the qapi generated commands
Date: Fri, 05 Aug 2016 14:42:15 +0200 [thread overview]
Message-ID: <87invfv13s.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20160721140030.28383-6-marcandre.lureau@redhat.com> (marcandre lureau's message of "Thu, 21 Jul 2016 18:00:23 +0400")
marcandre.lureau@redhat.com writes:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Stop using the so-called 'middle' mode. Instead, use qmp_find_command()
> from generated qapi commands registry.
>
> Note: this commit requires a 'make clean' prior to make, since the
> generated files do not depend on Makefile (due to a cyclic rule
> introduced in 4115852bb0).
We generally say "commit 4115852bb0".
Sounds like we had a cyclic dependency. Do you mean "they don't depend
on Makefile, because that would be a cyclic dependency"?
Paolo, any smart ideas on how to avoid "requires a 'make clean'"?
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> monitor.c | 15 ++++--
> Makefile | 2 +-
> qmp-commands.hx | 143 --------------------------------------------------------
> vl.c | 1 +
> 4 files changed, 13 insertions(+), 148 deletions(-)
>
> diff --git a/monitor.c b/monitor.c
> index 3a28b43..5bbe4bb 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -3934,6 +3934,7 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
> QObject *obj, *data;
> QDict *input, *args;
> const mon_cmd_t *cmd;
> + QmpCommand *qcmd;
> const char *cmd_name;
> Monitor *mon = cur_mon;
>
> @@ -3959,7 +3960,8 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
> cmd_name = qdict_get_str(input, "execute");
> trace_handle_qmp_command(mon, cmd_name);
> cmd = qmp_find_cmd(cmd_name);
> - if (!cmd) {
> + qcmd = qmp_find_command(cmd_name);
> + if (!qcmd || !cmd) {
Looks awkward, but it's temporary. Makes sense.
> error_set(&local_err, ERROR_CLASS_COMMAND_NOT_FOUND,
> "The command %s has not been found", cmd_name);
> goto err_out;
> @@ -3981,7 +3983,7 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
> goto err_out;
> }
>
> - cmd->mhandler.cmd_new(args, &data, &local_err);
> + qcmd->fn(args, &data, &local_err);
>
> err_out:
> monitor_protocol_emitter(mon, data, local_err);
> @@ -4050,10 +4052,15 @@ void monitor_resume(Monitor *mon)
>
> static QObject *get_qmp_greeting(void)
> {
> + QmpCommand *cmd;
> QObject *ver = NULL;
>
> - qmp_marshal_query_version(NULL, &ver, NULL);
> - return qobject_from_jsonf("{'QMP':{'version': %p,'capabilities': []}}",ver);
> + cmd = qmp_find_command("query-version");
> + assert(cmd && cmd->fn);
> + cmd->fn(NULL, &ver, NULL);
> +
> + return qobject_from_jsonf("{'QMP':{'version': %p, 'capabilities': []}}",
> + ver);
Meh.
The generator makes the generated qmp_marshal_FOOs() static unless
middle mode. Middle mode is going away (good riddance). But replacing
the linker's work by qmp_find_command() just so we can keep the
qmp_marshal_FOOs() static isn't an improvement. Especially since it
adds another run-time failure mode. Let's change the generator instead.
> }
>
> static void monitor_qmp_event(void *opaque, int event)
> diff --git a/Makefile b/Makefile
> index 0d7647f..fcdc192 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -311,7 +311,7 @@ $(qapi-modules) $(SRC_PATH)/scripts/qapi-event.py $(qapi-py)
> qmp-commands.h qmp-marshal.c :\
> $(qapi-modules) $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
> $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \
> - $(gen-out-type) -o "." -m $<, \
> + $(gen-out-type) -o "." $<, \
> " GEN $@")
> qmp-introspect.h qmp-introspect.c :\
> $(qapi-modules) $(SRC_PATH)/scripts/qapi-introspect.py $(qapi-py)
> diff --git a/qmp-commands.hx b/qmp-commands.hx
> index 13707ac..1ad8dda 100644
> --- a/qmp-commands.hx
> +++ b/qmp-commands.hx
> @@ -63,7 +63,6 @@ EQMP
> {
> .name = "quit",
> .args_type = "",
> - .mhandler.cmd_new = qmp_marshal_quit,
> },
>
> SQMP
[More of the same snipped...]
> diff --git a/vl.c b/vl.c
> index a455947..a819e05 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2971,6 +2971,7 @@ int main(int argc, char **argv, char **envp)
> qemu_init_exec_dir(argv[0]);
>
> module_call_init(MODULE_INIT_QOM);
> + module_call_init(MODULE_INIT_QAPI);
>
> qemu_add_opts(&qemu_drive_opts);
> qemu_add_drive_opts(&qemu_legacy_drive_opts);
So the code added by PATCH 03 doesn't actually run without this, right?
Okay with me, but let's mention it in the commit message of PATCH 03.
next prev parent reply other threads:[~2016-08-05 12:42 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-21 14:00 [Qemu-devel] [PATCH v2 00/12] qapi: remove the 'middle' mode marcandre.lureau
2016-07-21 14:00 ` [Qemu-devel] [PATCH v2 01/12] qapi-schema: use generated marshaller for 'qmp_capabilities' marcandre.lureau
2016-08-05 10:52 ` Markus Armbruster
2016-07-21 14:00 ` [Qemu-devel] [PATCH v2 02/12] qapi-schema: add 'device_add' marcandre.lureau
2016-07-21 20:44 ` Eric Blake
2016-07-22 7:13 ` Marc-André Lureau
2016-08-05 12:10 ` Markus Armbruster
2016-07-21 14:00 ` [Qemu-devel] [PATCH v2 03/12] monitor: register gen:false commands manually marcandre.lureau
2016-07-21 20:50 ` Eric Blake
2016-07-21 14:00 ` [Qemu-devel] [PATCH v2 04/12] monitor: remove usage of generated marshal functions marcandre.lureau
2016-08-05 12:17 ` Markus Armbruster
2016-08-05 12:22 ` Marc-André Lureau
2016-08-05 13:43 ` Markus Armbruster
2016-07-21 14:00 ` [Qemu-devel] [PATCH v2 05/12] monitor: register the qapi generated commands marcandre.lureau
2016-07-21 20:56 ` Eric Blake
2016-08-05 12:42 ` Markus Armbruster [this message]
2016-08-08 10:10 ` Paolo Bonzini
2016-07-21 14:00 ` [Qemu-devel] [PATCH v2 06/12] monitor: remove mhandler.cmd_new marcandre.lureau
2016-07-21 21:02 ` Eric Blake
2016-07-22 7:20 ` Marc-André Lureau
2016-08-05 12:52 ` Markus Armbruster
2016-08-05 13:00 ` Marc-André Lureau
2016-08-05 13:44 ` Markus Armbruster
2016-07-21 14:00 ` [Qemu-devel] [PATCH v2 07/12] monitor: implement 'qmp_query_commands' without qmp_cmds marcandre.lureau
2016-07-21 22:51 ` Eric Blake
2016-08-05 13:25 ` Markus Armbruster
2016-07-21 14:00 ` [Qemu-devel] [PATCH v2 08/12] build-sys: remove qmp-commands-old.h marcandre.lureau
2016-07-21 22:52 ` Eric Blake
2016-07-21 14:00 ` [Qemu-devel] [PATCH v2 09/12] qapi: remove the "middle" mode marcandre.lureau
2016-07-21 22:55 ` Eric Blake
2016-07-22 7:35 ` Marc-André Lureau
2016-08-05 13:31 ` Markus Armbruster
2016-07-21 14:00 ` [Qemu-devel] [PATCH v2 10/12] monitor: use qmp_dispatch() marcandre.lureau
2016-08-05 14:43 ` Markus Armbruster
2016-07-21 14:00 ` [Qemu-devel] [PATCH v2 11/12] qmp: update qmp_query_spice fallback marcandre.lureau
2016-08-05 13:40 ` Markus Armbruster
2016-08-05 13:43 ` Marc-André Lureau
2016-08-05 14:38 ` Markus Armbruster
2016-07-21 14:00 ` [Qemu-devel] [PATCH v2 12/12] Drop qmp-commands.hx marcandre.lureau
2016-08-05 14:56 ` Markus Armbruster
2016-08-05 18:32 ` Marc-André Lureau
2016-08-09 13:08 ` Markus Armbruster
2016-08-09 14:50 ` Marc-André Lureau
2016-08-09 16:32 ` 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=87invfv13s.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@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.