mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 00:33:55 -06:00
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>
This commit is contained in:
parent
946d6154ab
commit
3a0a2b0a2b
4 changed files with 39 additions and 16 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue