Series is replacement for a more simple attempt to generalize hotplug API http://lists.gnu.org/archive/html/qemu-devel/2013-11/msg02529.html promted by Paolo in this patch review. --
Refactor PCI specific hotplug API to a more generic/reusable one. Model it after SCSI-BUS like hotplug API replacing single hotplug callback with hotplug/hot_unplug pair of callbacks as suggested by Paolo. Difference between SCSI-BUS and this approach is that the former is BUS centric while the latter is device centred. Which is evolved from the fact that hotplug callbacks used by ACPI/SHPC/PCIE are implemented by devices rather than by bus and bus serves only as a proxy to forward event to hotplug device. Memory hotplug also exposes tha same usage pattern hence an attempt to generalize hotplug API. Refactoring also simplifies wiring of a hotplug device with a bus, all it needs is to set "hotplug-device" link on bus, which would potentially allow to do it from configuration file, there is not need to setup hotplug device callbacks on bus synce it can get them via HOTPLUG_DEVICE API of "hotplug-device" target. In addition device centred hotplug API may be used by bus-less hotplug implementations as well if it's decided to use link<foo...> instead of bus. Patches 4-7 are should be merged as one and are split only for simplifying review (they compile fine but PCI hotplug is broken until the last patch applyed). git tree for testing: https://github.com/imammedo/qemu/commits/hotplug_dev_inf_v1 tested only ACPI hotplug with following HMP commands: == netdev_add user,id=n1 device_add e1000,id=e1,netdev=n1 device_del e1 == Igor Mammedov (7): define hotplug interface qdev: add to BusState "hotplug-device" link hw/acpi: move typeinfo to the file end acpi/piix4pm: convert ACPI PCI hotplug to use hotplug-device interface pci/shpc: convert SHPC hotplug to use hotplug-device interface pci/pcie: convert PCIE hotplug to use hotplug-device interface hw/pci: convert PCI bus to use "hotplug-device" interface. hw/acpi/piix4.c | 143 +++++++++++++++++++++------------------- hw/core/Makefile.objs | 1 + hw/core/hotplug.c | 25 +++++++ hw/core/qdev.c | 4 + hw/pci-bridge/pci_bridge_dev.c | 9 +++ hw/pci/pci.c | 70 ++++++++++++++----- hw/pci/pcie.c | 73 +++++++++++++------- hw/pci/pcie_port.c | 8 ++ hw/pci/shpc.c | 132 ++++++++++++++++++++++++------------- include/hw/hotplug.h | 50 ++++++++++++++ include/hw/pci/pci.h | 10 --- include/hw/pci/pci_bus.h | 2 - include/hw/pci/pcie.h | 4 + include/hw/pci/shpc.h | 7 ++ include/hw/qdev-core.h | 4 + 15 files changed, 372 insertions(+), 170 deletions(-) create mode 100644 hw/core/hotplug.c create mode 100644 include/hw/hotplug.h