On 06/18/2013 03:31 AM, Dong Xu Wang wrote: > QMP command query-command-line-options shows details information of > parameters, since added def_value_str, also output it in the QMP > command. > > Signed-off-by: Dong Xu Wang <[email protected]> > --- > qapi-schema.json | 5 ++++- > qmp-commands.hx | 2 ++ > util/qemu-config.c | 4 ++++ > 3 files changed, 10 insertions(+), 1 deletion(-) > > diff --git a/qapi-schema.json b/qapi-schema.json > index a80ee40..a9202b0 100644 > --- a/qapi-schema.json > +++ b/qapi-schema.json > @@ -3541,12 +3541,15 @@ > # > # @help: #optional human readable text string, not suitable for parsing. > # > +# @def_value_str: #optional default value string for the parameter
Andreas called one aspect - please add '(since 1.6)'.
New QMP interfaces favor '-' over '_', and we also favor full words
rather than abbreviations. Furthermore, since this parameter is already
typed as a string, I think the _str suffix is redundant. I think it is
sufficient to just name it 'default', as in:
# @default: #optional string representation of the default used
# if the option is omitted
> +++ b/qmp-commands.hx
> @@ -2521,6 +2521,8 @@ Each array entry contains the following:
> or 'size')
> - "help": human readable description of the parameter
> (json-string, optional)
> + - "def_value_str": default value string for the parameter
> + (json-string, optional)
>
> Example:
Is it worth picking an example that actually shows a default value? But
I won't insist.
>
> diff --git a/util/qemu-config.c b/util/qemu-config.c
> index a59568d..538d743 100644
> --- a/util/qemu-config.c
> +++ b/util/qemu-config.c
> @@ -67,6 +67,10 @@ static CommandLineParameterInfoList
> *query_option_descs(const QemuOptDesc *desc)
> info->has_help = true;
> info->help = g_strdup(desc[i].help);
> }
> + if (desc[i].def_value_str) {
> + info->has_def_value_str = true;
> + info->def_value_str = g_strdup(desc[i].def_value_str);
Of course, if you follow my naming suggestion, this would be
desc[i].q_default (or whatever QAPI code generation munges it to),
rather than desc[i].default, thanks to being a C keyword :)
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
