diff options
author | Ross Zwisler <ross.zwisler@linux.intel.com> | 2018-06-07 16:31:11 -0600 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2018-06-11 22:19:57 +0300 |
commit | 11c39b5cd966ddc067a1ca0c5392ec9b666c45b7 (patch) | |
tree | aff666dadd919b34c5dac5b69f73b956e40050b3 /hw/i386/pc.c | |
parent | 0f3ef1c0628d15e27b1cc4bf9fbd0e5532c59c76 (diff) | |
download | qemu-11c39b5cd966ddc067a1ca0c5392ec9b666c45b7.zip qemu-11c39b5cd966ddc067a1ca0c5392ec9b666c45b7.tar.gz qemu-11c39b5cd966ddc067a1ca0c5392ec9b666c45b7.tar.bz2 |
nvdimm: make persistence option symbolic
Replace the "nvdimm-cap" option which took numeric arguments such as "2"
with a more user friendly "nvdimm-persistence" option which takes symbolic
arguments "cpu" or "mem-ctrl".
Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Suggested-by: Michael S. Tsirkin <mst@redhat.com>
Suggested-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/i386/pc.c')
-rw-r--r-- | hw/i386/pc.c | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/hw/i386/pc.c b/hw/i386/pc.c index f3befe6..5bba9dc 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -2181,31 +2181,30 @@ static void pc_machine_set_nvdimm(Object *obj, bool value, Error **errp) pcms->acpi_nvdimm_state.is_enabled = value; } -static void pc_machine_get_nvdimm_capabilities(Object *obj, Visitor *v, - const char *name, void *opaque, - Error **errp) +static char *pc_machine_get_nvdimm_persistence(Object *obj, Error **errp) { PCMachineState *pcms = PC_MACHINE(obj); - uint32_t value = pcms->acpi_nvdimm_state.capabilities; - visit_type_uint32(v, name, &value, errp); + return g_strdup(pcms->acpi_nvdimm_state.persistence_string); } -static void pc_machine_set_nvdimm_capabilities(Object *obj, Visitor *v, - const char *name, void *opaque, +static void pc_machine_set_nvdimm_persistence(Object *obj, const char *value, Error **errp) { PCMachineState *pcms = PC_MACHINE(obj); - Error *error = NULL; - uint32_t value; - - visit_type_uint32(v, name, &value, &error); - if (error) { - error_propagate(errp, error); - return; + AcpiNVDIMMState *nvdimm_state = &pcms->acpi_nvdimm_state; + + if (strcmp(value, "cpu") == 0) + nvdimm_state->persistence = 3; + else if (strcmp(value, "mem-ctrl") == 0) + nvdimm_state->persistence = 2; + else { + error_report("-machine nvdimm-persistence=%s: unsupported option", value); + exit(EXIT_FAILURE); } - pcms->acpi_nvdimm_state.capabilities = value; + g_free(nvdimm_state->persistence_string); + nvdimm_state->persistence_string = g_strdup(value); } static bool pc_machine_get_smbus(Object *obj, Error **errp) @@ -2421,9 +2420,9 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) object_class_property_add_bool(oc, PC_MACHINE_NVDIMM, pc_machine_get_nvdimm, pc_machine_set_nvdimm, &error_abort); - object_class_property_add(oc, PC_MACHINE_NVDIMM_CAP, "uint32", - pc_machine_get_nvdimm_capabilities, - pc_machine_set_nvdimm_capabilities, NULL, NULL, &error_abort); + object_class_property_add_str(oc, PC_MACHINE_NVDIMM_PERSIST, + pc_machine_get_nvdimm_persistence, + pc_machine_set_nvdimm_persistence, &error_abort); object_class_property_add_bool(oc, PC_MACHINE_SMBUS, pc_machine_get_smbus, pc_machine_set_smbus, &error_abort); |