QOM splits the destruction of a device in two phases: - unrealize, also known as "exit" from qdev times, should isolate the device from the guest. After unrealize returns, the guest should not be able to issue new requests.
- instance_finalize will reclaim the memory. This is only called after all requests terminate and drop the references on the device. This is important even now, but overlooked. It will become much more important for devices that will be able to access memory out of the big QEMU lock. This series changes all PCI devices (the sole to support hotplug _and_ use MemoryRegions) to do memory_region_del_subregion at unrealize time, and memory_region_destroy at instance_finalize time. This is mostly a PCI patch, and independent from the others, so I believe it should go through mst's tree. Paolo Paolo Bonzini (39): scsi: keep device alive while it has requests dma: keep a device alive while it has SGLists pci: split exit and finalize ac97: use instance_finalize instead of exit es1370: use instance_finalize instead of exit hda: use instance_finalize instead of exit serial: use instance_finalize instead of exit tpci200: use instance_finalize instead of exit pci-assign: use instance_finalize instead of exit ahci: use instance_finalize instead of exit msix: split msix_free from msix_uninit cmd646: use instance_finalize instead of exit ide/piix: use instance_finalize instead of exit ide/via: use instance_finalize instead of exit ivshmem: use instance_finalize instead of exit pci-testdev: use instance_finalize instead of exit vfio: use instance_finalize instead of exit e1000: use instance_finalize instead of exit eepro100: use instance_finalize instead of exit ne2000: use instance_finalize instead of exit pcnet: use instance_finalize instead of exit rtl8139: use instance_finalize instead of exit vmxnet3: use instance_finalize instead of exit shpc: use instance_finalize instead of exit pci_bridge: split pci_bridge_exitfn from pci_bridge_free pcie_aer: pcie_aer_exit really frees stuff pci_bridge: use instance_finalize instead of exit ioh4320: use instance_finalize instead of exit xio3130-downstream: use instance_finalize instead of exit xio3130-upstream: use instance_finalize instead of exit pcie: do not recreate mmcfg I/O region, use an alias instead esp: use instance_finalize instead of exit lsi: use instance_finalize instead of exit pvscsi: use instance_finalize instead of exit usb-uhci: use instance_finalize instead of exit virtio-pci: use instance_finalize instead of exit wdt_i6300esb: use instance_finalize instead of exit xen_pt: use instance_finalize instead of exit tpm: move add/del_subregion to realize/unrealize dma-helpers.c | 6 ++++- hw/audio/ac97.c | 5 ++-- hw/audio/es1370.c | 5 ++-- hw/audio/intel-hda.c | 8 ++++++ hw/char/serial-pci.c | 24 ++++++++++++++++++ hw/char/tpci200.c | 5 ++-- hw/i386/kvm/pci-assign.c | 8 ++++++ hw/ide/ahci.c | 5 ++-- hw/ide/ahci.h | 2 +- hw/ide/cmd646.c | 5 ++-- hw/ide/ich.c | 13 +++++++--- hw/ide/macio.c | 4 +-- hw/ide/piix.c | 8 +++--- hw/ide/via.c | 5 ++-- hw/misc/ivshmem.c | 10 +++++++- hw/misc/pci-testdev.c | 5 ++-- hw/misc/vfio.c | 52 +++++++++++++++++++++++++++++++++++--- hw/net/e1000.c | 5 ++-- hw/net/eepro100.c | 5 ++-- hw/net/ne2000.c | 5 ++-- hw/net/pcnet-pci.c | 5 ++-- hw/net/rtl8139.c | 5 ++-- hw/net/vmxnet3.c | 14 ++++++++-- hw/pci-bridge/i82801b11.c | 1 + hw/pci-bridge/ioh3420.c | 11 +++++++- hw/pci-bridge/pci_bridge_dev.c | 14 +++++++++- hw/pci-bridge/xio3130_downstream.c | 11 +++++++- hw/pci-bridge/xio3130_upstream.c | 11 +++++++- hw/pci/msix.c | 26 ++++++++++++++----- hw/pci/pci.c | 15 ++++++++--- hw/pci/pci_bridge.c | 5 ++++ hw/pci/pcie_aer.c | 3 ++- hw/pci/pcie_host.c | 22 ++++++++++++---- hw/pci/shpc.c | 8 +++++- hw/scsi/esp-pci.c | 5 ++-- hw/scsi/lsi53c895a.c | 5 ++-- hw/scsi/megasas.c | 4 +-- hw/scsi/scsi-bus.c | 4 +++ hw/scsi/virtio-scsi.c | 10 +++++--- hw/scsi/vmw_pvscsi.c | 12 ++++++++- hw/tpm/tpm_tis.c | 14 +++++++--- hw/usb/hcd-ehci.c | 4 +-- hw/usb/hcd-uhci.c | 5 ++-- hw/virtio/virtio-pci.c | 10 +++++++- hw/watchdog/wdt_i6300esb.c | 5 ++-- hw/xen/xen_pt.c | 10 ++++++++ hw/xen/xen_pt_config_init.c | 3 --- hw/xen/xen_pt_msi.c | 8 +++++- include/hw/pci/msix.h | 1 + include/hw/pci/pci.h | 2 +- include/hw/pci/pci_bridge.h | 1 + include/hw/pci/pcie_aer.h | 2 +- include/hw/pci/pcie_host.h | 1 + include/hw/pci/shpc.h | 1 + include/sysemu/dma.h | 4 ++- 55 files changed, 355 insertions(+), 92 deletions(-) -- 1.8.1.4