mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
machine: alias -mem-path and -mem-prealloc into memory-foo backend
Allow machine to opt in for hostmem backend based initial RAM even if user uses old -mem-path/prealloc options by providing MachineClass::default_ram_id Follow up patches will incrementally convert machines to new API, by dropping memory_region_allocate_system_memory() and setting default_ram_id that board used to use before conversion to keep migration stream the same. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Message-Id: <20200219160953.13771-4-imammedo@redhat.com>
This commit is contained in:
parent
aa8b183974
commit
900c0ba373
5 changed files with 49 additions and 9 deletions
25
vl.c
25
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();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue