mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23: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
|
@ -38,6 +38,11 @@ typedef struct MemoryDeviceState {
|
|||
* mapped into guest physical address space at a certain address. The
|
||||
* address in guest physical memory can either be specified explicitly
|
||||
* or get assigned automatically.
|
||||
*
|
||||
* Conceptually, memory devices only span one memory region. If multiple
|
||||
* successive memory regions are used, a covering memory region has to
|
||||
* be provided. Scattered memory regions are not supported for single
|
||||
* devices.
|
||||
*/
|
||||
typedef struct MemoryDeviceClass {
|
||||
/* private */
|
||||
|
@ -68,6 +73,16 @@ typedef struct MemoryDeviceClass {
|
|||
uint64_t (*get_plugged_size)(const MemoryDeviceState *md, Error **errp);
|
||||
uint64_t (*get_region_size)(const MemoryDeviceState *md, Error **errp);
|
||||
|
||||
/*
|
||||
* Return the memory region of the memory device.
|
||||
*
|
||||
* Called when (un)plugging the memory device, to (un)map the
|
||||
* memory region in guest physical memory, but also to detect the
|
||||
* required alignment during address assignment or when the size of the
|
||||
* memory region is required.
|
||||
*/
|
||||
MemoryRegion *(*get_memory_region)(MemoryDeviceState *md, Error **errp);
|
||||
|
||||
/*
|
||||
* Translate the memory device into #MemoryDeviceInfo.
|
||||
*/
|
||||
|
|
|
@ -61,9 +61,6 @@ typedef struct PCDIMMDevice {
|
|||
* PCDIMMDeviceClass:
|
||||
* @realize: called after common dimm is realized so that the dimm based
|
||||
* devices get the chance to do specified operations.
|
||||
* @get_memory_region: returns #MemoryRegion associated with @dimm which
|
||||
* is directly mapped into the physical address space of guest. Will not
|
||||
* fail after the device was realized.
|
||||
* @get_vmstate_memory_region: returns #MemoryRegion which indicates the
|
||||
* memory of @dimm should be kept during live migration. Will not fail
|
||||
* after the device was realized.
|
||||
|
@ -74,7 +71,6 @@ typedef struct PCDIMMDeviceClass {
|
|||
|
||||
/* public */
|
||||
void (*realize)(PCDIMMDevice *dimm, Error **errp);
|
||||
MemoryRegion *(*get_memory_region)(PCDIMMDevice *dimm, Error **errp);
|
||||
MemoryRegion *(*get_vmstate_memory_region)(PCDIMMDevice *dimm,
|
||||
Error **errp);
|
||||
} PCDIMMDeviceClass;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue