aboutsummaryrefslogtreecommitdiff
path: root/include/hw
diff options
context:
space:
mode:
authorIgor Mammedov <imammedo@redhat.com>2020-02-19 11:08:38 -0500
committerPatchew Importer <importer@patchew.org>2020-02-19 16:49:53 +0000
commit82b911aaff3ba33a3c028a533c5e169c274a7c3d (patch)
tree884387b1f8c4657ab5a1e8e366d7a159f11ca282 /include/hw
parent900c0ba373aada4c13d47d95330aa72ec4067ba5 (diff)
machine: introduce convenience MachineState::ram
the new field will be used by boards to get access to main RAM memory region and will help to save boiler plate in boards which often introduce a field or variable just for this purpose. Memory region will be equivalent to what currently used memory_region_allocate_system_memory() is returning apart from that it will come from hostmem backend. Followup patches will incrementally switch boards to using RAM from MachineState::ram. Patch takes care of non-NUMA case and follow up patch will initialize MachineState::ram for NUMA case. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20200219160953.13771-5-imammedo@redhat.com>
Diffstat (limited to 'include/hw')
-rw-r--r--include/hw/boards.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 8e536cafb2..ae2b60fb5e 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -73,7 +73,12 @@ void machine_set_cpu_numa_node(MachineState *machine,
Error **errp);
void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type);
-
+/*
+ * Checks that backend isn't used, preps it for exclusive usage and
+ * returns migratable MemoryRegion provided by backend.
+ */
+MemoryRegion *machine_consume_memdev(MachineState *machine,
+ HostMemoryBackend *backend);
/**
* CPUArchId:
@@ -295,6 +300,11 @@ struct MachineState {
bool enable_graphics;
char *memory_encryption;
char *ram_memdev_id;
+ /*
+ * convenience alias to ram_memdev_id backend memory region
+ * or to numa container memory region
+ */
+ MemoryRegion *ram;
DeviceMemoryState *device_memory;
ram_addr_t ram_size;