aboutsummaryrefslogtreecommitdiff
path: root/hw/mem/nvdimm.c
diff options
context:
space:
mode:
authorDavid Hildenbrand <david@redhat.com>2018-10-05 11:20:18 +0200
committerEduardo Habkost <ehabkost@redhat.com>2018-10-24 06:44:59 -0300
commit3a0a2b0a2ba87ed00b732f061e59f890aaa27c17 (patch)
tree29c74b2b83426ff0959fbd8a704445133b2395b7 /hw/mem/nvdimm.c
parent946d6154aba9aaa4d19433a6a8bcd3de3b119240 (diff)
memory-device: factor out get_memory_region() from pc-dimm
The memory region is necessary for plugging/unplugging a memory device. The region size (via get_region_size()) is no longer sufficient, as besides the alignment, also the region itself is required in order to add it to the device memory region of the machine via - memory_region_add_subregion - memory_region_del_subregion So, to factor out plugging/unplugging of memory devices from pc-dimm code, we have to factor out access to the memory region first. Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20181005092024.14344-11-david@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'hw/mem/nvdimm.c')
-rw-r--r--hw/mem/nvdimm.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c
index 1c6674c4ed..49324f3fae 100644
--- a/hw/mem/nvdimm.c
+++ b/hw/mem/nvdimm.c
@@ -27,6 +27,7 @@
#include "qapi/error.h"
#include "qapi/visitor.h"
#include "hw/mem/nvdimm.h"
+#include "hw/mem/memory-device.h"
static void nvdimm_get_label_size(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
@@ -118,9 +119,10 @@ static void nvdimm_prepare_memory_region(NVDIMMDevice *nvdimm, Error **errp)
nvdimm->nvdimm_mr->align = align;
}
-static MemoryRegion *nvdimm_get_memory_region(PCDIMMDevice *dimm, Error **errp)
+static MemoryRegion *nvdimm_md_get_memory_region(MemoryDeviceState *md,
+ Error **errp)
{
- NVDIMMDevice *nvdimm = NVDIMM(dimm);
+ NVDIMMDevice *nvdimm = NVDIMM(md);
Error *local_err = NULL;
if (!nvdimm->nvdimm_mr) {
@@ -190,11 +192,12 @@ static Property nvdimm_properties[] = {
static void nvdimm_class_init(ObjectClass *oc, void *data)
{
PCDIMMDeviceClass *ddc = PC_DIMM_CLASS(oc);
+ MemoryDeviceClass *mdc = MEMORY_DEVICE_CLASS(oc);
NVDIMMClass *nvc = NVDIMM_CLASS(oc);
DeviceClass *dc = DEVICE_CLASS(oc);
ddc->realize = nvdimm_realize;
- ddc->get_memory_region = nvdimm_get_memory_region;
+ mdc->get_memory_region = nvdimm_md_get_memory_region;
dc->props = nvdimm_properties;
nvc->read_label_data = nvdimm_read_label_data;