On Thu, Nov 20, 2014 at 05:32:56PM -0500, Don Slutz wrote: [...] > @@ -1711,18 +1711,23 @@ static void pc_machine_set_max_ram_below_4g(Object > *obj, Visitor *v, > pcms->max_ram_below_4g = value; > } > > -static bool pc_machine_get_vmport(Object *obj, Error **errp) > +static void pc_machine_get_vmport(Object *obj, Visitor *v, void *opaque, > + const char *name, Error **errp) > { > PCMachineState *pcms = PC_MACHINE(obj); > + int vmport = pcms->vmport; > > - return pcms->vmport; > + visit_type_enum(v, &vmport, OnOffAuto_lookup, NULL, name, errp);
A visit_type_OnOffAuto() function is automatically generated by the QAPI schema, so you don't need to deal with the low level visit_type_enum() function. > } > > -static void pc_machine_set_vmport(Object *obj, bool value, Error **errp) > +static void pc_machine_set_vmport(Object *obj, Visitor *v, void *opaque, > + const char *name, Error **errp) > { > PCMachineState *pcms = PC_MACHINE(obj); > + int vmport; > > - pcms->vmport = value; > + visit_type_enum(v, &vmport, OnOffAuto_lookup, NULL, name, errp); > + pcms->vmport = vmport; 'vmport' may be undefined in case the visitor return an error, and in this case you shouldn't change pcms->vmport. This won't be a problem if you just call: visit_type_OnOffAuto(v, &pcms->vmport, name, errp); > } > > static void pc_machine_initfn(Object *obj) > @@ -1737,11 +1742,11 @@ static void pc_machine_initfn(Object *obj) > pc_machine_get_max_ram_below_4g, > pc_machine_set_max_ram_below_4g, > NULL, NULL, NULL); > - pcms->vmport = !xen_enabled(); > - object_property_add_bool(obj, PC_MACHINE_VMPORT, > - pc_machine_get_vmport, > - pc_machine_set_vmport, > - NULL); > + pcms->vmport = ON_OFF_AUTO_AUTO; > + object_property_add(obj, PC_MACHINE_VMPORT, "str", I believe "OnOffAuto" is a valid type name, if it is defined in the QAPI schema. > + pc_machine_get_vmport, > + pc_machine_set_vmport, > + NULL, NULL, NULL); > } > [...] -- Eduardo