[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 02/80] machine: introduce memory-backend property
From: |
Igor Mammedov |
Subject: |
[PATCH v4 02/80] machine: introduce memory-backend property |
Date: |
Fri, 31 Jan 2020 16:08:32 +0100 |
Property will contain link to memory backend that will be
used for backing initial RAM.
Follow up commit will alias -mem-path and -mem-prealloc
CLI options into memory backend options to make memory
handling consistent (using only hostmem backend family
for guest RAM allocation).
Signed-off-by: Igor Mammedov <address@hidden>
---
v4:
* make property a string, instead of a link.
Fixes -M memory-backend=foo: foo not found error
since foo creation is delayed well beyond point
where machine's properties are set
v3:
* rename property name from ram-memdev to memory-backend
(Paolo Bonzini <address@hidden>)
CC: address@hidden
CC: address@hidden
CC: address@hidden
---
include/hw/boards.h | 2 ++
hw/core/machine.c | 24 ++++++++++++++++++++++++
2 files changed, 26 insertions(+)
diff --git a/include/hw/boards.h b/include/hw/boards.h
index fb1b43d..7b4b6b7 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -4,6 +4,7 @@
#define HW_BOARDS_H
#include "exec/memory.h"
+#include "sysemu/hostmem.h"
#include "sysemu/blockdev.h"
#include "sysemu/accel.h"
#include "qapi/qapi-types-machine.h"
@@ -285,6 +286,7 @@ struct MachineState {
bool enforce_config_section;
bool enable_graphics;
char *memory_encryption;
+ char *ram_memdev_id;
DeviceMemoryState *device_memory;
ram_addr_t ram_size;
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 3e288bf..752a227 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -505,6 +505,22 @@ static void validate_sysbus_device(SysBusDevice *sbdev,
void *opaque)
}
}
+static char *machine_get_memdev(Object *obj, Error **errp)
+{
+ MachineState *ms = MACHINE(obj);
+
+ return g_strdup(ms->ram_memdev_id);
+}
+
+static void machine_set_memdev(Object *obj, const char *value, Error **errp)
+{
+ MachineState *ms = MACHINE(obj);
+
+ g_free(ms->ram_memdev_id);
+ ms->ram_memdev_id = g_strdup(value);
+}
+
+
static void machine_init_notify(Notifier *notifier, void *data)
{
MachineState *machine = MACHINE(qdev_get_machine());
@@ -886,6 +902,14 @@ static void machine_initfn(Object *obj)
"Table (HMAT)", NULL);
}
+ object_property_add_str(obj, "memory-backend",
+ machine_get_memdev, machine_set_memdev,
+ &error_abort);
+ object_property_set_description(obj, "memory-backend",
+ "Set RAM backend"
+ "Valid value is ID of hostmem based
backend",
+ &error_abort);
+
/* Register notifier when init is done for sysbus sanity checks */
ms->sysbus_notifier.notify = machine_init_notify;
qemu_add_machine_init_done_notifier(&ms->sysbus_notifier);
--
2.7.4
- [PATCH v4 00/80] refactor main RAM allocation to use hostmem backend, Igor Mammedov, 2020/01/31
- [PATCH v4 02/80] machine: introduce memory-backend property,
Igor Mammedov <=
- [PATCH v4 01/80] numa: remove deprecated -mem-path fallback to anonymous RAM, Igor Mammedov, 2020/01/31
- [PATCH v4 04/80] machine: introduce convenience MachineState::ram, Igor Mammedov, 2020/01/31
- [PATCH v4 05/80] initialize MachineState::ram in NUMA case, Igor Mammedov, 2020/01/31
- [PATCH v4 11/80] arm/collie: use memdev for RAM, Igor Mammedov, 2020/01/31
- [PATCH v4 08/80] alpha/dp264: use memdev for RAM, Igor Mammedov, 2020/01/31
- [PATCH v4 06/80] vl.c: move -m parsing after memory backends has been processed, Igor Mammedov, 2020/01/31
- [PATCH v4 07/80] vl.c: ensure that ram_size matches size of machine.memory-backend, Igor Mammedov, 2020/01/31
- [PATCH v4 10/80] arm/aspeed: use memdev for RAM, Igor Mammedov, 2020/01/31
- [PATCH v4 14/80] arm/highbank: use memdev for RAM, Igor Mammedov, 2020/01/31
- [PATCH v4 09/80] arm/aspeed: actually check RAM size, Igor Mammedov, 2020/01/31