[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 10/20] memory-device: complete factoring out plug
From: |
David Hildenbrand |
Subject: |
[Qemu-devel] [PATCH v2 10/20] memory-device: complete factoring out plug handling |
Date: |
Wed, 29 Aug 2018 17:36:14 +0200 |
With the new memory device functions in place, we can factor out
plugging of memory devices completely.
Signed-off-by: David Hildenbrand <address@hidden>
---
hw/mem/memory-device.c | 10 +++++++---
hw/mem/pc-dimm.c | 7 +------
include/hw/mem/memory-device.h | 3 +--
3 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/hw/mem/memory-device.c b/hw/mem/memory-device.c
index ec9d175a2c..c7a12ff2c4 100644
--- a/hw/mem/memory-device.c
+++ b/hw/mem/memory-device.c
@@ -278,10 +278,14 @@ out:
error_propagate(errp, local_err);
}
-void memory_device_plug_region(MachineState *ms, MemoryRegion *mr,
- uint64_t addr)
+void memory_device_plug(MemoryDeviceState *md, MachineState *ms)
{
- /* we expect a previous call to memory_device_get_free_addr() */
+ const MemoryDeviceClass *mdc = MEMORY_DEVICE_GET_CLASS(md);
+ const uint64_t addr = mdc->get_addr(md);
+ MemoryRegion *mr;
+
+ /* we expect a previous call to memory_device_pre_plug() */
+ mr = mdc->get_memory_region(md, &error_abort);
g_assert(ms->device_memory);
memory_region_add_subregion(&ms->device_memory->mr,
diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index 0d0072a7e8..9d3dcc8da9 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -65,13 +65,8 @@ void pc_dimm_plug(DeviceState *dev, MachineState *machine,
Error **errp)
PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
MemoryRegion *vmstate_mr = ddc->get_vmstate_memory_region(dimm,
&error_abort);
- MemoryRegion *mr = ddc->get_memory_region(dimm, &error_abort);
- uint64_t addr;
-
- addr = object_property_get_uint(OBJECT(dev), PC_DIMM_ADDR_PROP,
- &error_abort);
- memory_device_plug_region(machine, mr, addr);
+ memory_device_plug(MEMORY_DEVICE(dev), machine);
vmstate_register_ram(vmstate_mr, dev);
}
diff --git a/include/hw/mem/memory-device.h b/include/hw/mem/memory-device.h
index dd582f9125..49cf2d498b 100644
--- a/include/hw/mem/memory-device.h
+++ b/include/hw/mem/memory-device.h
@@ -58,8 +58,7 @@ MemoryDeviceInfoList *qmp_memory_device_list(void);
uint64_t get_plugged_memory_size(void);
void memory_device_pre_plug(MemoryDeviceState *md, MachineState *ms,
const uint64_t *legacy_align, Error **errp);
-void memory_device_plug_region(MachineState *ms, MemoryRegion *mr,
- uint64_t addr);
+void memory_device_plug(MemoryDeviceState *md, MachineState *ms);
void memory_device_unplug_region(MachineState *ms, MemoryRegion *mr);
#endif
--
2.17.1
- Re: [Qemu-devel] [PATCH v2 02/20] memory-device: use memory device terminology in error messages, (continued)
- [Qemu-devel] [PATCH v2 01/20] memory-device: fix error message when hinted address is too small, David Hildenbrand, 2018/08/29
- [Qemu-devel] [PATCH v2 03/20] memory-device: introduce separate config option, David Hildenbrand, 2018/08/29
- [Qemu-devel] [PATCH v2 04/20] memory-device: get_region_size()/get_plugged_size() might fail, David Hildenbrand, 2018/08/29
- [Qemu-devel] [PATCH v2 05/20] memory-device: convert get_region_size() to get_memory_region(), David Hildenbrand, 2018/08/29
- [Qemu-devel] [PATCH v2 06/20] memory-device: document MemoryDeviceClass, David Hildenbrand, 2018/08/29
- [Qemu-devel] [PATCH v2 07/20] memory-device: add device class function set_addr(), David Hildenbrand, 2018/08/29
- [Qemu-devel] [PATCH v2 08/20] pc-dimm: implement memory device class function set_addr(), David Hildenbrand, 2018/08/29
- [Qemu-devel] [PATCH v2 09/20] memory-device: complete factoring out pre_plug handling, David Hildenbrand, 2018/08/29
- [Qemu-devel] [PATCH v2 10/20] memory-device: complete factoring out plug handling,
David Hildenbrand <=
- [Qemu-devel] [PATCH v2 11/20] memory-device: complete factoring out unplug handling, David Hildenbrand, 2018/08/29
- [Qemu-devel] [PATCH v2 12/20] memory-device: trace when pre_assigning/assigning/unassigning addresses, David Hildenbrand, 2018/08/29
- [Qemu-devel] [PATCH v2 13/20] hw/acpi-build: only indicate nvdimm and pc-dimm, David Hildenbrand, 2018/08/29
- [Qemu-devel] [PATCH v2 14/20] memory-device: ids of virtio based devices are special, David Hildenbrand, 2018/08/29