qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: imammedo@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v3 2/7] hmp: Allow help on preconfig commands
Date: Mon, 11 Jun 2018 19:49:43 +0100	[thread overview]
Message-ID: <20180611184943.GT2661@work-vm> (raw)
In-Reply-To: <874li9h36p.fsf@dusky.pond.sub.org>

* Markus Armbruster (armbru@redhat.com) wrote:
> "Dr. David Alan Gilbert" <dgilbert@redhat.com> writes:
> 
> > * Markus Armbruster (armbru@redhat.com) wrote:
> >> "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> writes:
> >> 
> >> > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> >> >
> >> > Allow the 'help' command in preconfig state but
> >> > make it only list the preconfig commands.
> >> >
> >> > Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> >> > Reviewed-by: Peter Xu <peterx@redhat.com>
> >> > Reviewed-by: Igor Mammedov <imammedo@redhat.com>
> >> > ---
> >> >  hmp-commands.hx | 1 +
> >> >  monitor.c       | 8 +++++++-
> >> >  2 files changed, 8 insertions(+), 1 deletion(-)
> >> >
> >> > diff --git a/hmp-commands.hx b/hmp-commands.hx
> >> > index 0734fea931..8bf590ae4b 100644
> >> > --- a/hmp-commands.hx
> >> > +++ b/hmp-commands.hx
> >> > @@ -15,6 +15,7 @@ ETEXI
> >> >          .params     = "[cmd]",
> >> >          .help       = "show the help",
> >> >          .cmd        = do_help_cmd,
> >> > +        .flags      = "p",
> >> >      },
> >> >  
> >> >  STEXI
> >> > diff --git a/monitor.c b/monitor.c
> >> > index f4a16e6a03..31c8f5dc88 100644
> >> > --- a/monitor.c
> >> > +++ b/monitor.c
> >> > @@ -957,6 +957,10 @@ static void help_cmd_dump_one(Monitor *mon,
> >> >  {
> >> >      int i;
> >> >  
> >> > +    if (runstate_check(RUN_STATE_PRECONFIG) && !cmd_can_preconfig(cmd)) {
> >> > +        return;
> >> > +    }
> >> > +
> >> >      for (i = 0; i < prefix_args_nb; i++) {
> >> >          monitor_printf(mon, "%s ", prefix_args[i]);
> >> >      }
> >> > @@ -979,7 +983,9 @@ static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds,
> >> >  
> >> >      /* Find one entry to dump */
> >> >      for (cmd = cmds; cmd->name != NULL; cmd++) {
> >> > -        if (compare_cmd(args[arg_index], cmd->name)) {
> >> > +        if (compare_cmd(args[arg_index], cmd->name) &&
> >> > +            ((!runstate_check(RUN_STATE_PRECONFIG) ||
> >> > +                cmd_can_preconfig(cmd)))) {
> >> 
> >> Why do we need this check in addition to the one in help_cmd_dump_one()?
> >
> > To gate entire subtables (we've only currently got 'info' and that's enabled,
> > anyway, so it never actually triggers).
> 
> Something's bothering me around here, but I can't put a finger on it...
> let me think aloud.
> 
> There's an asymmetry between command execution and help.  The former has
> just one check, in monitor_parse_command().  If the command has a
> sub-table, and there are arguments, monitor_parse_command() recurses
> into the sub-table.  Thus, if the command is unavailable, the
> sub-commands are unavailable as well, regardless of their "p" flags.
> 
> Help's recursion is different.  It's limited to two levels, unlike
> execution.  help_cmd_dump_one()'s check applies to the last level.
> help_cmd_dump()'s check applies to the first level.  If there's just one
> level, we check twice.  Perhaps less than elegant, but harmless and
> simple.
> 
> You can't make a sub-command available without also making the command
> available.  Makes sense, I guess.  If you try, your "p" flags on the
> sub-commands are silently ignored.  That's a bit ugly, but if it doesn't
> bother you, I can pretend I didn't see it ;)

Yes I'm OK with that; you've got to enable all the way down to the
command that youw ant to enable.

I think the difference between execution and help comes from the
way you can do 'help' on it's own to list everything, and help
on a subtable (help info) and help on a command (help info uuid);
I think that's why the recursion gets a bit hairier.

Dave

> > Dave
> >
> >> >              if (cmd->sub_table) {
> >> >                  /* continue with next arg */
> >> >                  help_cmd_dump(mon, cmd->sub_table,
> > --
> > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

  reply	other threads:[~2018-06-11 18:49 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-08 13:08 [Qemu-devel] [PATCH v3 0/7] Reenable hmp for preconfig mode Dr. David Alan Gilbert (git)
2018-06-08 13:08 ` [Qemu-devel] [PATCH v3 1/7] hmp: Add flag for preconfig commands Dr. David Alan Gilbert (git)
2018-06-11  8:49   ` Markus Armbruster
2018-06-11 17:37     ` Dr. David Alan Gilbert
2018-06-08 13:08 ` [Qemu-devel] [PATCH v3 2/7] hmp: Allow help on " Dr. David Alan Gilbert (git)
2018-06-11  9:00   ` Markus Armbruster
2018-06-11 10:27     ` Dr. David Alan Gilbert
2018-06-11 13:18       ` Markus Armbruster
2018-06-11 18:49         ` Dr. David Alan Gilbert [this message]
2018-06-12  7:03           ` Markus Armbruster
2018-06-08 13:08 ` [Qemu-devel] [PATCH v3 3/7] hmp: Restrict auto-complete in preconfig Dr. David Alan Gilbert (git)
2018-06-11  9:02   ` Markus Armbruster
2018-06-11 17:38     ` Dr. David Alan Gilbert
2018-06-08 13:08 ` [Qemu-devel] [PATCH v3 4/7] qmp: enable query-[chardev|version|name|uuid|iothreads|memdev] commands in preconfig state Dr. David Alan Gilbert (git)
2018-06-11 11:28   ` Markus Armbruster
2018-06-11 17:43     ` Dr. David Alan Gilbert
2018-06-12  7:05       ` Markus Armbruster
2018-06-08 13:08 ` [Qemu-devel] [PATCH v3 5/7] hmp: Add info commands for preconfig Dr. David Alan Gilbert (git)
2018-06-11 12:01   ` Markus Armbruster
2018-06-11 17:49     ` Dr. David Alan Gilbert
2018-06-12  5:37       ` Gerd Hoffmann
2018-06-12 12:00         ` Markus Armbruster
2018-06-12 12:52           ` Dr. David Alan Gilbert
2018-06-15 16:10             ` [Qemu-devel] Abandon our QMP first policy? (was: [PATCH v3 5/7] hmp: Add info commands for preconfig) Markus Armbruster
2018-06-15 16:32               ` Dr. David Alan Gilbert
2018-06-15 18:44               ` Eduardo Habkost
2018-06-18  6:36                 ` Gerd Hoffmann
2018-06-20 14:48                   ` Dr. David Alan Gilbert
2018-06-12  6:43       ` [Qemu-devel] [PATCH v3 5/7] hmp: Add info commands for preconfig Markus Armbruster
2018-06-12  8:49         ` Dr. David Alan Gilbert
2018-06-13 13:47           ` Eduardo Habkost
2018-06-13 13:53             ` Daniel P. Berrangé
2018-06-13 16:59               ` Eduardo Habkost
2018-06-11 18:40     ` Eduardo Habkost
2018-06-11 21:33       ` Igor Mammedov
2018-06-12  7:00         ` Markus Armbruster
2018-06-13 13:44           ` Eduardo Habkost
2018-06-12  7:57         ` Daniel P. Berrangé
2018-06-08 13:08 ` [Qemu-devel] [PATCH v3 6/7] hmp: add exit_preconfig Dr. David Alan Gilbert (git)
2018-06-11 12:04   ` Markus Armbruster
2018-06-11 18:29     ` Dr. David Alan Gilbert
2018-06-08 13:08 ` [Qemu-devel] [PATCH v3 7/7] hmp: Allow HMP in preconfig state again Dr. David Alan Gilbert (git)
2018-06-11 12:06 ` [Qemu-devel] [PATCH v3 0/7] Reenable hmp for preconfig mode Markus Armbruster
2018-06-11 12:09   ` Dr. David Alan Gilbert
2018-06-11 12:44     ` Markus Armbruster
2018-06-14 13:17       ` Igor Mammedov

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=20180611184943.GT2661@work-vm \
    --to=dgilbert@redhat.com \
    --cc=armbru@redhat.com \
    --cc=imammedo@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).