]> git.proxmox.com Git - mirror_qemu.git/commitdiff
Access BusState::allow_hotplug using wraper qbus_is_hotpluggable()
authorIgor Mammedov <imammedo@redhat.com>
Fri, 26 Sep 2014 09:28:17 +0000 (09:28 +0000)
committerAndreas Färber <afaerber@suse.de>
Wed, 15 Oct 2014 03:03:13 +0000 (05:03 +0200)
It would allow to transparently switch detection whether Bus
is hotpluggable from allow_hotplug field to hotplug_handler
link and to drop allow_hotplug field once all users are
converted to hotplug handler API.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
hw/core/qdev.c
hw/i386/acpi-build.c
hw/pci/pci-hotplug-old.c
include/hw/qdev-core.h
qdev-monitor.c

index 2b42d5b58c275eb166216729d08df8002b9fe64f..df9700328983c145bae4d73e50982fe92306eef2 100644 (file)
@@ -86,7 +86,7 @@ static void bus_add_child(BusState *bus, DeviceState *child)
     BusChild *kid = g_malloc0(sizeof(*kid));
 
     if (qdev_hotplug) {
-        assert(bus->allow_hotplug);
+        assert(qbus_is_hotpluggable(bus));
     }
 
     kid->index = bus->max_index++;
@@ -213,7 +213,7 @@ void qdev_unplug(DeviceState *dev, Error **errp)
 {
     DeviceClass *dc = DEVICE_GET_CLASS(dev);
 
-    if (dev->parent_bus && !dev->parent_bus->allow_hotplug) {
+    if (dev->parent_bus && !qbus_is_hotpluggable(dev->parent_bus)) {
         error_set(errp, QERR_BUS_NO_HOTPLUG, dev->parent_bus->name);
         return;
     }
@@ -948,7 +948,7 @@ static bool device_get_hotpluggable(Object *obj, Error **errp)
     DeviceState *dev = DEVICE(obj);
 
     return dc->hotpluggable && (dev->parent_bus == NULL ||
-                                dev->parent_bus->allow_hotplug);
+                                qbus_is_hotpluggable(dev->parent_bus));
 }
 
 static bool device_get_hotplugged(Object *obj, Error **err)
index a3133211a89c4bd95246cc001841261bd7da1bc7..00be4bb12a6e31d844bfffab0d5b67c2143fb838 100644 (file)
@@ -774,7 +774,7 @@ static void *acpi_set_bsel(PCIBus *bus, void *opaque)
     unsigned *bsel_alloc = opaque;
     unsigned *bus_bsel;
 
-    if (bus->qbus.allow_hotplug) {
+    if (qbus_is_hotpluggable(BUS(bus))) {
         bus_bsel = g_malloc(sizeof *bus_bsel);
 
         *bus_bsel = (*bsel_alloc)++;
index d87c469096aef44fc86df8b83b5357304b2cb544..6ab28b703cfe6e6f056b21cfec22f19c6ca6fc02 100644 (file)
@@ -77,7 +77,7 @@ static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon,
         monitor_printf(mon, "Invalid PCI device address %s\n", devaddr);
         return NULL;
     }
-    if (!((BusState*)bus)->allow_hotplug) {
+    if (!qbus_is_hotpluggable(BUS(bus))) {
         monitor_printf(mon, "PCI bus doesn't support hotplug\n");
         return NULL;
     }
@@ -227,7 +227,7 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,
         monitor_printf(mon, "Invalid PCI device address %s\n", devaddr);
         return NULL;
     }
-    if (!((BusState*)bus)->allow_hotplug) {
+    if (!qbus_is_hotpluggable(BUS(bus))) {
         monitor_printf(mon, "PCI bus doesn't support hotplug\n");
         return NULL;
     }
index 178fee2ef69b07380b2c7b4012f3689f76af34b2..48a96d28ff61d25029eabc658a2390e1ac4a6231 100644 (file)
@@ -368,4 +368,9 @@ static inline void qbus_set_hotplug_handler(BusState *bus, DeviceState *handler,
                              QDEV_HOTPLUG_HANDLER_PROPERTY, errp);
     bus->allow_hotplug = 1;
 }
+
+static inline bool qbus_is_hotpluggable(BusState *bus)
+{
+   return bus->allow_hotplug || bus->hotplug_handler;
+}
 #endif
index 5ec66067f523bc75ba71d726a393ce0379f134d5..f6db4614763c6b3a9bd585b4a9cb897928d383d7 100644 (file)
@@ -515,7 +515,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)
             return NULL;
         }
     }
-    if (qdev_hotplug && bus && !bus->allow_hotplug) {
+    if (qdev_hotplug && bus && !qbus_is_hotpluggable(bus)) {
         qerror_report(QERR_BUS_NO_HOTPLUG, bus->name);
         return NULL;
     }