On 03/07/2014 02:54 AM, Markus Armbruster wrote:
Eric Blake <eblake(a)redhat.com> writes:
> On 03/05/2014 07:36 PM, Amos Kong wrote:
>> vm_config_groups[] only contains part of the options which have
>> argument, and all options which have no argument aren't added
>> to vm_config_groups[]. Current query-command-line-options only
>> checks options from vm_config_groups[], so some options will
>> be lost.
>>
Example: -device takes unspecified parameters. -cdrom doesn't
take
parameters, it takes a file name. Yet, the command reports the same
for both: "parameters": [], "argument": true.
Looks like we need a tri-state: option takes no argument, QemuOpts
argument, or other argument.
I don't buy that. '-cdrom filename' could easily be re-written [in a
future qemu version] to use QemuOpts with an implied parameter name
(we've done that elsewhere, such as for '-machine'). In other words, I
think we could make it become shorthand for '-cdrom file=filename', at
which point the QemuOpts spelling is available and would now show up as
"parameters":[{"name":"file"...}]. Thus, in converting
-cdrom to
QemuOpts, we can still maintain command-line back-compat, while making
the query-command-line-options output more featureful. In other words,
_for now_ it takes unspecified parameters, and the fact that it is only
a single parameter in the form 'filename' rather than a more typical
parameter 'file=filename' is not a show-stopper.
So your idea of a tri-state (QemuOpts, no argument, or other argument)
doesn't add anything - any option that takes "other argument" could be
converted to take QemuOpts, and from the command line, we can't tell the
difference from whether something was implemented by QemuOpts, only by
whether we have introspection on what the argument consists of.
Meanwhile, it DOES point out that our use of implicit argument in
QemuOpts ought to be exposed to the introspection mechanism, for
introspection to be fully descriptive. That is, maybe we should modify
our introspection to add a new 'implied-name':
##
# @CommandLineParameterInfo:
#
...
# @implied-name: #optional, if present and true, the parameter can be
# specified as '-option value' instead of the preferred
# spelling of '-option name=value' (since 2.0)
# Since 1.5
{ 'type': 'CommandLineParameterInfo',
'data': { 'name': 'str',
'type': 'CommandLineParameterType',
'*help': 'str', '*implied-name': 'bool' } }
parameters is [] unless it's a QemuOpts argument. Then it lists the
recognized parameters.
This part is still true. When parameters[] is non-empty, it is a
QemuOpts and we know all recognized parameters (well, more precisely,
the subset of QemuOpts that were explicitly called out - given your
point 2 about the mess of -drive); when it is empty, then all we know is
whether the argument is a boolean or takes unspecified arguments (where
the conversion of those unknown arguments to QemuOpts will be what
finally lets us introspect the format of those unknown arguments).
2. Our dear friend -drive is more complicated than you might think
We special-case it to report the union of drive_config_groups[],
which contains qemu_legacy_drive_opts, qemu_common_drive_opts and
qemu_drive_opts. The latter accepts unspecified parameters.
I believe qemu_drive_opts is actually not used by the (complex!) code
parsing the argument of -drive.
Nevertheless, said code accepts more than just qemu_legacy_drive_opts
and qemu_common_drive_opts, namely driver-specific parameters.
Until we define those properly in a schema, I guess the best we can
do is add one more case: option takes QemuOpts argument, but
parameters is not exhaustive.
We already know 'query-command-line-options' is not a full introspection
yet. So far, libvirt has managed to get by on partial information (in
fact, the whole hack for special-casing -drive to merge multiple lists
together was precisely to avoid a regression with at least providing the
partial information that libvirt was actually using). Documenting that
QemuOpts information may be incomplete may be nice, but shouldn't hold
up the initial purpose of this patch which is to document non-QemuOpts
options. And knowing that an option takes unspecified arguments is
still better than not knowing about the option at all.
>> This patch also fixes options to match their actual command-line
>> spelling rather than an alternate name associated with the
>> option table in use by the command.
>
> Should we independently patch hw/acpi/core.c to rename qemu_acpi_opts
> from "acpi" to "acpitable" to match the command line option?
Same for
> vl.c and qemu_boot_opts from "boot-opts" to "boot"? Same for
vl.c and
> qemu_smp_opts from "smp-opts" to "smp"? Those were the obvious
> mismatches I found where the command line was spelled differently than
> the vm_config_groups entry.
Without such a change, the command lies, because it fails to connect the
option to its QemuOptsList. Example:
{"parameters": [], "option": "acpitable",
"argument": true},
However, the vm_config_groups[].name values are ABI: they're the section
names recognized by -readconfig and produced by -writeconfig. Thus,
this is an incompatible change. It's also an improvement of sorts:
things become more consistent.
Ouch. I did not realize they were ABI. 'query-command-line-options'
should expose the command line spelling, but maybe that argues that we
need to enhance our QAPI introspection to make it easier to document the
special cases:
##
# @CommandLineOptionInfo:
...
# @config-name: #optional if present, the command line spelling differs
# from the name used by -readconfig (since 2.0)
# Since 1.5
##
{ 'type': 'CommandLineOptionInfo',
'data': { 'option': 'str',
'*config-name':'str',
'parameters': ['CommandLineParameterInfo'] } }
and where we would expose:
{"parameters": [], "option": "acpitable",
"config-name": "acpi",
"argument": true},
or even combining my above suggestions:
{"option":"M", "parameters":[],
"config-name":"machine",
"argument": true},
{"option":"machine", "parameters":[
{"name": "firmware", "help": "firmware image",
"type": "string"},
{"name": "type", "implied-name": true, "help":
"emulated machine",
"type": "string"}, ...]},
to make it a bit more obvious that '-M str' and '-machine str' are both
shorthands for the preferred '-machine type=str', and that the same
effect is reached via a config file that has a [machine] section.
We could avoid it with a suitable mapping from option name to option
group name. Simplest way to do that is store only the exceptions from
the rule "the names are the same".
Yes. We've identified at least 3 exceptions now (acpitable, boot, smp),
and exposing those exceptions in the introspection is a good idea, to
make us quit adding new ones.
Do we care?
> This is a bug fix patch, so let's shoot to get it into 2.0.
Yes.
How much work are we able to do before hard freeze? How much work are we
willing to accept as bug fix after hard freeze?
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org