Fix the coredump when memory backend id conflicts with default_ram_id
PATCH v2 1/1 Fix the coredump when memory backend id conflicts with default_ram_id
When no memory backend is specified in machine options, a default memory device will be added with default_ram_id. However, if a memory backend object is added in QEMU options and id is the same as default_ram_id, a coredump happens.
Command line:
qemu-system-x86_64 -name guest=vmtest,debug-threads=on \
-machine pc-q35-6.0,accel=kvm,usb=off,vmport=off \
-smp 16,sockets=16,cores=1,threads=1 \
-m 4G \
-object memory-backend-ram,id=pc.ram,size=4G \
-no-user-config -nodefaults -nographic
Stack trace of thread 16903:
#0 0x00007fb109a9318b raise (libc.so.6 + 0x3a18b)
#1 0x00007fb109a94585 abort (libc.so.6 + 0x3b585)
#2 0x0000558c34bc89be error_handle_fatal (qemu-system-x86_64 + 0x9c89be)
#3 0x0000558c34bc8aee error_setv (qemu-system-x86_64 + 0x9c8aee)
#4 0x0000558c34bc8ccf error_setg_internal (qemu-system-x86_64 + 0x9c8ccf)
#5 0x0000558c349f6899 object_property_try_add (qemu-system-x86_64 + 0x7f6899)
#6 0x0000558c349f7df8 object_property_try_add_child (qemu-system-x86_64 + 0x7f7df8)
#7 0x0000558c349f7e91 object_property_add_child (qemu-system-x86_64 + 0x7f7e91)
#8 0x0000558c3454686d create_default_memdev (qemu-system-x86_64 + 0x34686d)
#9 0x0000558c34546f58 qemu_init_board (qemu-system-x86_64 + 0x346f58)
#10 0x0000558c345471b9 qmp_x_exit_preconfig (qemu-system-x86_64 + 0x3471b9)
#11 0x0000558c345497d9 qemu_init (qemu-system-x86_64 + 0x3497d9)
#12 0x0000558c344e54c2 main (qemu-system-x86_64 + 0x2e54c2)
#13 0x00007fb109a7e34d __libc_start_main (libc.so.6 + 0x2534d)
#14 0x0000558c344e53ba _start (qemu-system-x86_64 + 0x2e53ba)--- hw/core/machine.c | 8 ++++++++ 1 file changed, 8 insertions(+)
hw/core/machine.c +8 -0
@@ -1290,9 +1290,17 @@ MemoryRegion *machine_consume_memdev(MachineState *machine,static bool create_default_memdev (MachineState *ms,const char *path,Error **errp) {Object *obj; +ObjectProperty *prop;MachineClass *mc =MACHINE_GET_CLASS (ms);bool r = false; + prop =object_property_find (object_get_objects_root (), mc->default_ram_id); +if (prop) { +error_report ("Memory backend id conflicts with default_ram_id %s" , + mc->default_ram_id); +exit (EXIT_FAILURE ); + } + obj =object_new (path ?TYPE_MEMORY_BACKEND_FILE :TYPE_MEMORY_BACKEND_RAM );if (path) {if (!object_property_set_str (obj,"mem-path" , path, errp)) {
Signature · 1 line
2.34.1
Hi all,
Any comments about this patch?
Thanks a lot.
Quoted 69 lines · Li Zhang
When no memory backend is specified in machine options, a default memory device will be added with
default_ram_id. However, if a memory backend object is added in QEMU options and id is the same asdefault_ram_id, a coredump happens.Command line:
qemu-system-x86_64 -name guest=vmtest,debug-threads=on \(quoted diff) +0
-5-machine pc-q35-6.0,accel=kvm,usb=off,vmport=off \ -smp 16,sockets=16,cores=1,threads=1 \ -m 4G \ -object memory-backend-ram,id=pc.ram,size=4G \ -no-user-config -nodefaults -nographicStack trace of thread 16903:
#0 0x00007fb109a9318b raise (libc.so.6 + 0x3a18b) #1 0x00007fb109a94585 abort (libc.so.6 + 0x3b585) #2 0x0000558c34bc89be error_handle_fatal (qemu-system-x86_64 + 0x9c89be) #3 0x0000558c34bc8aee error_setv (qemu-system-x86_64 + 0x9c8aee) #4 0x0000558c34bc8ccf error_setg_internal (qemu-system-x86_64 + 0x9c8ccf) #5 0x0000558c349f6899 object_property_try_add (qemu-system-x86_64 + 0x7f6899) #6 0x0000558c349f7df8 object_property_try_add_child (qemu-system-x86_64 + 0x7f7df8) #7 0x0000558c349f7e91 object_property_add_child (qemu-system-x86_64 + 0x7f7e91) #8 0x0000558c3454686d create_default_memdev (qemu-system-x86_64 + 0x34686d) #9 0x0000558c34546f58 qemu_init_board (qemu-system-x86_64 + 0x346f58) #10 0x0000558c345471b9 qmp_x_exit_preconfig (qemu-system-x86_64 + 0x3471b9) #11 0x0000558c345497d9 qemu_init (qemu-system-x86_64 + 0x3497d9) #12 0x0000558c344e54c2 main (qemu-system-x86_64 + 0x2e54c2) #13 0x00007fb109a7e34d __libc_start_main (libc.so.6 + 0x2534d) #14 0x0000558c344e53ba _start (qemu-system-x86_64 + 0x2e53ba)Signed-off-by Li Zhang <[email protected]>--- hw/core/machine.c | 8 ++++++++ 1 file changed, 8 insertions(+)hw/core/machine.c +3
-0@@ -1290,9 +1290,17 @@ MemoryRegion *machine_consume_memdev(MachineState *machine, static bool create_default_memdev(MachineState *ms, const char *path, Error **errp) { Object *obj; + ObjectProperty *prop; MachineClass *mc = MACHINE_GET_CLASS(ms); bool r = false; + prop = object_property_find(object_get_objects_root(), mc->default_ram_id); + if (prop) { + error_report("Memory backend id conflicts with default_ram_id%s",
hw/core/machine.c +4
-0+ mc->default_ram_id); +exit (EXIT_FAILURE ); + } + obj = object_new(path ? TYPE_MEMORY_BACKEND_FILE :TYPE_MEMORY_BACKEND_RAM); if (path) { if (!object_property_set_str(obj, "mem-path", path, errp)) {
ping
Quoted 70 lines · Li Zhang
When no memory backend is specified in machine options, a default memory device will be added with
default_ram_id. However, if a memory backend object is added in QEMU options and id is the same asdefault_ram_id, a coredump happens.Command line:
qemu-system-x86_64 -name guest=vmtest,debug-threads=on \(quoted diff) +0
-5-machine pc-q35-6.0,accel=kvm,usb=off,vmport=off \ -smp 16,sockets=16,cores=1,threads=1 \ -m 4G \ -object memory-backend-ram,id=pc.ram,size=4G \ -no-user-config -nodefaults -nographicStack trace of thread 16903:
#0 0x00007fb109a9318b raise (libc.so.6 + 0x3a18b) #1 0x00007fb109a94585 abort (libc.so.6 + 0x3b585) #2 0x0000558c34bc89be error_handle_fatal (qemu-system-x86_64 + 0x9c89be) #3 0x0000558c34bc8aee error_setv (qemu-system-x86_64 + 0x9c8aee) #4 0x0000558c34bc8ccf error_setg_internal (qemu-system-x86_64 + 0x9c8ccf) #5 0x0000558c349f6899 object_property_try_add (qemu-system-x86_64 + 0x7f6899) #6 0x0000558c349f7df8 object_property_try_add_child (qemu-system-x86_64 + 0x7f7df8) #7 0x0000558c349f7e91 object_property_add_child (qemu-system-x86_64 + 0x7f7e91) #8 0x0000558c3454686d create_default_memdev (qemu-system-x86_64 + 0x34686d) #9 0x0000558c34546f58 qemu_init_board (qemu-system-x86_64 + 0x346f58) #10 0x0000558c345471b9 qmp_x_exit_preconfig (qemu-system-x86_64 + 0x3471b9) #11 0x0000558c345497d9 qemu_init (qemu-system-x86_64 + 0x3497d9) #12 0x0000558c344e54c2 main (qemu-system-x86_64 + 0x2e54c2) #13 0x00007fb109a7e34d __libc_start_main (libc.so.6 + 0x2534d) #14 0x0000558c344e53ba _start (qemu-system-x86_64 + 0x2e53ba)Signed-off-by Li Zhang <[email protected]>--- hw/core/machine.c | 8 ++++++++ 1 file changed, 8 insertions(+)hw/core/machine.c +4
-0@@ -1290,9 +1290,17 @@ MemoryRegion *machine_consume_memdev(MachineState *machine, static bool create_default_memdev(MachineState *ms, const char *path, Error **errp) { Object *obj; + ObjectProperty *prop; MachineClass *mc = MACHINE_GET_CLASS(ms); bool r = false; + prop = object_property_find(object_get_objects_root(), mc->default_ram_id); + if (prop) { + error_report("Memory backend id conflicts with default_ram_id%s",
hw/core/machine.c +4
-0+ mc->default_ram_id); +exit (EXIT_FAILURE ); + } + obj = object_new(path ? TYPE_MEMORY_BACKEND_FILE :TYPE_MEMORY_BACKEND_RAM); if (path) { if (!object_property_set_str(obj, "mem-path", path, errp)) {
Cc'ing Igor
Quoted 61 lines · Li Zhang
When no memory backend is specified in machine options, a default memory device will be added with
default_ram_id. However, if a memory backend object is added in QEMU options and id is the same asdefault_ram_id, a coredump happens.Command line:
qemu-system-x86_64 -name guest=vmtest,debug-threads=on \(quoted diff) +0
-5-machine pc-q35-6.0,accel=kvm,usb=off,vmport=off \ -smp 16,sockets=16,cores=1,threads=1 \ -m 4G \ -object memory-backend-ram,id=pc.ram,size=4G \ -no-user-config -nodefaults -nographicStack trace of thread 16903:
#0 0x00007fb109a9318b raise (libc.so.6 + 0x3a18b) #1 0x00007fb109a94585 abort (libc.so.6 + 0x3b585) #2 0x0000558c34bc89be error_handle_fatal (qemu-system-x86_64 + 0x9c89be) #3 0x0000558c34bc8aee error_setv (qemu-system-x86_64 + 0x9c8aee) #4 0x0000558c34bc8ccf error_setg_internal (qemu-system-x86_64 + 0x9c8ccf) #5 0x0000558c349f6899 object_property_try_add (qemu-system-x86_64 + 0x7f6899) #6 0x0000558c349f7df8 object_property_try_add_child (qemu-system-x86_64 + 0x7f7df8) #7 0x0000558c349f7e91 object_property_add_child (qemu-system-x86_64 + 0x7f7e91) #8 0x0000558c3454686d create_default_memdev (qemu-system-x86_64 + 0x34686d) #9 0x0000558c34546f58 qemu_init_board (qemu-system-x86_64 + 0x346f58) #10 0x0000558c345471b9 qmp_x_exit_preconfig (qemu-system-x86_64 + 0x3471b9) #11 0x0000558c345497d9 qemu_init (qemu-system-x86_64 + 0x3497d9) #12 0x0000558c344e54c2 main (qemu-system-x86_64 + 0x2e54c2) #13 0x00007fb109a7e34d __libc_start_main (libc.so.6 + 0x2534d) #14 0x0000558c344e53ba _start (qemu-system-x86_64 + 0x2e53ba)Signed-off-by Li Zhang <[email protected]>--- hw/core/machine.c | 8 ++++++++ 1 file changed, 8 insertions(+)hw/core/machine.c +8
-1@@ -1290,9 +1290,17 @@ MemoryRegion *machine_consume_memdev(MachineState *machine,static bool create_default_memdev (MachineState *ms,const char *path,Error **errp) {Object *obj; +ObjectProperty *prop;MachineClass *mc =MACHINE_GET_CLASS (ms);bool r = false; + prop =object_property_find (object_get_objects_root (), mc->default_ram_id); +if (prop) { +error_report ("Memory backend id conflicts with default_ram_id %s" , + mc->default_ram_id); +exit (EXIT_FAILURE ); + } + obj =object_new (path ?TYPE_MEMORY_BACKEND_FILE :TYPE_MEMORY_BACKEND_RAM );if (path) {if (!object_property_set_str (obj,"mem-path" , path, errp)) { --2.34.1
Thanks Philippe.
Hi Igor,
Any comments about this patch?
Quoted 66 lines · Philippe Mathieu-Daudé via
Cc'ing Igor
Quoted 61 lines · Li Zhang
When no memory backend is specified in machine options, a default memory device will be added with
default_ram_id. However, if a memory backend object is added in QEMU options and id is the same asdefault_ram_id, a coredump happens.Command line:
qemu-system-x86_64 -name guest=vmtest,debug-threads=on \(quoted diff) +0
-5-machine pc-q35-6.0,accel=kvm,usb=off,vmport=off \ -smp 16,sockets=16,cores=1,threads=1 \ -m 4G \ -object memory-backend-ram,id=pc.ram,size=4G \ -no-user-config -nodefaults -nographicStack trace of thread 16903:
#0 0x00007fb109a9318b raise (libc.so.6 + 0x3a18b) #1 0x00007fb109a94585 abort (libc.so.6 + 0x3b585) #2 0x0000558c34bc89be error_handle_fatal (qemu-system-x86_64 + 0x9c89be) #3 0x0000558c34bc8aee error_setv (qemu-system-x86_64 + 0x9c8aee) #4 0x0000558c34bc8ccf error_setg_internal (qemu-system-x86_64 + 0x9c8ccf) #5 0x0000558c349f6899 object_property_try_add (qemu-system-x86_64 + 0x7f6899) #6 0x0000558c349f7df8 object_property_try_add_child (qemu-system-x86_64 + 0x7f7df8) #7 0x0000558c349f7e91 object_property_add_child (qemu-system-x86_64 + 0x7f7e91) #8 0x0000558c3454686d create_default_memdev (qemu-system-x86_64 + 0x34686d) #9 0x0000558c34546f58 qemu_init_board (qemu-system-x86_64 + 0x346f58) #10 0x0000558c345471b9 qmp_x_exit_preconfig (qemu-system-x86_64 + 0x3471b9) #11 0x0000558c345497d9 qemu_init (qemu-system-x86_64 + 0x3497d9) #12 0x0000558c344e54c2 main (qemu-system-x86_64 + 0x2e54c2) #13 0x00007fb109a7e34d __libc_start_main (libc.so.6 + 0x2534d) #14 0x0000558c344e53ba _start (qemu-system-x86_64 + 0x2e53ba)Signed-off-by Li Zhang <[email protected]>--- hw/core/machine.c | 8 ++++++++ 1 file changed, 8 insertions(+)hw/core/machine.c +8
-1@@ -1290,9 +1290,17 @@ MemoryRegion *machine_consume_memdev(MachineState *machine,static bool create_default_memdev (MachineState *ms,const char *path,Error **errp) {Object *obj; +ObjectProperty *prop;MachineClass *mc =MACHINE_GET_CLASS (ms);bool r = false; + prop =object_property_find (object_get_objects_root (), mc->default_ram_id); +if (prop) { +error_report ("Memory backend id conflicts with default_ram_id %s" , + mc->default_ram_id); +exit (EXIT_FAILURE ); + } + obj =object_new (path ?TYPE_MEMORY_BACKEND_FILE :TYPE_MEMORY_BACKEND_RAM );if (path) {if (!object_property_set_str (obj,"mem-path" , path, errp)) { --2.34.1
Signature · 2 lines
Best Regards -Li
Quoted 41 lines · On Fri, 20 May 2022 11:56:02 +0200 Li Zhang <[email protected]> wrote:
When no memory backend is specified in machine options, a default memory device will be added with
default_ram_id. However, if a memory backend object is added in QEMU options and id is the same asdefault_ram_id, a coredump happens.Command line:
qemu-system-x86_64 -name guest=vmtest,debug-threads=on \(quoted diff) +0
-5-machine pc-q35-6.0,accel=kvm,usb=off,vmport=off \ -smp 16,sockets=16,cores=1,threads=1 \ -m 4G \ -object memory-backend-ram,id=pc.ram,size=4G \ -no-user-config -nodefaults -nographicStack trace of thread 16903:
#0 0x00007fb109a9318b raise (libc.so.6 + 0x3a18b) #1 0x00007fb109a94585 abort (libc.so.6 + 0x3b585) #2 0x0000558c34bc89be error_handle_fatal (qemu-system-x86_64 + 0x9c89be) #3 0x0000558c34bc8aee error_setv (qemu-system-x86_64 + 0x9c8aee) #4 0x0000558c34bc8ccf error_setg_internal (qemu-system-x86_64 + 0x9c8ccf) #5 0x0000558c349f6899 object_property_try_add (qemu-system-x86_64 + 0x7f6899) #6 0x0000558c349f7df8 object_property_try_add_child (qemu-system-x86_64 + 0x7f7df8) #7 0x0000558c349f7e91 object_property_add_child (qemu-system-x86_64 + 0x7f7e91) #8 0x0000558c3454686d create_default_memdev (qemu-system-x86_64 + 0x34686d) #9 0x0000558c34546f58 qemu_init_board (qemu-system-x86_64 + 0x346f58) #10 0x0000558c345471b9 qmp_x_exit_preconfig (qemu-system-x86_64 + 0x3471b9) #11 0x0000558c345497d9 qemu_init (qemu-system-x86_64 + 0x3497d9) #12 0x0000558c344e54c2 main (qemu-system-x86_64 + 0x2e54c2) #13 0x00007fb109a7e34d __libc_start_main (libc.so.6 + 0x2534d) #14 0x0000558c344e53ba _start (qemu-system-x86_64 + 0x2e53ba)Signed-off-by Li Zhang <[email protected]>--- hw/core/machine.c | 8 ++++++++ 1 file changed, 8 insertions(+)hw/core/machine.c +0
-0@@ -1290,9 +1290,17 @@ MemoryRegion *machine_consume_memdev(MachineState *machine,static bool create_default_memdev (MachineState *ms,const char *path,Error **errp)
hw/core/machine.c MemoryRegion *machine_consume_memdev(MachineState *machine, · line 1300
Quoted 10 lines
hw/core/machine.c +5
-0{Object *obj; +ObjectProperty *prop;MachineClass *mc =MACHINE_GET_CLASS (ms);bool r = false; + prop =object_property_find (object_get_objects_root (), mc->default_ram_id); +if (prop) { +error_report ("Memory backend id conflicts with default_ram_id %s" , + mc->default_ram_id);
maybe something like this would be better:
A memory backend with id '%s' already exists, cannot create default RAM backend with the same id. Either change id of the offending backend or provide system RAM backend explicitly using '-machine memory-backend' option.
Quoted 6 lines
hw/core/machine.c +3
-0+exit (EXIT_FAILURE ); + } + obj =object_new (path ?TYPE_MEMORY_BACKEND_FILE :TYPE_MEMORY_BACKEND_RAM );if (path) {if (!object_property_set_str (obj,"mem-path" , path, errp)) {
Quoted 51 lines · Igor Mammedov
Quoted 47 lines · On Fri, 20 May 2022 11:56:02 +0200 Li Zhang <[email protected]> wrote:
When no memory backend is specified in machine options, a default memory device will be added with
default_ram_id. However, if a memory backend object is added in QEMU options and id is the same asdefault_ram_id, a coredump happens.Command line:
qemu-system-x86_64 -name guest=vmtest,debug-threads=on \(quoted diff) +0
-5-machine pc-q35-6.0,accel=kvm,usb=off,vmport=off \ -smp 16,sockets=16,cores=1,threads=1 \ -m 4G \ -object memory-backend-ram,id=pc.ram,size=4G \ -no-user-config -nodefaults -nographicStack trace of thread 16903:
#0 0x00007fb109a9318b raise (libc.so.6 + 0x3a18b) #1 0x00007fb109a94585 abort (libc.so.6 + 0x3b585) #2 0x0000558c34bc89be error_handle_fatal (qemu-system-x86_64 + 0x9c89be) #3 0x0000558c34bc8aee error_setv (qemu-system-x86_64 + 0x9c8aee) #4 0x0000558c34bc8ccf error_setg_internal (qemu-system-x86_64 + 0x9c8ccf) #5 0x0000558c349f6899 object_property_try_add (qemu-system-x86_64 + 0x7f6899) #6 0x0000558c349f7df8 object_property_try_add_child (qemu-system-x86_64 + 0x7f7df8) #7 0x0000558c349f7e91 object_property_add_child (qemu-system-x86_64 + 0x7f7e91) #8 0x0000558c3454686d create_default_memdev (qemu-system-x86_64 + 0x34686d) #9 0x0000558c34546f58 qemu_init_board (qemu-system-x86_64 + 0x346f58) #10 0x0000558c345471b9 qmp_x_exit_preconfig (qemu-system-x86_64 + 0x3471b9) #11 0x0000558c345497d9 qemu_init (qemu-system-x86_64 + 0x3497d9) #12 0x0000558c344e54c2 main (qemu-system-x86_64 + 0x2e54c2) #13 0x00007fb109a7e34d __libc_start_main (libc.so.6 + 0x2534d) #14 0x0000558c344e53ba _start (qemu-system-x86_64 + 0x2e53ba)Signed-off-by Li Zhang <[email protected]>--- hw/core/machine.c | 8 ++++++++ 1 file changed, 8 insertions(+)hw/core/machine.c +1
-0@@ -1290,9 +1290,17 @@ MemoryRegion *machine_consume_memdev(MachineState *machine,static bool create_default_memdev (MachineState *ms,const char *path,Error **errp) {Object *obj; +ObjectProperty *prop;MachineClass *mc =MACHINE_GET_CLASS (ms);bool r = false;
Quoted 10 lines
hw/core/machine.c MemoryRegion *machine_consume_memdev(MachineState *machine, · line 1300
Quoted 4 lines
hw/core/machine.c +4
-0+ prop =object_property_find (object_get_objects_root (), mc->default_ram_id); +if (prop) { +error_report ("Memory backend id conflicts with default_ram_id %s" , + mc->default_ram_id);maybe something like this would be better:
A memory backend with id '%s' already exists, cannot create default RAM backend with the same id. Either change id of the offending backend or provide system RAM backend explicitly using '-machine memory-backend' option.
Thanks, I will modify it.
Quoted 9 lines
Quoted 7 lines
hw/core/machine.c +3
-0+exit (EXIT_FAILURE ); + } + obj =object_new (path ?TYPE_MEMORY_BACKEND_FILE :TYPE_MEMORY_BACKEND_RAM );if (path) {if (!object_property_set_str (obj,"mem-path" , path, errp)) {
Signature · 2 lines
Best Regards -Li