Message ID | 1579100861-73692-3-git-send-email-imammedo@redhat.com |
---|---|
State | New |
Headers | show |
Series | refactor main RAM allocation to use hostmem backend | expand |
On 15/01/20 16:06, Igor Mammedov wrote: > > + object_property_add_link(obj, "ram-memdev", TYPE_MEMORY_BACKEND, > + (Object **)&ms->ram_memdev, > + object_property_allow_set_link, > + OBJ_PROP_LINK_STRONG, &error_abort); > + object_property_set_description(obj, "ram-memdev", > + "Set RAM backend" > + "Valid value is ID of hostmem based backend", > + &error_abort); > + Obligatory bikeshedding, why not just ram (the MachineState field can remain "ram_memdev"). Or memory-backend matching the QOM type names. Paolo
On Wed, 15 Jan 2020 16:56:30 +0100 Paolo Bonzini <pbonzini@redhat.com> wrote: > On 15/01/20 16:06, Igor Mammedov wrote: > > > > + object_property_add_link(obj, "ram-memdev", TYPE_MEMORY_BACKEND, > > + (Object **)&ms->ram_memdev, > > + object_property_allow_set_link, > > + OBJ_PROP_LINK_STRONG, &error_abort); > > + object_property_set_description(obj, "ram-memdev", > > + "Set RAM backend" > > + "Valid value is ID of hostmem based backend", > > + &error_abort); > > + > > Obligatory bikeshedding, why not just ram (the MachineState field can > remain "ram_memdev"). Or memory-backend matching the QOM type names. I'd say it was inspired by "-numa node,memdev" option for some sort of consistency. But I'm fine with any other name as far as there is consensus. If I had to choose between 'ram' and 'memory-backend', I'd go for the later. > > Paolo >
On 1/15/20 5:39 PM, Igor Mammedov wrote: > On Wed, 15 Jan 2020 16:56:30 +0100 > Paolo Bonzini <pbonzini@redhat.com> wrote: > >> On 15/01/20 16:06, Igor Mammedov wrote: >>> >>> + object_property_add_link(obj, "ram-memdev", TYPE_MEMORY_BACKEND, >>> + (Object **)&ms->ram_memdev, >>> + object_property_allow_set_link, >>> + OBJ_PROP_LINK_STRONG, &error_abort); >>> + object_property_set_description(obj, "ram-memdev", >>> + "Set RAM backend" >>> + "Valid value is ID of hostmem based backend", >>> + &error_abort); >>> + >> >> Obligatory bikeshedding, why not just ram (the MachineState field can >> remain "ram_memdev"). Or memory-backend matching the QOM type names. > > I'd say it was inspired by "-numa node,memdev" option for some sort of consistency. > But I'm fine with any other name as far as there is consensus. > If I had to choose between 'ram' and 'memory-backend', I'd go for the later. +1 for "memory-backend".
diff --git a/include/hw/boards.h b/include/hw/boards.h index fb1b43d..6aa01b8 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; + HostMemoryBackend *ram_memdev; DeviceMemoryState *device_memory; ram_addr_t ram_size; diff --git a/hw/core/machine.c b/hw/core/machine.c index 3e288bf..fd573d2 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -886,6 +886,15 @@ static void machine_initfn(Object *obj) "Table (HMAT)", NULL); } + object_property_add_link(obj, "ram-memdev", TYPE_MEMORY_BACKEND, + (Object **)&ms->ram_memdev, + object_property_allow_set_link, + OBJ_PROP_LINK_STRONG, &error_abort); + object_property_set_description(obj, "ram-memdev", + "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);
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 <imammedo@redhat.com> --- CC: ehabkost@redhat.com CC: pbonzini@redhat.com --- include/hw/boards.h | 2 ++ hw/core/machine.c | 9 +++++++++ 2 files changed, 11 insertions(+)