aboutsummaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/vl.c b/vl.c
index 794f2e5733..4dc4803611 100644
--- a/vl.c
+++ b/vl.c
@@ -75,6 +75,7 @@ int main(int argc, char **argv)
#include "ui/input.h"
#include "sysemu/sysemu.h"
#include "sysemu/numa.h"
+#include "sysemu/hostmem.h"
#include "exec/gdbstub.h"
#include "qemu/timer.h"
#include "chardev/char.h"
@@ -2805,6 +2806,26 @@ static void configure_accelerators(const char *progname)
}
}
+static void create_default_memdev(MachineState *ms, const char *path,
+ bool prealloc)
+{
+ Object *obj;
+ MachineClass *mc = MACHINE_GET_CLASS(ms);
+
+ obj = object_new(path ? TYPE_MEMORY_BACKEND_FILE : TYPE_MEMORY_BACKEND_RAM);
+ if (path) {
+ object_property_set_str(obj, path, "mem-path", &error_fatal);
+ }
+ object_property_set_bool(obj, prealloc, "prealloc", &error_fatal);
+ object_property_set_int(obj, ms->ram_size, "size", &error_fatal);
+ object_property_add_child(object_get_objects_root(), mc->default_ram_id,
+ obj, &error_fatal);
+ user_creatable_complete(USER_CREATABLE(obj), &error_fatal);
+ object_unref(obj);
+ object_property_set_str(OBJECT(ms), mc->default_ram_id, "memory-backend",
+ &error_fatal);
+}
+
int main(int argc, char **argv, char **envp)
{
int i;
@@ -4268,6 +4289,10 @@ int main(int argc, char **argv, char **envp)
}
parse_numa_opts(current_machine);
+ if (machine_class->default_ram_id && current_machine->ram_size &&
+ !current_machine->ram_memdev_id) {
+ create_default_memdev(current_machine, mem_path, mem_prealloc);
+ }
/* do monitor/qmp handling at preconfig state if requested */
main_loop();