qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Marc-André Lureau" <mlureau@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: marcandre lureau <marcandre.lureau@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v4 06/17] monitor: unregister conditional commands
Date: Tue, 16 Aug 2016 10:34:56 -0400 (EDT)	[thread overview]
Message-ID: <1604394942.66237.1471358096460.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <8737m44wod.fsf@dusky.pond.sub.org>

Hi

----- Original Message -----
> marcandre.lureau@redhat.com writes:
> 
> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> >
> > The current monitor dispatch codes doesn't know commands that have been
> > filtered out during qmp-commands.hx preprocessing. query-commands
> > doesn't list them either. However, qapi generator doesn't filter them
> > out, and they are listed in the command list.
> >
> > For now, disable the commands that aren't avaible to avoid introducing a
> > regression there when switching to qmp_dispatch() or listing commands
> > from the generated qapi code.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> >  monitor.c | 23 +++++++++++++++++++++++
> >  1 file changed, 23 insertions(+)
> >
> > diff --git a/monitor.c b/monitor.c
> > index b7ae552..ef946ad 100644
> > --- a/monitor.c
> > +++ b/monitor.c
> > @@ -1008,6 +1008,26 @@ static void qmp_query_qmp_schema(QDict *qdict,
> > QObject **ret_data,
> >      *ret_data = qobject_from_json(qmp_schema_json);
> >  }
> >  
> > +/*
> > + * Those commands are registered unconditionnally by generated
> > + * qmp files. FIXME: Educate the QAPI schema on #ifdef commands.
> > + */
> > +static void qmp_disable_marshal(void)
> > +{
> > +#ifndef CONFIG_SPICE
> > +    qmp_disable_command("query-spice");
> > +#endif
> > +#ifndef TARGET_I386
> > +    qmp_disable_command("rtc-reset-reinjection");
> > +#endif
> > +#ifndef TARGET_S390X
> > +    qmp_disable_command("dump-skeys");
> > +#endif
> > +#ifndef TARGET_ARM
> > +    qmp_disable_command("query-gic-capabilities");
> > +#endif
> > +}
> > +
> >  static void qmp_init_marshal(void)
> >  {
> >      qmp_register_command("query-qmp-schema", qmp_query_qmp_schema,
> > @@ -1016,6 +1036,9 @@ static void qmp_init_marshal(void)
> >                           QCO_NO_OPTIONS);
> >      qmp_register_command("netdev_add", qmp_netdev_add,
> >                           QCO_NO_OPTIONS);
> > +
> > +    /* call it after the rest of qapi_init() */
> > +    register_module_init(qmp_disable_marshal, MODULE_INIT_QAPI);
> >  }
> >  
> >  qapi_init(qmp_init_marshal);
> 
> Let's see whether I understand this patch...
> 
> qmp_disable_command() sets a flag that can be tested directly or with
> qmp_command_is_enabled().  do_qmp_dispatch() tests it, and fails the
> command with an "The command FOO has been disabled for this instance"
> error.  It's called from qmp_dispatch(), which we're not yet using for
> QMP at this point of the series.
> 
> QGA uses this to implement its "freeze whitelist", i.e. to disable all
> commands that aren't known to be safe while filesystems are frozen.
> 
> qmp_disable_command() does nothing when the command doesn't exist, which
> I think is the case at this point of the series.
> 
> So this patch does exactly nothing by itself.  When you later flip
> dispatch to use qmp_dispatch(), it becomes active, and the error for
> these commands changes from
> 
>     {"error": {"class": "CommandNotFound", "desc": "The command FOO has not
>     been found"}}
> 
> to
> 
>     {"error": {"class": "GenericError", "desc": "The command FOO has been
>     disabled for this instance"}}
> 
> which is fine with me.
> 
> Is this basically correct?

I think it's correct, I haven't played much with this as I focused on the conditional build instead, which is actually not so difficult, see:

https://github.com/elmarco/qemu/commit/d0496fdabe49149e76d765d96feada0d5269c211 (qapi.py change)

https://github.com/elmarco/qemu/commit/ee3c17b7bd5ffaa0b5be258a2cfb46c6c577f653 (per target build)

https://github.com/elmarco/qemu/commit/91a692b3428878f8c26933c8a113853fb2a19970 (per target conditonal in schema)

Do you think I should introduce that conditional build earlier in this series instead of that disable workaround?

  reply	other threads:[~2016-08-16 14:35 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 [this message]
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
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=1604394942.66237.1471358096460.JavaMail.zimbra@redhat.com \
    --to=mlureau@redhat.com \
    --cc=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).