aboutsummaryrefslogtreecommitdiff
path: root/include/hw/boards.h
diff options
context:
space:
mode:
authorDavid Hildenbrand <david@redhat.com>2023-09-26 20:57:28 +0200
committerDavid Hildenbrand <david@redhat.com>2023-10-12 14:15:22 +0200
commitf9716f4b0d6eaee5d0b1ccf428a102e0c148fa30 (patch)
tree54c3248b993bfd07c6a580351aa242a84a110ec2 /include/hw/boards.h
parent759bac673a8de9d6db50b0f96caa7b70cf0d1694 (diff)
downloadqemu-f9716f4b0d6eaee5d0b1ccf428a102e0c148fa30.zip
qemu-f9716f4b0d6eaee5d0b1ccf428a102e0c148fa30.tar.gz
qemu-f9716f4b0d6eaee5d0b1ccf428a102e0c148fa30.tar.bz2
memory-device: Track required and actually used memslots in DeviceMemoryState
Let's track how many memslots are required by plugged memory devices and how many are currently actually getting used by plugged memory devices. "required - used" is the number of reserved memslots. For now, the number of used and required memslots is always equal, and there are no reservations. This is a preparation for memory devices that want to dynamically consume memslots after initially specifying how many they require -- where we'll end up with reserved memslots. To track the number of used memslots, create a new address space for our device memory and register a memory listener (add/remove) for that address space. Message-ID: <20230926185738.277351-9-david@redhat.com> Reviewed-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com>
Diffstat (limited to 'include/hw/boards.h')
-rw-r--r--include/hw/boards.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 55a64a1..01bddb2 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -297,15 +297,23 @@ struct MachineClass {
* DeviceMemoryState:
* @base: address in guest physical address space where the memory
* address space for memory devices starts
- * @mr: address space container for memory devices
+ * @mr: memory region container for memory devices
+ * @as: address space for memory devices
+ * @listener: memory listener used to track used memslots in the address space
* @dimm_size: the sum of plugged DIMMs' sizes
* @used_region_size: the part of @mr already used by memory devices
+ * @required_memslots: the number of memslots required by memory devices
+ * @used_memslots: the number of memslots currently used by memory devices
*/
typedef struct DeviceMemoryState {
hwaddr base;
MemoryRegion mr;
+ AddressSpace as;
+ MemoryListener listener;
uint64_t dimm_size;
uint64_t used_region_size;
+ unsigned int required_memslots;
+ unsigned int used_memslots;
} DeviceMemoryState;
/**