Paolo Bonzini <pbonz...@redhat.com> writes: > On 03/11/20 17:25, Daniel P. Berrangé wrote: >>> OptsVisitor, StringInputVisitor and the keyval visitor have >>> three different ideas of how a human could write the value of >>> a boolean option. Pay homage to the backwards-compatibility >>> gods and make the new common helper accept all four sets (on/off, >>> true/false, y/n and yes/no), and case-insensitive at that. >>> >>> Since OptsVisitor is supposed to match qemu-options, adjust >>> it as well. >> FWIW, libvirt does not appear to use true/false or y/n, nor >> ever use uppercase / mixed case. >> >> IOW this level of back compat may well be overkill. >> >> I'd particular suggest deprecating case-insensitivity, as >> Yes, YES, yEs feel unlikely to be important or widely used. > > True; at least it's type-safe code unlike the short-form boolean option. > It only hurts in the odd case of a boolean option becoming on/off/auto > or on/off/split.
Another argument for deprecating values other than "on" and "off". > I didn't want to introduce deprecation at this point, because Not wanting to rush deprecation this close to the release is a valid point. So is not wanting to rush in additional sugar :) > consistency is better anyway even if we plan to later deprecate > something. For example, since there is a common parser now, introducing > deprecation would be much easier. It also lets us switch parsers even > during the deprecation period (which is how I got into this mess). On the other hand, we'll have more to deprecate. Status quo: on/off yes/no y/n true/false case-sensitive? qemu_opt_get_bool() X no keyval visitor X no string visitor X X X yes opts visitor X X X no For once, there is no way to blame QemuOpts ;) qemu_opt_get_bool() is everywhere in CLI and HMP. The keyval visitor is used for QAPIfied human-friendly interfaces: block stuff, -display, -audio. The string input visitor is used for -object, -global, HMP object_add, qom-set, migrate_set_parameter. The opts visitor is used for -mon and its sugared forms (new in 5.2!), -net, -netdev, -acpitable, -numa. I'd very much prefer to deprecate the odd ones in string and opts visitor, and not copy them elsewhere. We can still factor out a common parsing function if we like: pass a flag that makes it recognize deprecated forms. A single flag should suffice; it lets odd ones spread from string to opts visitor and vice versa, which I find tolerable.