nvdimm: add uuid property to nvdimm
For ppc64, PAPR requires the nvdimm device to have UUID property set in the device tree. Add an option to get it from the user. Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Message-Id: <158131056931.2897.14057087440721445976.stgit@lep8c.aus.stglabs.ibm.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
3f350f6bb3
commit
6c5627bb24
@ -69,11 +69,51 @@ out:
|
||||
error_propagate(errp, local_err);
|
||||
}
|
||||
|
||||
static void nvdimm_get_uuid(Object *obj, Visitor *v, const char *name,
|
||||
void *opaque, Error **errp)
|
||||
{
|
||||
NVDIMMDevice *nvdimm = NVDIMM(obj);
|
||||
char *value = NULL;
|
||||
|
||||
value = qemu_uuid_unparse_strdup(&nvdimm->uuid);
|
||||
|
||||
visit_type_str(v, name, &value, errp);
|
||||
g_free(value);
|
||||
}
|
||||
|
||||
|
||||
static void nvdimm_set_uuid(Object *obj, Visitor *v, const char *name,
|
||||
void *opaque, Error **errp)
|
||||
{
|
||||
NVDIMMDevice *nvdimm = NVDIMM(obj);
|
||||
Error *local_err = NULL;
|
||||
char *value;
|
||||
|
||||
visit_type_str(v, name, &value, &local_err);
|
||||
if (local_err) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (qemu_uuid_parse(value, &nvdimm->uuid) != 0) {
|
||||
error_setg(errp, "Property '%s.%s' has invalid value",
|
||||
object_get_typename(obj), name);
|
||||
goto out;
|
||||
}
|
||||
g_free(value);
|
||||
|
||||
out:
|
||||
error_propagate(errp, local_err);
|
||||
}
|
||||
|
||||
|
||||
static void nvdimm_init(Object *obj)
|
||||
{
|
||||
object_property_add(obj, NVDIMM_LABEL_SIZE_PROP, "int",
|
||||
nvdimm_get_label_size, nvdimm_set_label_size, NULL,
|
||||
NULL, NULL);
|
||||
|
||||
object_property_add(obj, NVDIMM_UUID_PROP, "QemuUUID", nvdimm_get_uuid,
|
||||
nvdimm_set_uuid, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
static void nvdimm_finalize(Object *obj)
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include "hw/mem/pc-dimm.h"
|
||||
#include "hw/acpi/bios-linker-loader.h"
|
||||
#include "qemu/uuid.h"
|
||||
|
||||
#define NVDIMM_DEBUG 0
|
||||
#define nvdimm_debug(fmt, ...) \
|
||||
@ -49,6 +50,7 @@
|
||||
TYPE_NVDIMM)
|
||||
|
||||
#define NVDIMM_LABEL_SIZE_PROP "label-size"
|
||||
#define NVDIMM_UUID_PROP "uuid"
|
||||
#define NVDIMM_UNARMED_PROP "unarmed"
|
||||
|
||||
struct NVDIMMDevice {
|
||||
@ -83,6 +85,11 @@ struct NVDIMMDevice {
|
||||
* the guest write persistence.
|
||||
*/
|
||||
bool unarmed;
|
||||
|
||||
/*
|
||||
* The PPC64 - spapr requires each nvdimm device have a uuid.
|
||||
*/
|
||||
QemuUUID uuid;
|
||||
};
|
||||
typedef struct NVDIMMDevice NVDIMMDevice;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user