[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2] machine: Move acpi_nvdimm_state into struct
From: |
Eduardo Habkost |
Subject: |
Re: [Qemu-devel] [PATCH v2] machine: Move acpi_nvdimm_state into struct MachineState |
Date: |
Thu, 7 Mar 2019 09:44:19 -0300 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
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
Re: [Qemu-devel] [PATCH v2] machine: Move acpi_nvdimm_state into struct MachineState, Eduardo Habkost, 2019/03/07