Paolo Bonzini <pbonzini(a)redhat.com> writes:
Il 26/02/2013 20:35, Anthony Liguori ha scritto:
>>> >>
>>> >> See also discussion on multi-valued keys in command line option
>>> >> arguments and config files in v1 thread. Hopefully we can reach a
>>> >> conclusion soon, and then we'll see whether this patch is what
we want.
>> >
>> > Yeah, let's drop this patch by now. I am starting to be convinced that
>> > "cpus=A,cpus=B,cpus=C" is the best approach. It is not pretty, but
at
>> > least it uses generic parser code instead of yet another ad-hoc
>> > parser.
> No, we cannot rely on this behavior. We had to do it to support
> backwards compat with netdev but it should not be used anywhere else.
We chose a config format (git's) because it was a good match for
QemuOpts, and multiple-valued operations are well supported by that
config format; see git-config(1). There is no reason to consider it a
backwards-compatibility hack.
There's such thing as list support in QemuOpts. The only way
QemuOptsVisitor was able to implement it was to expose QemuOpts publicly
via options_int.h and rely on a implementation detail.
There are fixed types supported by QemuOpts. It just so happens that
whenever qemu_opt_set() is called, instead of replacing the last
instance, the value is either prepended or appended in order to
implement a replace or set-if-unset behavior.
All values are treated this way. So the above "list" would only be:
{
.name = "cpus",
.type = QEMU_OPT_STRING
}
Which is indistinguishable from a straight string property. This means
it's impossible to introspect because the type is context-sensitive.
What's more, there is no API outside of QemuOptsVisitor that can
actually work with "lists" of QemuOpts values.
If we want to have list syntax, we need to introduce first class support
for it. Here's a simple example of how to do this. Obviously we would
want to introduce some better error checking so we can catch if someone
tries to access a list with a non-list accessor. We also would need
list accessor functions.
But it's really not hard at all.
(Only compile tested)
Regards,
Anthony Liguori
Paolo