All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marc-André Lureau" <marcandre.lureau@gmail.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v3 12/15] monitor: use qmp_dispatch()
Date: Wed, 10 Aug 2016 15:28:07 +0000	[thread overview]
Message-ID: <CAJ+F1CLozdBbvoEVGvkND3QzUcFd4DTK3nFS+Nd5ttoPjPv-jA@mail.gmail.com> (raw)
In-Reply-To: <87vaz9x71b.fsf@dusky.pond.sub.org>

Hi

On Wed, Aug 10, 2016 at 2:17 PM Markus Armbruster <armbru@redhat.com> wrote:

> Marc-André Lureau <marcandre.lureau@gmail.com> writes:
>
> > Hi
> >
> > On Tue, Aug 9, 2016 at 9:35 PM Markus Armbruster <armbru@redhat.com>
> wrote:
> >
> >> Marc-André Lureau <mlureau@redhat.com> writes:
> >>
> >> > Hi
> >> >
> >> > ----- Original Message -----
> >> >> Marc-André Lureau <mlureau@redhat.com> writes:
> >> >>
> >> >> > Hi
> >> >> >
> >> >> > ----- Original Message -----
> >> >> >> marcandre.lureau@redhat.com writes:
> >> >> >>
> >> >> >> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> >> >> >> >
> >> >> >> > Replace the old manual dispatch and validation code by the
> generic
> >> one
> >> >> >> > provided by qapi common code.
> >> >> >> >
> >> >> >> > Note that it is now possible to call the following commands that
> >> used to
> >> >> >> > be disabled by compile-time conditionals:
> >> >> >> > - dump-skeys
> >> >> >> > - query-spice
> >> >> >> > - rtc-reset-reinjection
> >> >> >> > - query-gic-capabilities
> >> >> >> >
> >> >> >> > Their fallback functions return an appropriate "feature
> disabled"
> >> error.
> >> >> >> >
> >> >> >> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> >> >> >>
> >> >> >> Means query-qmp-schema no longer shows whether these commands are
> >> >> >> supported, doesn't it?
> >> >> >>
> >> >> >> Eric, could this create difficulties for libvirt or other
> >> introspection
> >> >> >> users?
> >> >> >
> >> >> > Thinking a bit about this, I guess it would be fairly
> straightforward
> >> >> > to have a new key "c-conditional" : "#ifdef CONFIG_SPICE" that
> would
> >> >> > prepend it in C generated files, with a corresponding "#endif".
> Would
> >> >> > that be acceptable?
> >> >>
> >> >> Not exactly pretty, but the only alternative I can think of right now
> >> >> would be conditional qapi generation, i.e. something like
> >> >>
> >> >> { 'if': 'CONFIG_SPICE'
> >> >>   'then': { 'command': 'query-spice', 'returns': 'SpiceInfo' } }
> >> >>
> >> >> More general, but *much* more work.  Let's not go there now.
> >> >
> >> > That looks quite unnecessarily complicated to me, and not so
> declarative.
> >> >
> >> >>
> >> >> The value of key 'c-conditional' must be a preprocessing directive
> that
> >> >> pairs with #endif.  Hmm.
> >> >>
> >> >> Could make it an expression instead, and call the key just
> >> >> 'conditional'.  If given, wrap the code generated for the QAPI
> >> >> definition in
> >> >>
> >> >>     #if <value of conditional>
> >> >>     ...
> >> >>     #endif
> >> >>
> >> >
> >> > Sure, we could make it a preprocessor expression instead, so it would
> >> have to match with the automatically appened "#endif".
> >> >
> >> >> Feels cleaner, but to avoid -Wundef warnings, we'd have to say
> >> >> 'defined(CONFIG_SPICE)'.
> >> >
> >> > Yes, why not? I can work on a patch see how well it fits.
> >>
> >> Yes, please.
> >>
> >
> > After spending some time on this (the generator part is trivial), I think
> > it's not going to be that easy because the conditions are per-target, but
> > qmp is not, so you get poisoned defines errors with the TARGET
> conditions.
>
> Ah, yes.  monitor.c is target-specific for similarly annoying reasons.
> Factoring out the parts that are actually target-specific into a
> separate file would be nice.
>
> > We can't easily make qmp per target, as the code is spread everywhere
> (even
>
> What you mean by "qmp" and ...
>
> > though such qmp code won't be useful for other tools, it would be nice to
> > untangle this - the block code is full of qmp usage and implementation)
>
> ... "qmp usage and implementation"?
>

Building and linking with the generated qapi/qmp code (even though they may
not actually use it..)

>
> > Furthermore, the current query-qmp-schema returns all commands currently,
> > so this won't be a regression.
>
> It returns qmp_schema_json[], generated by qapi-introspect.py.
>
>
Right so it returns everything from the schema. The difference is that with
this series, query-commands will now return everything from the schema. And
the command will return feature-disabled error. Is that an acceptable
regression? or should it be fixed before that series?


> > - unregister functions dynamically? (that could be useful for other
> reasons)
> > - make only qmp_init_marshal() and qmp_introspect() per target.
> >
> > That last option seems the easier. What do you think?
>
> Let me try to elaborate the last option to make sure we're on the same
> page.
>
> Key 'conditional' makes the QAPI generators generate preprocessing
> directives for conditional compilation.  Only commands have this key, at
> least for now.  The preprocessing directives should wrap "everything"
> belonging to the command:
>
> * Command handler declaration in qmp-commands.h
>
>   Problem: this header gets included widely, and we really don't want to
>   make all the .c files including it target-dependent.
>
>   Howeve, since a declaration without an implementation is not an error,
>   we can blindly generate the declarations for now, along with a TODO
>   comment explaining the uncleanliness.
>
> * Command marshaller declaration in qmp-commands.h
>
>   Likewise.
>
> * Command marshaller definition in qmp-marshal.c
>
>   Can make target-dependent.  It's a big file, though.  Perhaps we can
>   split it into a target-dependent and a target-independent part some
>   day.
>
> * Command marshaller use in qmp-marshal.c's qmp_init_marshal()
>
>   Likewise.
>
> * Command introspection data in qmp-introspect.c.
>
>   Can make target-dependent.  Splitting it up doesn't look worth the
>   bother.
>
> Is this basically what you're proposing?
>

Yes, I got it working. But then I started to wonder about the rest of the
events & data types, and I figured it would be probably best  handled by a
c preprocessor (so you could have large #if blocks instead of plenty of
'c-conditional' keys, and a generated file with lot of #ifs that could have
been not there at generation time). Unfortunately, our json files aren't
really 'json', and in particular our #-shellish comments do not play nice
with the C preprocessor.

I don't really fancy changing all the doc format right now, or fixing the
json usage (to be a valid json), since I have a lot of doc patches after,
that would conflict a lot! And it's probably best to automate the move once
all the doc is at the same place..

So I wonder if it's acceptable to have query-commands return commands that
return feature-disabled errors. After all, the command exists, and it
returns a 'valid' reply. Alternatively, I think we could have the commands
removed at run-time for now until we fix this at compile time after the doc
series is merged.
-- 
Marc-André Lureau

  reply	other threads:[~2016-08-10 15:28 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-08 14:14 [Qemu-devel] [PATCH v3 00/15] qapi: remove the 'middle' mode marcandre.lureau
2016-08-08 14:14 ` [Qemu-devel] [PATCH v3 01/15] qapi-schema: use generated marshaller for 'qmp_capabilities' marcandre.lureau
2016-08-09 11:22   ` Markus Armbruster
2016-08-08 14:14 ` [Qemu-devel] [PATCH v3 02/15] qapi-schema: add 'device_add' marcandre.lureau
2016-08-08 14:14 ` [Qemu-devel] [PATCH v3 03/15] monitor: register gen:false commands manually marcandre.lureau
2016-08-09  7:52   ` Markus Armbruster
2016-08-09 17:16     ` Marc-André Lureau
2016-08-08 14:14 ` [Qemu-devel] [PATCH v3 04/15] monitor: remove usage of generated marshal functions marcandre.lureau
2016-08-09  8:36   ` Markus Armbruster
2016-08-09  8:43     ` Marc-André Lureau
2016-08-08 14:14 ` [Qemu-devel] [PATCH v3 05/15] qapi: add 'export-marshal' command key marcandre.lureau
2016-08-09  8:05   ` Markus Armbruster
2016-08-09  8:38     ` Marc-André Lureau
2016-08-09 14:35       ` Markus Armbruster
2016-08-08 14:14 ` [Qemu-devel] [PATCH v3 06/15] monitor: register the qapi generated commands marcandre.lureau
2016-08-08 14:14 ` [Qemu-devel] [PATCH v3 07/15] monitor: remove mhandler.cmd_new marcandre.lureau
2016-08-08 14:14 ` [Qemu-devel] [PATCH v3 08/15] monitor: implement 'qmp_query_commands' without qmp_cmds marcandre.lureau
2016-08-08 14:14 ` [Qemu-devel] [PATCH v3 09/15] qapi: remove the "middle" mode marcandre.lureau
2016-08-08 14:14 ` [Qemu-devel] [PATCH v3 10/15] qapi: check invalid arguments on no-args commands marcandre.lureau
2016-08-09 12:11   ` Markus Armbruster
2016-08-09 12:20     ` Marc-André Lureau
2016-08-08 14:14 ` [Qemu-devel] [PATCH v3 11/15] qmp: update qmp_query_spice fallback marcandre.lureau
2016-08-09 12:38   ` Markus Armbruster
2016-08-08 14:14 ` [Qemu-devel] [PATCH v3 12/15] monitor: use qmp_dispatch() marcandre.lureau
2016-08-09 12:43   ` Markus Armbruster
2016-08-09 12:48     ` Daniel P. Berrange
2016-08-09 12:50     ` Marc-André Lureau
2016-08-09 14:29       ` Markus Armbruster
2016-08-09 14:41         ` Marc-André Lureau
2016-08-09 16:27           ` Markus Armbruster
2016-08-09 19:35             ` Marc-André Lureau
2016-08-10 10:17               ` Markus Armbruster
2016-08-10 15:28                 ` Marc-André Lureau [this message]
2016-08-08 14:14 ` [Qemu-devel] [PATCH v3 13/15] build-sys: remove qmp-commands-old.h marcandre.lureau
2016-08-08 14:14 ` [Qemu-devel] [PATCH v3 14/15] Drop qmp-commands.hx marcandre.lureau
2016-08-09 13:08   ` Markus Armbruster
2016-08-09 13:35     ` Marc-André Lureau
2016-08-17 15:01       ` Markus Armbruster
2016-08-08 14:14 ` [Qemu-devel] [PATCH v3 15/15] qmp-commands.txt: fix some styling marcandre.lureau
2016-08-08 14:55 ` [Qemu-devel] [PATCH v3 00/15] qapi: remove the 'middle' mode no-reply
2016-08-08 17:59   ` Marc-André Lureau
2016-08-09 14:50 ` 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=CAJ+F1CLozdBbvoEVGvkND3QzUcFd4DTK3nFS+Nd5ttoPjPv-jA@mail.gmail.com \
    --to=marcandre.lureau@gmail.com \
    --cc=armbru@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.