spapr_pci: fix multifunction hotplug
commit788d2599def0e26d92802593b07ec76e8701ccce
authorMichael Roth <mdroth@linux.vnet.ibm.com>
Thu, 3 Mar 2016 21:55:36 +0000 (3 15:55 -0600)
committerDavid Gibson <david@gibson.dropbear.id.au>
Tue, 15 Mar 2016 22:55:05 +0000 (16 09:55 +1100)
tree42072966de1f24b90a9c62a94b001541f9b78734
parenta88dced8eb69730df39cb04bb3e262e5b98d5f5c
spapr_pci: fix multifunction hotplug

Since 3f1e147, QEMU has adopted a convention of supporting function
hotplug by deferring hotplug events until func 0 is hotplugged.
This is likely how management tools like libvirt would expose
such support going forward.

Since sPAPR guests rely on per-func events rather than
slot-based, our protocol has been to hotplug func 0 *first* to
avoid cases where devices appear within guests without func 0
present to avoid undefined behavior.

To remain compatible with new convention, defer hotplug in a
similar manner, but then generate events in 0-first order as we
did in the past. Once func 0 present, fail any attempts to plug
additional functions (as we do with PCIe).

For unplug, defer unplug operations in a similar manner, but
generate unplug events such that function 0 is removed last in guest.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
hw/ppc/spapr_pci.c