Message ID | 20211119113229.350338-1-philmd@redhat.com |
---|---|
State | New |
Headers | show |
Series | [PATCH-for-6.2] qom/object: Ignore global properties with empty name | expand |
On Friday, 2021-11-19 at 12:32:29 +01, Philippe Mathieu-Daudé wrote: > When using -global, properties might have empty name/value. > > This fixes this legitimate use case: > > $ qemu-system-x86_64 -global driver=isa-fdc > qemu-system-x86_64: ../../devel/qemu/qapi/string-input-visitor.c:394: > string_input_visitor_new: Assertion `str' failed. > Aborted (core dumped) > > (gdb) bt > #4 0x0000555555f6b8d5 in string_input_visitor_new (str=0x0) at qapi/string-input-visitor.c:394 > #5 0x0000555555dd0f8d in object_property_parse (obj=0x555556f33400, name=0x0, string=0x0, errp=0x7fffffffc9c8) at qom/object.c:1641 > #6 0x0000555555dce131 in object_apply_global_props (obj=0x555556f33400, props=0x555556737360, errp=0x555556611760 <error_fatal>) at qom/object.c:411 > #7 0x0000555555dc5ee2 in qdev_prop_set_globals (dev=0x555556f33400) at hw/core/qdev-properties.c:790 > #8 0x0000555555dc89e8 in device_post_init (obj=0x555556f33400) at hw/core/qdev.c:697 > #9 0x0000555555dce02b in object_post_init_with_type (obj=0x555556f33400, ti=0x55555672bd20) at qom/object.c:383 > #10 0x0000555555dce059 in object_post_init_with_type (obj=0x555556f33400, ti=0x5555566e9090) at qom/object.c:387 > #11 0x0000555555dce059 in object_post_init_with_type (obj=0x555556f33400, ti=0x5555566df730) at qom/object.c:387 > #12 0x0000555555dce566 in object_initialize_with_type (obj=0x555556f33400, size=848, type=0x5555566df730) at qom/object.c:519 > #13 0x0000555555dcec78 in object_new_with_type (type=0x5555566df730) at qom/object.c:733 > #14 0x0000555555dceccf in object_new (typename=0x5555560fcf81 "isa-fdc") at qom/object.c:748 > #15 0x0000555555dc75fe in qdev_new (name=0x5555560fcf81 "isa-fdc") at hw/core/qdev.c:153 > #16 0x00005555559eec58 in isa_new (name=0x5555560fcf81 "isa-fdc") at hw/isa/isa-bus.c:166 > #17 0x0000555555bd3607 in pc_superio_init (isa_bus=0x5555566b42e0, create_fdctrl=true, no_vmport=false) at hw/i386/pc.c:1026 > (gdb) fr 6 > #6 0x0000555555dce131 in object_apply_global_props (obj=0x555556f33400, props=0x555556737360, errp=0x555556611760 <error_fatal>) at qom/object.c:411 > 411 if (!object_property_parse(obj, p->property, p->value, &err)) { > (gdb) p *p > $1 = {driver = 0x555556738250 "isa-fdc", property = 0x0, value = 0x0, used = true, optional = false} > > Reported-by: Thomas Huth <thuth@redhat.com> > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/604 > Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Darren Kenny <darren.kenny@oracle.com> > --- > qom/object.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/qom/object.c b/qom/object.c > index 4f0677cca9e..45fa8561df6 100644 > --- a/qom/object.c > +++ b/qom/object.c > @@ -401,6 +401,9 @@ bool object_apply_global_props(Object *obj, const GPtrArray *props, > GlobalProperty *p = g_ptr_array_index(props, i); > Error *err = NULL; > > + if (!p->property) { > + continue; > + } > if (object_dynamic_cast(obj, p->driver) == NULL) { > continue; > } > -- > 2.31.1
On Fri, 19 Nov 2021 12:32:29 +0100 Philippe Mathieu-Daudé <philmd@redhat.com> wrote: > When using -global, properties might have empty name/value. > > This fixes this legitimate use case: > > $ qemu-system-x86_64 -global driver=isa-fdc > qemu-system-x86_64: ../../devel/qemu/qapi/string-input-visitor.c:394: > string_input_visitor_new: Assertion `str' failed. > Aborted (core dumped) why ignore instead of printing error message and exiting? it never worked before, and I don't see a reason to let QEMU startup fine with nonsense CLI. > > (gdb) bt > #4 0x0000555555f6b8d5 in string_input_visitor_new (str=0x0) at qapi/string-input-visitor.c:394 > #5 0x0000555555dd0f8d in object_property_parse (obj=0x555556f33400, name=0x0, string=0x0, errp=0x7fffffffc9c8) at qom/object.c:1641 > #6 0x0000555555dce131 in object_apply_global_props (obj=0x555556f33400, props=0x555556737360, errp=0x555556611760 <error_fatal>) at qom/object.c:411 > #7 0x0000555555dc5ee2 in qdev_prop_set_globals (dev=0x555556f33400) at hw/core/qdev-properties.c:790 > #8 0x0000555555dc89e8 in device_post_init (obj=0x555556f33400) at hw/core/qdev.c:697 > #9 0x0000555555dce02b in object_post_init_with_type (obj=0x555556f33400, ti=0x55555672bd20) at qom/object.c:383 > #10 0x0000555555dce059 in object_post_init_with_type (obj=0x555556f33400, ti=0x5555566e9090) at qom/object.c:387 > #11 0x0000555555dce059 in object_post_init_with_type (obj=0x555556f33400, ti=0x5555566df730) at qom/object.c:387 > #12 0x0000555555dce566 in object_initialize_with_type (obj=0x555556f33400, size=848, type=0x5555566df730) at qom/object.c:519 > #13 0x0000555555dcec78 in object_new_with_type (type=0x5555566df730) at qom/object.c:733 > #14 0x0000555555dceccf in object_new (typename=0x5555560fcf81 "isa-fdc") at qom/object.c:748 > #15 0x0000555555dc75fe in qdev_new (name=0x5555560fcf81 "isa-fdc") at hw/core/qdev.c:153 > #16 0x00005555559eec58 in isa_new (name=0x5555560fcf81 "isa-fdc") at hw/isa/isa-bus.c:166 > #17 0x0000555555bd3607 in pc_superio_init (isa_bus=0x5555566b42e0, create_fdctrl=true, no_vmport=false) at hw/i386/pc.c:1026 > (gdb) fr 6 > #6 0x0000555555dce131 in object_apply_global_props (obj=0x555556f33400, props=0x555556737360, errp=0x555556611760 <error_fatal>) at qom/object.c:411 > 411 if (!object_property_parse(obj, p->property, p->value, &err)) { > (gdb) p *p > $1 = {driver = 0x555556738250 "isa-fdc", property = 0x0, value = 0x0, used = true, optional = false} > > Reported-by: Thomas Huth <thuth@redhat.com> > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/604 > Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> > --- > qom/object.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/qom/object.c b/qom/object.c > index 4f0677cca9e..45fa8561df6 100644 > --- a/qom/object.c > +++ b/qom/object.c > @@ -401,6 +401,9 @@ bool object_apply_global_props(Object *obj, const GPtrArray *props, > GlobalProperty *p = g_ptr_array_index(props, i); > Error *err = NULL; > > + if (!p->property) { > + continue; > + } > if (object_dynamic_cast(obj, p->driver) == NULL) { > continue; > }
diff --git a/qom/object.c b/qom/object.c index 4f0677cca9e..45fa8561df6 100644 --- a/qom/object.c +++ b/qom/object.c @@ -401,6 +401,9 @@ bool object_apply_global_props(Object *obj, const GPtrArray *props, GlobalProperty *p = g_ptr_array_index(props, i); Error *err = NULL; + if (!p->property) { + continue; + } if (object_dynamic_cast(obj, p->driver) == NULL) { continue; }
When using -global, properties might have empty name/value. This fixes this legitimate use case: $ qemu-system-x86_64 -global driver=isa-fdc qemu-system-x86_64: ../../devel/qemu/qapi/string-input-visitor.c:394: string_input_visitor_new: Assertion `str' failed. Aborted (core dumped) (gdb) bt #4 0x0000555555f6b8d5 in string_input_visitor_new (str=0x0) at qapi/string-input-visitor.c:394 #5 0x0000555555dd0f8d in object_property_parse (obj=0x555556f33400, name=0x0, string=0x0, errp=0x7fffffffc9c8) at qom/object.c:1641 #6 0x0000555555dce131 in object_apply_global_props (obj=0x555556f33400, props=0x555556737360, errp=0x555556611760 <error_fatal>) at qom/object.c:411 #7 0x0000555555dc5ee2 in qdev_prop_set_globals (dev=0x555556f33400) at hw/core/qdev-properties.c:790 #8 0x0000555555dc89e8 in device_post_init (obj=0x555556f33400) at hw/core/qdev.c:697 #9 0x0000555555dce02b in object_post_init_with_type (obj=0x555556f33400, ti=0x55555672bd20) at qom/object.c:383 #10 0x0000555555dce059 in object_post_init_with_type (obj=0x555556f33400, ti=0x5555566e9090) at qom/object.c:387 #11 0x0000555555dce059 in object_post_init_with_type (obj=0x555556f33400, ti=0x5555566df730) at qom/object.c:387 #12 0x0000555555dce566 in object_initialize_with_type (obj=0x555556f33400, size=848, type=0x5555566df730) at qom/object.c:519 #13 0x0000555555dcec78 in object_new_with_type (type=0x5555566df730) at qom/object.c:733 #14 0x0000555555dceccf in object_new (typename=0x5555560fcf81 "isa-fdc") at qom/object.c:748 #15 0x0000555555dc75fe in qdev_new (name=0x5555560fcf81 "isa-fdc") at hw/core/qdev.c:153 #16 0x00005555559eec58 in isa_new (name=0x5555560fcf81 "isa-fdc") at hw/isa/isa-bus.c:166 #17 0x0000555555bd3607 in pc_superio_init (isa_bus=0x5555566b42e0, create_fdctrl=true, no_vmport=false) at hw/i386/pc.c:1026 (gdb) fr 6 #6 0x0000555555dce131 in object_apply_global_props (obj=0x555556f33400, props=0x555556737360, errp=0x555556611760 <error_fatal>) at qom/object.c:411 411 if (!object_property_parse(obj, p->property, p->value, &err)) { (gdb) p *p $1 = {driver = 0x555556738250 "isa-fdc", property = 0x0, value = 0x0, used = true, optional = false} Reported-by: Thomas Huth <thuth@redhat.com> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/604 Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> --- qom/object.c | 3 +++ 1 file changed, 3 insertions(+)