[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 06/16] pc: implement NVDIMM device abstract
From: |
Xiao Guangrong |
Subject: |
[Qemu-devel] [PATCH 06/16] pc: implement NVDIMM device abstract |
Date: |
Wed, 1 Jul 2015 22:50:22 +0800 |
Introduce "pc-nvdimm" device and it only has one parameter, @file, which
is the backed memory file for NVDIMM device
We can use "-device pc-nvdimm,file=/dev/pmem" in the Qemu command to
create NVDIMM device for the guest
Signed-off-by: Xiao Guangrong <address@hidden>
---
hw/mem/Makefile.objs | 1 +
hw/mem/pc-nvdimm.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++
include/hw/mem/pc-nvdimm.h | 32 ++++++++++++++++++
3 files changed, 116 insertions(+)
create mode 100644 hw/mem/pc-nvdimm.c
create mode 100644 include/hw/mem/pc-nvdimm.h
diff --git a/hw/mem/Makefile.objs b/hw/mem/Makefile.objs
index b000fb4..9a7f5a9 100644
--- a/hw/mem/Makefile.objs
+++ b/hw/mem/Makefile.objs
@@ -1 +1,2 @@
common-obj-$(CONFIG_MEM_HOTPLUG) += pc-dimm.o
+common-obj-$(CONFIG_LINUX) += pc-nvdimm.o
diff --git a/hw/mem/pc-nvdimm.c b/hw/mem/pc-nvdimm.c
new file mode 100644
index 0000000..0209ea9
--- /dev/null
+++ b/hw/mem/pc-nvdimm.c
@@ -0,0 +1,83 @@
+/*
+ * NVDIMM (A Non-Volatile Dual In-line Memory Module) Virtualization Implement
+ *
+ * Copyright(C) 2015 Intel Corporation.
+ *
+ * Author:
+ * Xiao Guangrong <address@hidden>
+ *
+ * Currently, it only supports PMEM Virtualization.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>
+ */
+
+#include "hw/mem/pc-nvdimm.h"
+
+static char *get_file(Object *obj, Error **errp)
+{
+ PCNVDIMMDevice *nvdimm = PC_NVDIMM(obj);
+
+ return g_strdup(nvdimm->file);
+}
+
+static void set_file(Object *obj, const char *str, Error **errp)
+{
+ PCNVDIMMDevice *nvdimm = PC_NVDIMM(obj);
+
+ if (nvdimm->file) {
+ g_free(nvdimm->file);
+ }
+
+ nvdimm->file = g_strdup(str);
+}
+
+static void pc_nvdimm_init(Object *obj)
+{
+ object_property_add_str(obj, "file", get_file, set_file, NULL);
+}
+
+static void pc_nvdimm_realize(DeviceState *dev, Error **errp)
+{
+ PCNVDIMMDevice *nvdimm = PC_NVDIMM(dev);
+
+ if (!nvdimm->file) {
+ error_setg(errp, "file property is not set");
+ }
+}
+
+static void pc_nvdimm_class_init(ObjectClass *oc, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(oc);
+
+ /* nvdimm hotplug has not supported yet. */
+ dc->hotpluggable = false;
+
+ dc->realize = pc_nvdimm_realize;
+ dc->desc = "NVDIMM memory module";
+}
+
+static TypeInfo pc_nvdimm_info = {
+ .name = TYPE_PC_NVDIMM,
+ .parent = TYPE_DEVICE,
+ .instance_size = sizeof(PCNVDIMMDevice),
+ .instance_init = pc_nvdimm_init,
+ .class_init = pc_nvdimm_class_init,
+};
+
+static void pc_nvdimm_register_types(void)
+{
+ type_register_static(&pc_nvdimm_info);
+}
+
+type_init(pc_nvdimm_register_types)
diff --git a/include/hw/mem/pc-nvdimm.h b/include/hw/mem/pc-nvdimm.h
new file mode 100644
index 0000000..7f37b46
--- /dev/null
+++ b/include/hw/mem/pc-nvdimm.h
@@ -0,0 +1,32 @@
+/*
+ * NVDIMM (A Non-Volatile Dual In-line Memory Module) Virtualization Implement
+ *
+ * Copyright(C) 2015 Intel Corporation.
+ *
+ * Author:
+ * Xiao Guangrong <address@hidden>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef __PC_NVDIMM_H
+#define __PC_NVDIMM_H
+
+#include "hw/qdev.h"
+
+#ifdef CONFIG_LINUX
+typedef struct PCNVDIMMDevice {
+ /* private */
+ DeviceState parent_obj;
+
+ char *file;
+} PCNVDIMMDevice;
+
+#define TYPE_PC_NVDIMM "pc-nvdimm"
+
+#define PC_NVDIMM(obj) \
+ OBJECT_CHECK(PCNVDIMMDevice, (obj), TYPE_PC_NVDIMM)
+#else /* !CONFIG_LINUX */
+#endif
+#endif
--
2.1.0
- [Qemu-devel] [PATCH 00/16] implement vNVDIMM, Xiao Guangrong, 2015/07/01
- [Qemu-devel] [PATCH 02/16] i386/acpi-build: allow SSDT to operate on 64 bit, Xiao Guangrong, 2015/07/01
- [Qemu-devel] [PATCH 01/16] acpi: allow aml_operation_region() working on 64 bit offset, Xiao Guangrong, 2015/07/01
- [Qemu-devel] [PATCH 04/16] acpi: add aml_sizeof, Xiao Guangrong, 2015/07/01
- [Qemu-devel] [PATCH 03/16] acpi: add aml_derefof, Xiao Guangrong, 2015/07/01
- [Qemu-devel] [PATCH 05/16] acpi: add aml_create_field, Xiao Guangrong, 2015/07/01
- [Qemu-devel] [PATCH 06/16] pc: implement NVDIMM device abstract,
Xiao Guangrong <=
- [Qemu-devel] [PATCH 07/16] nvdimm: reserve address range for NVDIMM, Xiao Guangrong, 2015/07/01
- [Qemu-devel] [PATCH 08/16] nvdimm: init backend memory mapping and config data area, Xiao Guangrong, 2015/07/01
- [Qemu-devel] [PATCH 10/16] nvdimm: init the address region used by _DSM method, Xiao Guangrong, 2015/07/01
- [Qemu-devel] [PATCH 09/16] nvdimm: build ACPI NFIT table, Xiao Guangrong, 2015/07/01
- [Qemu-devel] [PATCH 11/16] nvdimm: build ACPI nvdimm devices, Xiao Guangrong, 2015/07/01
- [Qemu-devel] [PATCH 13/16] nvdimm: support NFIT_CMD_IMPLEMENTED function, Xiao Guangrong, 2015/07/01
- [Qemu-devel] [PATCH 12/16] nvdimm: save arg3 for NVDIMM device _DSM method, Xiao Guangrong, 2015/07/01
- [Qemu-devel] [PATCH 15/16] nvdimm: support NFIT_CMD_GET_CONFIG_DATA, Xiao Guangrong, 2015/07/01
- [Qemu-devel] [PATCH 14/16] nvdimm: support NFIT_CMD_GET_CONFIG_SIZE function, Xiao Guangrong, 2015/07/01