@@ -96,15 +96,46 @@ static void nvdimm_set_uuid(Object *obj, Visitor *v, const char *name,
g_free(value);
}
+static void nvdimm_get_device_node(Object *obj, Visitor *v,
+ const char *name, void *opaque,
+ Error **errp)
+{
+ NVDIMMDevice *nvdimm = NVDIMM(obj);
+ int64_t value = nvdimm->device_node;
+
+ visit_type_int(v, name, &value, errp);
+}
+
+static void nvdimm_set_device_node(Object *obj, Visitor *v,
+ const char *name, void *opaque,
+ Error **errp)
+{
+ NVDIMMDevice *nvdimm = NVDIMM(obj);
+ int64_t value;
+
+ if (!visit_type_int(v, name, &value, errp)) {
+ return;
+ }
+
+ nvdimm->device_node = value;
+}
static void nvdimm_init(Object *obj)
{
+ NVDIMMDevice *nvdimm = NVDIMM(obj);
+
object_property_add(obj, NVDIMM_LABEL_SIZE_PROP, "int",
nvdimm_get_label_size, nvdimm_set_label_size, NULL,
NULL);
object_property_add(obj, NVDIMM_UUID_PROP, "QemuUUID", nvdimm_get_uuid,
nvdimm_set_uuid, NULL, NULL);
+
+ nvdimm->device_node = -1;
+ object_property_add(obj, NVDIMM_DEVICE_NODE, "int",
+ nvdimm_get_device_node,
+ nvdimm_set_device_node,
+ NULL, NULL);
}
static void nvdimm_finalize(Object *obj)
@@ -49,6 +49,7 @@
OBJECT_DECLARE_TYPE(NVDIMMDevice, NVDIMMClass, NVDIMM)
#define NVDIMM_LABEL_SIZE_PROP "label-size"
+#define NVDIMM_DEVICE_NODE "device-node"
#define NVDIMM_UUID_PROP "uuid"
#define NVDIMM_UNARMED_PROP "unarmed"
@@ -89,6 +90,17 @@ struct NVDIMMDevice {
* The PPC64 - spapr requires each nvdimm device have a uuid.
*/
QemuUUID uuid;
+
+ /*
+ * The spapr-nvdimm (PPC64 NVDIMM) driver supports two modes of
+ * operation: regular memory and persistent memory. When using the
+ * device as regular memory, the NUMA nodeid that comes from
+ * PC_DIMM_NODEPROP is to be used. When used as persistent memory,
+ * the guest should consider the 'device-node' instead since it
+ * indicates the locality of the device to an established NUMA
+ * node, which is more relevant to this type of usage.
+ */
+ int device_node;
};
struct NVDIMMClass {
The spapr-nvdimm driver is able to operate in two ways. The first one is as a regular memory in which the NUMA node of the parent pc-dimm class is used. The second mode, as persistent memory, allows for a different NUMA node to be used based on the locality of the device. At this moment we don't have a way to express this second NUMA node for the persistent memory mode. This patch introduces a new 'device-node' property that will be used by the PPC64 spapr-nvdimm driver to set a second NUMA node for the nvdimm. CC: Shivaprasad G Bhat <sbhat@linux.ibm.com> CC: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> --- hw/mem/nvdimm.c | 31 +++++++++++++++++++++++++++++++ include/hw/mem/nvdimm.h | 12 ++++++++++++ 2 files changed, 43 insertions(+)