qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Amos Kong <akong@redhat.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, afaerber@suse.de, aliguori@amazon.com
Subject: [Qemu-devel] [PATCH] qdev: unparent device when fails to set properties
Date: Tue, 31 Dec 2013 16:06:57 +0800	[thread overview]
Message-ID: <1388477217-23491-1-git-send-email-akong@redhat.com> (raw)

Test steps:
  (qemu) device_add e1000,addr=adsf
  Property 'e1000.addr' doesn't take value 'adsf'
  (qemu) info qtree
Then qemu crashed.

When it fails to set properties, qdev's parent is already set, but the
object hasn't been added to parent object, object_unparent() won't
unparent the device. This patch unparents device in the mediacy.

Signed-off-by: Amos Kong <akong@redhat.com>
---
 qdev-monitor.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/qdev-monitor.c b/qdev-monitor.c
index dc37a43..3d8b4f4 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -527,7 +527,9 @@ DeviceState *qdev_device_add(QemuOpts *opts)
         dev->id = id;
     }
     if (qemu_opt_foreach(opts, set_property, dev, 1) != 0) {
-        object_unparent(OBJECT(dev));
+        if (OBJECT(dev)->class->unparent) {
+            (OBJECT(dev)->class->unparent)(OBJECT(dev));
+        }
         object_unref(OBJECT(dev));
         return NULL;
     }
-- 
1.8.4.2

             reply	other threads:[~2013-12-31  8:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-31  8:06 Amos Kong [this message]
2013-12-31  9:09 ` [Qemu-devel] [PATCH] qdev: unparent device when fails to set properties Hu Tao
2013-12-31  9:52   ` Amos Kong
2013-12-31 16:06 ` Paolo Bonzini
2014-01-02  1:02   ` Amos Kong

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=1388477217-23491-1-git-send-email-akong@redhat.com \
    --to=akong@redhat.com \
    --cc=afaerber@suse.de \
    --cc=aliguori@amazon.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).