Skip to contentSkip to conversation

vl: allow not specifying size in -m when using -M memory-backend

PATCH In review Paolo Bonzini 2 participants 2 messages May 18, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vl: allow not specifying size in -m when using -M memory-backend

Starting in QEMU 6.0's commit f5c9fcb82d ("vl: separate qemu_create_machine", 2020-12-10), a function have_custom_ram_size() replaced the return value of set_memory_options().

The purpose of the return value was to record the presence of "-m size", and if it was not there, change the default RAM size to the size of the memory backend passed with "-M memory-backend".

With that commit, however, have_custom_ram_size() is now queried only after set_memory_options has stored the fixed-up RAM size in QemuOpts for "future use". This was actually the only future use of the fixed-up RAM size, so remove that code and fix the bug.

Fixes f5c9fcb82d ("vl: separate qemu_create_machine", 2020-12-10)
---
 softmmu/vl.c | 2 --
 1 file changed, 2 deletions(-)
softmmu/vl.c +0 -2
index ac0ff6e160..21e55718a6 100644
@@ -2039,8 +2039,6 @@ static void set_memory_options(MachineClass *mc)
         exit(EXIT_FAILURE);
     }
 
-    /* store value for the future use */
-    qemu_opt_set_number(opts, "size", ram_size, &error_abort);
     maxram_size = ram_size;
 
     if (qemu_opt_get(opts, "maxmem")) {
Signature · 1 line
2.31.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · On Tue, 18 May 2021 12:35:31 +0200 Paolo Bonzini <[email protected]> wrote:

Starting in QEMU 6.0's commit f5c9fcb82d ("vl: separate qemu_create_machine", 2020-12-10), a function have_custom_ram_size() replaced the return value of set_memory_options().

The purpose of the return value was to record the presence of "-m size", and if it was not there, change the default RAM size to the size of the memory backend passed with "-M memory-backend".

Quoted 8 lines

With that commit, however, have_custom_ram_size() is now queried only after set_memory_options has stored the fixed-up RAM size in QemuOpts for "future use". This was actually the only future use of the fixed-up RAM size, so remove that code and fix the bug.

Fixes f5c9fcb82d ("vl: separate qemu_create_machine", 2020-12-10)
Quoted 17 lines
---
 softmmu/vl.c | 2 --
 1 file changed, 2 deletions(-)
softmmu/vl.c +0 -2
index ac0ff6e160..21e55718a6 100644
@@ -2039,8 +2039,6 @@ static void set_memory_options(MachineClass *mc)
         exit(EXIT_FAILURE);
     }
 
-    /* store value for the future use */
-    qemu_opt_set_number(opts, "size", ram_size, &error_abort);
     maxram_size = ram_size;
 
     if (qemu_opt_get(opts, "maxmem")) {