qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] qdev: Fix qdev_try_create() for bus-less device


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH] qdev: Fix qdev_try_create() for bus-less devices
Date: Wed, 05 Feb 2014 17:38:45 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

Il 05/02/2014 15:09, Andreas Färber ha scritto:
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 82a9123..14c8765 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -131,21 +131,27 @@ DeviceState *qdev_create(BusState *bus, const char *name)
 DeviceState *qdev_try_create(BusState *bus, const char *type)
 {
     DeviceState *dev;
+    ObjectClass *oc;
+    DeviceClass *dc;

-    if (object_class_by_name(type) == NULL) {
+    oc = object_class_by_name(type);
+    if (oc == NULL) {
         return NULL;
     }
+    dc = DEVICE_CLASS(oc);
     dev = DEVICE(object_new(type));
     if (!dev) {
         return NULL;
     }

-    if (!bus) {
+    if (!bus && dc->bus_type && strcmp(dc->bus_type, "System") == 0) {

Should you check instead if dev is-a TYPE_SYSBUS_DEVICE?

Does this also leave the nand device out of info qtree, or is it still dumped?

Paolo

         bus = sysbus_get_default();
     }

-    qdev_set_parent_bus(dev, bus);
-    object_unref(OBJECT(dev));
+    if (bus != NULL) {
+        qdev_set_parent_bus(dev, bus);
+        object_unref(OBJECT(dev));
+    }
     return dev;
 }






reply via email to

[Prev in Thread] Current Thread [Next in Thread]