All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/1] Fix the coredump when memory backend id conflicts with default_ram_id
@ 2022-05-20  9:56 Li Zhang
  2022-05-24  9:14 ` lizhang
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Li Zhang @ 2022-05-20  9:56 UTC (permalink / raw)
  To: eduardo, marcel.apfelbaum, f4bug, wangyanan55, qemu-devel; +Cc: 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 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)

Signed-off-by: Li Zhang <lizhang@suse.de>
---
 hw/core/machine.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index b03d9192ba..3867af7a8a 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -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



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/1] Fix the coredump when memory backend id conflicts with default_ram_id
  2022-05-20  9:56 [PATCH v2 1/1] Fix the coredump when memory backend id conflicts with default_ram_id Li Zhang
@ 2022-05-24  9:14 ` lizhang
  2022-06-01 11:13 ` lizhang
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: lizhang @ 2022-05-24  9:14 UTC (permalink / raw)
  To: eduardo, marcel.apfelbaum, f4bug, wangyanan55, qemu-devel

Hi all,

Any comments about this patch?

Thanks a lot.

On 5/20/22 11:56, Li Zhang 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 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)
> 
> Signed-off-by: Li Zhang <lizhang@suse.de>
> ---
>   hw/core/machine.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index b03d9192ba..3867af7a8a 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -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)) {



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/1] Fix the coredump when memory backend id conflicts with default_ram_id
  2022-05-20  9:56 [PATCH v2 1/1] Fix the coredump when memory backend id conflicts with default_ram_id Li Zhang
  2022-05-24  9:14 ` lizhang
@ 2022-06-01 11:13 ` lizhang
  2022-06-01 12:25 ` Philippe Mathieu-Daudé via
  2022-06-09 15:05 ` Igor Mammedov
  3 siblings, 0 replies; 7+ messages in thread
From: lizhang @ 2022-06-01 11:13 UTC (permalink / raw)
  To: eduardo, marcel.apfelbaum, f4bug, wangyanan55, qemu-devel


ping

On 2022-05-20 11:56, Li Zhang 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 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)
> 
> Signed-off-by: Li Zhang <lizhang@suse.de>
> ---
>  hw/core/machine.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index b03d9192ba..3867af7a8a 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -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)) {


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/1] Fix the coredump when memory backend id conflicts with default_ram_id
  2022-05-20  9:56 [PATCH v2 1/1] Fix the coredump when memory backend id conflicts with default_ram_id Li Zhang
  2022-05-24  9:14 ` lizhang
  2022-06-01 11:13 ` lizhang
@ 2022-06-01 12:25 ` Philippe Mathieu-Daudé via
  2022-06-07  8:41   ` Li Zhang
  2022-06-09 15:05 ` Igor Mammedov
  3 siblings, 1 reply; 7+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-06-01 12:25 UTC (permalink / raw)
  To: Li Zhang
  Cc: Eduardo Habkost, Marcel Apfelbaum, Yanan Wang,
	qemu-devel@nongnu.org Developers, Igor Mammedov

Cc'ing Igor

On Fri, May 20, 2022 at 11:56 AM Li Zhang <lizhang@suse.de> 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 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)
>
> Signed-off-by: Li Zhang <lizhang@suse.de>
> ---
>  hw/core/machine.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index b03d9192ba..3867af7a8a 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -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
>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/1] Fix the coredump when memory backend id conflicts with default_ram_id
  2022-06-01 12:25 ` Philippe Mathieu-Daudé via
@ 2022-06-07  8:41   ` Li Zhang
  0 siblings, 0 replies; 7+ messages in thread
From: Li Zhang @ 2022-06-07  8:41 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Igor Mammedov
  Cc: Li Zhang, Eduardo Habkost, Marcel Apfelbaum, Yanan Wang,
	qemu-devel@nongnu.org Developers

Thanks Philippe.

Hi Igor,
Any comments about this patch?

On Wed, Jun 1, 2022 at 2:28 PM Philippe Mathieu-Daudé via
<qemu-devel@nongnu.org> wrote:
>
> Cc'ing Igor
>
> On Fri, May 20, 2022 at 11:56 AM Li Zhang <lizhang@suse.de> 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 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)
> >
> > Signed-off-by: Li Zhang <lizhang@suse.de>
> > ---
> >  hw/core/machine.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/hw/core/machine.c b/hw/core/machine.c
> > index b03d9192ba..3867af7a8a 100644
> > --- a/hw/core/machine.c
> > +++ b/hw/core/machine.c
> > @@ -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
> >
>


-- 

Best Regards
-Li


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/1] Fix the coredump when memory backend id conflicts with default_ram_id
  2022-05-20  9:56 [PATCH v2 1/1] Fix the coredump when memory backend id conflicts with default_ram_id Li Zhang
                   ` (2 preceding siblings ...)
  2022-06-01 12:25 ` Philippe Mathieu-Daudé via
@ 2022-06-09 15:05 ` Igor Mammedov
  2022-06-13  9:03   ` Li Zhang
  3 siblings, 1 reply; 7+ messages in thread
From: Igor Mammedov @ 2022-06-09 15:05 UTC (permalink / raw)
  To: Li Zhang; +Cc: eduardo, marcel.apfelbaum, f4bug, wangyanan55, qemu-devel

On Fri, 20 May 2022 11:56:02 +0200
Li Zhang <lizhang@suse.de> 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 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)
> 
> Signed-off-by: Li Zhang <lizhang@suse.de>
> ---
>  hw/core/machine.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index b03d9192ba..3867af7a8a 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -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);

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.
 

> +        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)) {



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/1] Fix the coredump when memory backend id conflicts with default_ram_id
  2022-06-09 15:05 ` Igor Mammedov
@ 2022-06-13  9:03   ` Li Zhang
  0 siblings, 0 replies; 7+ messages in thread
From: Li Zhang @ 2022-06-13  9:03 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Li Zhang, Eduardo Habkost, Marcel Apfelbaum,
	Philippe Mathieu-Daudé,
	Yanan Wang, QEMU

On Thu, Jun 9, 2022 at 5:59 PM Igor Mammedov <imammedo@redhat.com> wrote:
>
> On Fri, 20 May 2022 11:56:02 +0200
> Li Zhang <lizhang@suse.de> 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 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)
> >
> > Signed-off-by: Li Zhang <lizhang@suse.de>
> > ---
> >  hw/core/machine.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/hw/core/machine.c b/hw/core/machine.c
> > index b03d9192ba..3867af7a8a 100644
> > --- a/hw/core/machine.c
> > +++ b/hw/core/machine.c
> > @@ -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);
>
> 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.

>
> > +        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)) {
>
>


-- 

Best Regards
-Li


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-06-13  9:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-20  9:56 [PATCH v2 1/1] Fix the coredump when memory backend id conflicts with default_ram_id Li Zhang
2022-05-24  9:14 ` lizhang
2022-06-01 11:13 ` lizhang
2022-06-01 12:25 ` Philippe Mathieu-Daudé via
2022-06-07  8:41   ` Li Zhang
2022-06-09 15:05 ` Igor Mammedov
2022-06-13  9:03   ` Li Zhang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.