qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: [PATCH-for-6.2] qom/object: Ignore global properties with empty name
Date: Fri, 19 Nov 2021 12:32:29 +0100	[thread overview]
Message-ID: <20211119113229.350338-1-philmd@redhat.com> (raw)

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

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



             reply	other threads:[~2021-11-19 11:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-19 11:32 Philippe Mathieu-Daudé [this message]
2021-11-22 11:19 ` [PATCH-for-6.2] qom/object: Ignore global properties with empty name Darren Kenny
2021-11-24  8:46 ` Igor Mammedov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211119113229.350338-1-philmd@redhat.com \
    --to=philmd@redhat.com \
    --cc=berrange@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).