qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qdev: unparent device when fails to set properties
@ 2013-12-31  8:06 Amos Kong
  2013-12-31  9:09 ` Hu Tao
  2013-12-31 16:06 ` Paolo Bonzini
  0 siblings, 2 replies; 5+ messages in thread
From: Amos Kong @ 2013-12-31  8:06 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, afaerber, aliguori

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

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

end of thread, other threads:[~2014-01-02  1:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-31  8:06 [Qemu-devel] [PATCH] qdev: unparent device when fails to set properties Amos Kong
2013-12-31  9:09 ` Hu Tao
2013-12-31  9:52   ` Amos Kong
2013-12-31 16:06 ` Paolo Bonzini
2014-01-02  1:02   ` Amos Kong

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).