]> git.proxmox.com Git - mirror_qemu.git/commitdiff
bus: do not unref hotplug handler
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 7 Feb 2017 09:57:26 +0000 (09:57 +0000)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Wed, 1 Mar 2017 07:51:28 +0000 (11:51 +0400)
Apparently, none of the bus owner give a reference to the hotplug
handler property, do not unref it on bus release.

Furthermore, a bus is allowed to be its own hotplug handler, which can
be seen in qbus_set_bus_hotplug_handler() function. However, in this
case, the reference can't be given to the property, or this will create
a cyclic dependency and the bus will never be free.

Each bus owner should manage the lifecycle of the hotplug handler.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
hw/acpi/piix4.c
hw/core/bus.c

index 6d99fe407c61f17fd9ea6fcc8712911bdd4521ba..a553a7e11096c28e941091ee98c1013b0dcd81d0 100644 (file)
@@ -440,6 +440,8 @@ static void piix4_update_bus_hotplug(PCIBus *pci_bus, void *opaque)
 {
     PIIX4PMState *s = opaque;
 
+    /* pci_bus cannot outlive PIIX4PMState, because /machine keeps it alive
+     * and it's not hot-unpluggable */
     qbus_set_hotplug_handler(BUS(pci_bus), DEVICE(s), &error_abort);
 }
 
index cf383fc1afb60065bdbd109bf377bbf2d9bddcf7..4651f244864c309018ee4d1179e59fca6985e471 100644 (file)
@@ -197,7 +197,7 @@ static void qbus_initfn(Object *obj)
                              TYPE_HOTPLUG_HANDLER,
                              (Object **)&bus->hotplug_handler,
                              object_property_allow_set_link,
-                             OBJ_PROP_LINK_UNREF_ON_RELEASE,
+                             0,
                              NULL);
     object_property_add_bool(obj, "realized",
                              bus_get_realized, bus_set_realized, NULL);