Introduce machine specific default memory size
PATCH v2 1/1 Introduce machine specific default memory size
QEMU default memory of 128MB is not enough to boot sPAPR guest. Introduce a member in the machine class to override the default memory size enforced by QEMU.
--- hw/ppc/spapr.c | 1 + include/hw/boards.h | 1 + include/hw/ppc/spapr.h | 3 +++ vl.c | 9 +++++++++ 4 files changed, 14 insertions(+)
hw/ppc/spapr.c +1 -0
@@ -1738,6 +1738,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) mc->max_cpus =MAX_CPUS ; mc->no_parallel =1 ; mc->default_boot_order =NULL ; + mc->default_ram_size =SPAPR_DEFAULT_RAM_SIZE ; mc->kvm_type = spapr_kvm_type; mc->has_dynamic_sysbus = true;
include/hw/boards.h +1 -0
@@ -108,6 +108,7 @@ struct MachineClass {const char *default_display;GlobalProperty *compat_props;const char *hw_version; +ram_addr_t default_ram_size; HotplugHandler *(*get_hotplug_handler)(MachineState *machine, DeviceState *dev);
include/hw/ppc/spapr.h +3 -0
@@ -444,6 +444,9 @@ int spapr_rtas_device_tree_setup(void *fdt, hwaddr rtas_addr,#define SPAPR_VIO_BASE_LIOBN 0x00000000#define SPAPR_PCI_BASE_LIOBN 0x80000000 +/* Default to 1GB guest ram_size */ +#define SPAPR_DEFAULT_RAM_SIZE (1ULL << 30) +#define RTAS_ERROR_LOG_MAX 2048typedef struct sPAPRTCETable sPAPRTCETable ;
vl.c +9 -0
@@ -2649,6 +2649,7 @@ static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size)const ram_addr_t default_ram_size = (ram_addr_t )DEFAULT_RAM_SIZE *1024 *1024 ;QemuOpts *opts =qemu_find_opts_singleton ("memory" ); +MachineClass *machine_class; sz =0 ; mem_str =qemu_opt_get (opts,"size" );
@@ -2684,6 +2685,14 @@ static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size)exit (EXIT_FAILURE ); } + machine_class =find_default_machine (); +if (machine_class->default_ram_size && ram_size < machine_class->default_ram_size) { +fprintf (stderr,"qemu: %s guest ram size defaulting to %ld MB\n" , + machine_class->name, + machine_class->default_ram_size / (1024 *1024 )); + ram_size = machine_class->default_ram_size; + } +/* store value for the future use */ qemu_opt_set_number (opts,"size" , ram_size, &error_abort); *maxram_size = ram_size;
Signature · 1 line
1.8.3.1
Quoted 4 lines · On Wed, 4 Mar 2015 16:48:05 +0530 Nikunj A Dadhania…
QEMU default memory of 128MB is not enough to boot sPAPR guest. Introduce a member in the machine class to override the default memory size enforced by QEMU.
now we have DEFAULT_RAM_SIZE in vl.c and default_ram_size in Machine class. it is confusing.
Could you make current ram_size in vl.c a property of Machine with default DEFAULT_RAM_SIZE moved there for generic Machine class and do what you are doing here in property setter. Then it will work for all machines the same way.
I'd actually suggest to take set_memory_options() and make ram_size, slots, maxmem a properties of Machine and remap -m parsing to normal machine option parsing. Getting rid of global ram_size along the way.
Quoted 73 lines
Signed-off-by Nikunj A Dadhania <[email protected]>--- hw/ppc/spapr.c | 1 + include/hw/boards.h | 1 + include/hw/ppc/spapr.h | 3 +++ vl.c | 9 +++++++++ 4 files changed, 14 insertions(+)hw/ppc/spapr.c +1
-0@@ -1738,6 +1738,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) mc->max_cpus =MAX_CPUS ; mc->no_parallel =1 ; mc->default_boot_order =NULL ; + mc->default_ram_size =SPAPR_DEFAULT_RAM_SIZE ; mc->kvm_type = spapr_kvm_type; mc->has_dynamic_sysbus = true;include/hw/boards.h +1
-0@@ -108,6 +108,7 @@ struct MachineClass {const char *default_display;GlobalProperty *compat_props;const char *hw_version; +ram_addr_t default_ram_size; HotplugHandler *(*get_hotplug_handler)(MachineState *machine, DeviceState *dev);include/hw/ppc/spapr.h +3
-0@@ -444,6 +444,9 @@ int spapr_rtas_device_tree_setup(void *fdt, hwaddr rtas_addr,#define SPAPR_VIO_BASE_LIOBN 0x00000000#define SPAPR_PCI_BASE_LIOBN 0x80000000 +/* Default to 1GB guest ram_size */ +#define SPAPR_DEFAULT_RAM_SIZE (1ULL << 30) +#define RTAS_ERROR_LOG_MAX 2048typedef struct sPAPRTCETable sPAPRTCETable ;vl.c +9
-0@@ -2649,6 +2649,7 @@ static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size)const ram_addr_t default_ram_size = (ram_addr_t )DEFAULT_RAM_SIZE *1024 *1024 ;QemuOpts *opts =qemu_find_opts_singleton ("memory" ); +MachineClass *machine_class; sz =0 ; mem_str =qemu_opt_get (opts,"size" );@@ -2684,6 +2685,14 @@ static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size)exit (EXIT_FAILURE ); } + machine_class =find_default_machine (); +if (machine_class->default_ram_size && ram_size < machine_class->default_ram_size) { +fprintf (stderr,"qemu: %s guest ram size defaulting to %ld MB\n" , + machine_class->name, + machine_class->default_ram_size / (1024 *1024 )); + ram_size = machine_class->default_ram_size; + } +/* store value for the future use */ qemu_opt_set_number (opts,"size" , ram_size, &error_abort); *maxram_size = ram_size;
Quoted 9 lines · Igor Mammedov
Quoted 4 lines · On Wed, 4 Mar 2015 16:48:05 +0530 Nikunj A Dadhania…
QEMU default memory of 128MB is not enough to boot sPAPR guest. Introduce a member in the machine class to override the default memory size enforced by QEMU.
now we have
DEFAULT_RAM_SIZEinvl.canddefault_ram_sizein Machine class. it is confusing.
Agree, but moving the define into hw/core/machine.c and setting it as base class default would make this clean.
Quoted 5 lines
Could you make current
ram_sizeinvl.ca property of Machine with defaultDEFAULT_RAM_SIZEmoved there for generic Machine class and do what you are doing here in property setter. Then it will work for all machines the same way.
Once is a property with a setter it can be set by command line! I don't think this is the right think to do.
Thanks,
Marcel
Quoted 82 lines
I'd actually suggest to take
set_memory_options()and makeram_size, slots, maxmem a properties of Machine and remap -m parsing to normal machine option parsing. Getting rid of globalram_sizealong the way.Quoted 73 lines
Signed-off-by Nikunj A Dadhania <[email protected]>--- hw/ppc/spapr.c | 1 + include/hw/boards.h | 1 + include/hw/ppc/spapr.h | 3 +++ vl.c | 9 +++++++++ 4 files changed, 14 insertions(+)hw/ppc/spapr.c +1
-0@@ -1738,6 +1738,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) mc->max_cpus =MAX_CPUS ; mc->no_parallel =1 ; mc->default_boot_order =NULL ; + mc->default_ram_size =SPAPR_DEFAULT_RAM_SIZE ; mc->kvm_type = spapr_kvm_type; mc->has_dynamic_sysbus = true;include/hw/boards.h +1
-0@@ -108,6 +108,7 @@ struct MachineClass {const char *default_display;GlobalProperty *compat_props;const char *hw_version; +ram_addr_t default_ram_size; HotplugHandler *(*get_hotplug_handler)(MachineState *machine, DeviceState *dev);include/hw/ppc/spapr.h +3
-0@@ -444,6 +444,9 @@ int spapr_rtas_device_tree_setup(void *fdt, hwaddr rtas_addr,#define SPAPR_VIO_BASE_LIOBN 0x00000000#define SPAPR_PCI_BASE_LIOBN 0x80000000 +/* Default to 1GB guest ram_size */ +#define SPAPR_DEFAULT_RAM_SIZE (1ULL << 30) +#define RTAS_ERROR_LOG_MAX 2048typedef struct sPAPRTCETable sPAPRTCETable ;vl.c +9
-0@@ -2649,6 +2649,7 @@ static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size)const ram_addr_t default_ram_size = (ram_addr_t )DEFAULT_RAM_SIZE *1024 *1024 ;QemuOpts *opts =qemu_find_opts_singleton ("memory" ); +MachineClass *machine_class; sz =0 ; mem_str =qemu_opt_get (opts,"size" );@@ -2684,6 +2685,14 @@ static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size)exit (EXIT_FAILURE ); } + machine_class =find_default_machine (); +if (machine_class->default_ram_size && ram_size < machine_class->default_ram_size) { +fprintf (stderr,"qemu: %s guest ram size defaulting to %ld MB\n" , + machine_class->name, + machine_class->default_ram_size / (1024 *1024 )); + ram_size = machine_class->default_ram_size; + } +/* store value for the future use */ qemu_opt_set_number (opts,"size" , ram_size, &error_abort); *maxram_size = ram_size;
Quoted 13 lines · On Wed, 04 Mar 2015 14:32:44 +0200 Marcel Apfelbaum…
Quoted 9 lines · Igor Mammedov
Quoted 4 lines · On Wed, 4 Mar 2015 16:48:05 +0530 Nikunj A Dadhania…
QEMU default memory of 128MB is not enough to boot sPAPR guest. Introduce a member in the machine class to override the default memory size enforced by QEMU.
now we have
DEFAULT_RAM_SIZEinvl.canddefault_ram_sizein Machine class. it is confusing.Agree, but moving the define into
hw/core/machine.cand setting it as base class default would make this clean.Quoted 1 line
Quoted 6 lines
Quoted 4 lines
Could you make current
ram_sizeinvl.ca property of Machine with defaultDEFAULT_RAM_SIZEmoved there for generic Machine class and do what you are doing here in property setter. Then it will work for all machines the same way.Once is a property with a setter it can be set by command line! I don't think this is the right think to do.
Why is it not right?
We could some day abandon -m and just use -machine property parsing. Another purpose of it is to move machine related code i.e. parsing/ setting/getting ram_size, slots, maxmem to machine class and drop adhoc parsing and globals in vl.c.
Quoted 87 lines
Thanks,
MarcelQuoted 82 lines
I'd actually suggest to take
set_memory_options()and makeram_size, slots, maxmem a properties of Machine and remap -m parsing to normal machine option parsing. Getting rid of globalram_sizealong the way.Quoted 73 lines
Signed-off-by Nikunj A Dadhania <[email protected]>--- hw/ppc/spapr.c | 1 + include/hw/boards.h | 1 + include/hw/ppc/spapr.h | 3 +++ vl.c | 9 +++++++++ 4 files changed, 14 insertions(+)hw/ppc/spapr.c +1
-0@@ -1738,6 +1738,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) mc->max_cpus =MAX_CPUS ; mc->no_parallel =1 ; mc->default_boot_order =NULL ; + mc->default_ram_size =SPAPR_DEFAULT_RAM_SIZE ; mc->kvm_type = spapr_kvm_type; mc->has_dynamic_sysbus = true;include/hw/boards.h +1
-0@@ -108,6 +108,7 @@ struct MachineClass {const char *default_display;GlobalProperty *compat_props;const char *hw_version; +ram_addr_t default_ram_size; HotplugHandler *(*get_hotplug_handler)(MachineState *machine, DeviceState *dev);include/hw/ppc/spapr.h +3
-0@@ -444,6 +444,9 @@ int spapr_rtas_device_tree_setup(void *fdt, hwaddr rtas_addr,#define SPAPR_VIO_BASE_LIOBN 0x00000000#define SPAPR_PCI_BASE_LIOBN 0x80000000 +/* Default to 1GB guest ram_size */ +#define SPAPR_DEFAULT_RAM_SIZE (1ULL << 30) +#define RTAS_ERROR_LOG_MAX 2048typedef struct sPAPRTCETable sPAPRTCETable ;vl.c +9
-0@@ -2649,6 +2649,7 @@ static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size)const ram_addr_t default_ram_size = (ram_addr_t )DEFAULT_RAM_SIZE *1024 *1024 ;QemuOpts *opts =qemu_find_opts_singleton ("memory" ); +MachineClass *machine_class; sz =0 ; mem_str =qemu_opt_get (opts,"size" );@@ -2684,6 +2685,14 @@ static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size)exit (EXIT_FAILURE ); } + machine_class =find_default_machine (); +if (machine_class->default_ram_size && ram_size < machine_class->default_ram_size) { +fprintf (stderr,"qemu: %s guest ram size defaulting to %ld MB\n" , + machine_class->name, + machine_class->default_ram_size / (1024 *1024 )); + ram_size = machine_class->default_ram_size; + } +/* store value for the future use */ qemu_opt_set_number (opts,"size" , ram_size, &error_abort); *maxram_size = ram_size;
Quoted 63 lines · Nikunj A Dadhania
QEMU default memory of 128MB is not enough to boot sPAPR guest. Introduce a member in the machine class to override the default memory size enforced by QEMU.
Signed-off-by Nikunj A Dadhania <[email protected]>--- hw/ppc/spapr.c | 1 + include/hw/boards.h | 1 + include/hw/ppc/spapr.h | 3 +++ vl.c | 9 +++++++++ 4 files changed, 14 insertions(+)hw/ppc/spapr.c +1
-0@@ -1738,6 +1738,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) mc->max_cpus =MAX_CPUS ; mc->no_parallel =1 ; mc->default_boot_order =NULL ; + mc->default_ram_size =SPAPR_DEFAULT_RAM_SIZE ; mc->kvm_type = spapr_kvm_type; mc->has_dynamic_sysbus = true;include/hw/boards.h +1
-0@@ -108,6 +108,7 @@ struct MachineClass {const char *default_display;GlobalProperty *compat_props;const char *hw_version; +ram_addr_t default_ram_size; HotplugHandler *(*get_hotplug_handler)(MachineState *machine, DeviceState *dev);include/hw/ppc/spapr.h +3
-0@@ -444,6 +444,9 @@ int spapr_rtas_device_tree_setup(void *fdt, hwaddr rtas_addr,#define SPAPR_VIO_BASE_LIOBN 0x00000000#define SPAPR_PCI_BASE_LIOBN 0x80000000 +/* Default to 1GB guest ram_size */ +#define SPAPR_DEFAULT_RAM_SIZE (1ULL << 30) +#define RTAS_ERROR_LOG_MAX 2048typedef struct sPAPRTCETable sPAPRTCETable ;vl.c +1
-0@@ -2649,6 +2649,7 @@ static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size)const ram_addr_t default_ram_size = (ram_addr_t )DEFAULT_RAM_SIZE *1024 *1024 ;QemuOpts *opts =qemu_find_opts_singleton ("memory" ); +MachineClass *machine_class; sz =0 ; mem_str =qemu_opt_get (opts,"size" );
vl.c static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size) · line 2693
Quoted 9 lines
vl.c +6
-0@@ -2684,6 +2685,14 @@ static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size)exit (EXIT_FAILURE ); } + machine_class =find_default_machine (); +if (machine_class->default_ram_size && ram_size < machine_class->default_ram_size) { +fprintf (stderr,"qemu: %s guest ram size defaulting to %ld MB\n" , + machine_class->name, + machine_class->default_ram_size / (1024 *1024 )); + ram_size = machine_class->default_ram_size;
Can't the check happen at the same spot that the current 128MB default gets set?
Also, why so complicated? Just have a default value of 128MB in the default machine class and just override it from the sPAPR one. Then unconditionally set ram_size = mc->default_ram_size in the code that today sets ram_size = 128MB.
Alex
Quoted 6 lines
vl.c +2
-0+ } +/* store value for the future use */ qemu_opt_set_number (opts,"size" , ram_size, &error_abort); *maxram_size = ram_size;
Quoted 79 lines · Alexander Graf
Quoted 63 lines · Nikunj A Dadhania
QEMU default memory of 128MB is not enough to boot sPAPR guest. Introduce a member in the machine class to override the default memory size enforced by QEMU.
Signed-off-by Nikunj A Dadhania <[email protected]>--- hw/ppc/spapr.c | 1 + include/hw/boards.h | 1 + include/hw/ppc/spapr.h | 3 +++ vl.c | 9 +++++++++ 4 files changed, 14 insertions(+)hw/ppc/spapr.c +1
-0@@ -1738,6 +1738,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) mc->max_cpus =MAX_CPUS ; mc->no_parallel =1 ; mc->default_boot_order =NULL ; + mc->default_ram_size =SPAPR_DEFAULT_RAM_SIZE ; mc->kvm_type = spapr_kvm_type; mc->has_dynamic_sysbus = true;include/hw/boards.h +1
-0@@ -108,6 +108,7 @@ struct MachineClass {const char *default_display;GlobalProperty *compat_props;const char *hw_version; +ram_addr_t default_ram_size; HotplugHandler *(*get_hotplug_handler)(MachineState *machine, DeviceState *dev);include/hw/ppc/spapr.h +3
-0@@ -444,6 +444,9 @@ int spapr_rtas_device_tree_setup(void *fdt, hwaddr rtas_addr,#define SPAPR_VIO_BASE_LIOBN 0x00000000#define SPAPR_PCI_BASE_LIOBN 0x80000000 +/* Default to 1GB guest ram_size */ +#define SPAPR_DEFAULT_RAM_SIZE (1ULL << 30) +#define RTAS_ERROR_LOG_MAX 2048typedef struct sPAPRTCETable sPAPRTCETable ;vl.c +1
-0@@ -2649,6 +2649,7 @@ static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size)const ram_addr_t default_ram_size = (ram_addr_t )DEFAULT_RAM_SIZE *1024 *1024 ;QemuOpts *opts =qemu_find_opts_singleton ("memory" ); +MachineClass *machine_class; sz =0 ; mem_str =qemu_opt_get (opts,"size" );vl.c static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size) · line 2693
Quoted 9 lines
vl.c +6
-0@@ -2684,6 +2685,14 @@ static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size)exit (EXIT_FAILURE ); } + machine_class =find_default_machine (); +if (machine_class->default_ram_size && ram_size < machine_class->default_ram_size) { +fprintf (stderr,"qemu: %s guest ram size defaulting to %ld MB\n" , + machine_class->name, + machine_class->default_ram_size / (1024 *1024 )); + ram_size = machine_class->default_ram_size;Can't the check happen at the same spot that the current 128MB default gets set?
Quoted 4 lines
Also, why so complicated? Just have a default value of 128MB in the default machine class and just override it from the sPAPR one. Then unconditionally set
ram_size=mc->default_ram_sizein the code that today setsram_size= 128MB.
+1
That's what I said :), but much more concise.
Thanks,
Marcel
Quoted 11 lines
Alex
Quoted 6 lines
vl.c +2
-0+ } +/* store value for the future use */ qemu_opt_set_number (opts,"size" , ram_size, &error_abort); *maxram_size = ram_size;
Quoted 5 lines · Nikunj A Dadhania
QEMU default memory of 128MB is not enough to boot sPAPR guest. Introduce a member in the machine class to override the default memory size enforced by QEMU.
Signed-off-by Nikunj A Dadhania <[email protected]>
Hi,
Thank you for contributing to QEMU!
Quoted 24 lines
--- hw/ppc/spapr.c | 1 + include/hw/boards.h | 1 + include/hw/ppc/spapr.h | 3 +++ vl.c | 9 +++++++++ 4 files changed, 14 insertions(+)hw/ppc/spapr.c +1
-0@@ -1738,6 +1738,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) mc->max_cpus =MAX_CPUS ; mc->no_parallel =1 ; mc->default_boot_order =NULL ; + mc->default_ram_size =SPAPR_DEFAULT_RAM_SIZE ; mc->kvm_type = spapr_kvm_type; mc->has_dynamic_sysbus = true;include/hw/boards.h +0
-0
include/hw/boards.h struct MachineClass { · line 111
Quoted 4 lines
include/hw/boards.h +1
-0@@ -108,6 +108,7 @@ struct MachineClass {const char *default_display;GlobalProperty *compat_props;const char *hw_version; +ram_addr_t default_ram_size;
You add a field to MachineClass that represents default_ram_size. That's fair because different machine types may have a different "native" default.
But in this case you should set DEFAULT_RAM_SIZE as default for all machine types for consistency. (as suggested also by others)
Quoted 30 lines
include/hw/boards.h +0
-0HotplugHandler *(*get_hotplug_handler)(MachineState *machine, DeviceState *dev);include/hw/ppc/spapr.h +3
-0@@ -444,6 +444,9 @@ int spapr_rtas_device_tree_setup(void *fdt, hwaddr rtas_addr,#define SPAPR_VIO_BASE_LIOBN 0x00000000#define SPAPR_PCI_BASE_LIOBN 0x80000000 +/* Default to 1GB guest ram_size */ +#define SPAPR_DEFAULT_RAM_SIZE (1ULL << 30) +#define RTAS_ERROR_LOG_MAX 2048typedef struct sPAPRTCETable sPAPRTCETable ;vl.c +1
-0@@ -2649,6 +2649,7 @@ static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size)const ram_addr_t default_ram_size = (ram_addr_t )DEFAULT_RAM_SIZE *1024 *1024 ;QemuOpts *opts =qemu_find_opts_singleton ("memory" ); +MachineClass *machine_class; sz =0 ; mem_str =qemu_opt_get (opts,"size" );
vl.c static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size) · line 2688
Quoted 4 lines
vl.c +1
-0@@ -2684,6 +2685,14 @@ static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size)exit (EXIT_FAILURE ); } + machine_class =find_default_machine ();
I am not sure this is want you want to do here.
I think you want to use the *current* machine class and not the default one. that can be passed as parameter to set_memory_options.
vl.c static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size) · line 2689
Quoted 1 line
vl.c +1
-0+if (machine_class->default_ram_size && ram_size < machine_class->default_ram_size) {
and here you can drop the un-natural machine_class->default_ram_size check
vl.c static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size) · line 2698
Quoted 10 lines
vl.c +6
-0+fprintf (stderr,"qemu: %s guest ram size defaulting to %ld MB\n" , + machine_class->name, + machine_class->default_ram_size / (1024 *1024 )); + ram_size = machine_class->default_ram_size; + } +/* store value for the future use */ qemu_opt_set_number (opts,"size" , ram_size, &error_abort); *maxram_size = ram_size;
Thanks,
Marcel