On 28/03/2017 13:26, Alexander Graf wrote: >> You can define an enum type in qapi-schema.json, and use >> visit_type_<YourEnumType>(). You can grep for >> visit_type_OnOffAuto to find examples. >> >> (But I suggest naming the enum something like >> "X86CPUFeatureSetting" instead of "OnOffForce", because we will >> probably add other enum values in the future). >> >> However: we need to find a way to do this and not break >> compatibility with "feat=yes|true|no|false", that's supported by >> StringInputVisitor (which is used by object_property_parse()). >> Maybe fallback to visit_type_bool() in case >> visit_type_<YourEnumType>() fails? > > Putting it into a special enum sounds much more fragile than the current > solution to me. We need to bool fallback either way, so I fail to see > any benefit from having the enum.
Using an on/off/force enum sounds like the right thing to do. However, I would open code the getters and setters completely (using visit_type_str) instead of using visit_type_FooEnum+visit_type_bool. Then you can easily map yes/true to on and no/false to off. Paolo