qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/2] qemu-option: add help fallback to print the


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH 1/2] qemu-option: add help fallback to print the list of options
Date: Thu, 16 Aug 2018 09:18:36 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Marc-André Lureau <address@hidden> writes:

> QDev options accept '?' or 'help' in the list of parameters, which is
> really handy to list the available options.
>
> Unfortunately, this isn't built in QemuOpts. qemu_opts_parse_noisily()
> seems to be the common path for command line options, so place a
> fallback to check for '?' and print help listing available options.

My immediate reaction was "how come this doesn't break -device help"?
It doesn't, because...

> This is very handy, for example with qemu "-spice ?".
>
> Signed-off-by: Marc-André Lureau <address@hidden>
> ---
>  util/qemu-option.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/util/qemu-option.c b/util/qemu-option.c
> index 01886efe90..8839ee6523 100644
> --- a/util/qemu-option.c
> +++ b/util/qemu-option.c
> @@ -889,7 +889,12 @@ QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, 
> const char *params,
>  
>      opts = opts_parse(list, params, permit_abbrev, false, &err);
>      if (err) {
> -        error_report_err(err);
> +        if (has_help_option(params)) {
> +            qemu_opts_print_help(list);
> +            error_free(err);
> +        } else {
> +            error_report_err(err);
> +        }
>      }
>      return opts;
>  }

... it only kicks in when parsing failed, and it doesn't for option
argument "help".

However, it *can* break for some option arguments:

    $ upstream-qemu -device e1000,id=@
    upstream-qemu: -device e1000,id=@: Parameter 'id' expects an identifier
    Identifiers consist of letters, digits, '-', '.', '_', starting with a 
letter.
    [Exit 1 ]
    $ upstream-qemu -device e1000,id=@,help
    [Exit 1 ]

In the second test case, the error message gets replaced by (empty)
help.

I love patches improving help, but I can't immediately see how to
salvage this one.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]