
On Thu, Mar 21, 2019 at 18:28:45 -0400, Laine Stump wrote:
There are separate Detach functions for PCI, USB, SCSI, Vhost, and Mediated hostdevs, but the functions are all 100% the same code, except that the PCI function checks for the guest side of the device being a PCI Multifunction device, while the other 4 check that the device's alias != NULL.
The check for multifunction PCI devices should be done for *all* devices that are connected to the PCI bus in the guest, not just PCI hostdevs, and qemuIsMultiFunctionDevice() conveniently returns false if the queried device doesn't connect with PCI, so it is safe to make this check for all hostdev devices. (It also needs to be done for many other device types, but that will be addressed in a future patch).
Likewise, since all hostdevs are detached by calling qemuDomainDeleteDevice(), which requires the device's alias, checking for a valid alias is a reasonable thing for PCI hostdevs too (NB: you'd think that we could rely on every device having a valid alias, but unfortunately when you run virsh qemu-attach on a qemu process
We also need to do something about qemu-attach ...
that was started with some "old style" device args, they don't include an "id" option on the commandline, so there is no alias in the device object that's created).
Signed-off-by: Laine Stump <laine@laine.org> --- src/qemu/qemu_hotplug.c | 129 +++++++++------------------------------- 1 file changed, 28 insertions(+), 101 deletions(-)
ACK