On Thu, Mar 07, 2019 at 10:48:59AM +0100, Igor Mammedov wrote: [...] > > +static void machine_set_nvdimm_persistence(Object *obj, const char *value, > > + Error **errp) > > +{ > > + MachineState *ms = MACHINE(obj); > > + AcpiNVDIMMState *nvdimms_state = &ms->nvdimms_state; > > + > > + if (strcmp(value, "cpu") == 0) > > + nvdimms_state->persistence = 3; > we probably should use QAPI enum magic to handle description to value > conversion > but I don't know how to (CCed Markus).
QEMU is not very consistent in this. I have found at least 3 different methods for registering enum properties: 1) qdev PropertyInfo using set_enum/get_enum. Examples: DEFINE_PROP_ON_OFF_AUTO, DEFINE_PROP_LOSTTICKPOLICY. 2) object_property_add() + visit_type_...(). Examples: machine_set_kernel_irqchip(), pc_machine_set_vmport(), pc_machine_set_smm(). 3) object_property_add_add_enum() and object_class_property_add_enum(). Examples: qauthz_list_prop_set_policy(), host_memory_backend_set_policy(), qcrypto_secret_prop_set_format(), netfilter_set_direction(). > But since it's just moving existing code, it do not insist and it could be > done on top later on. Agreed, but I think we should at least add a TODO comment indicating the code is not a good example to be followed. -- Eduardo