virhostdev.c: virHostdevGetPCIHostDevice() now reports missing device
virhostdev.c: virHostdevGetPCIHostDevice() now reports missing device

Gitlab issue #72 [1] reports that removing SR-IOVs VFs before
removing the devices from the running domains can have strange
consequences. QEMU might be able to hotunplug the device inside the
guest, but Libvirt will not be aware of that, and then the guest is
now inconsistent with the domain definition.

There's also the possibility of the VFs removal not succeeding
while the domain is running but then, as soon as the domain
is shutdown, all the VFs are removed. Libvirt can't handle
the removal of the PCI devices while trying to reattach the
hostdevs, and the Libvirt daemon can be left in an inconsistent
state (see [2]).

This patch starts to address the issue related in Gitlab #72, most
notably the issue described in [2]. When shutting down a domain
with SR-IOV hostdevs that got missing, virHostdevReAttachPCIDevices()
is failing the whole process and failing to reattach all the
PCI devices, including the ones that aren't related to the VFs that
went missing. Let's make it more resilient with host changes by
changing virHostdevGetPCIHostDevice() to return an exclusive error
code '-2' for this case. virHostdevGetPCIHostDeviceList() can then
tell when virHostdevGetPCIHostDevice() failed to find the PCI
device of a hostdev and continue to make the list of PCI devices.

virHostdevReAttachPCIDevices() will now be able to proceed reattaching
all other valid PCI devices, at least. The 'ghost hostdevs' will be
handled later on.

[1] https://gitlab.com/libvirt/libvirt/-/issues/72
[2] https://gitlab.com/libvirt/libvirt/-/issues/72#note_459032148

Reviewed-by: Laine Stump <c23361c43fbf79fed83e8b76173707b083d6caf5@redhat.com>
Signed-off-by: Daniel Henrique Barboza <627b089ad62deae9aaf06ccfa2c9056df28927e0@gmail.com>

crobinso/libvirt,libvirt/libvirt,nertpinx/libvirt,jfehlig/libvirt,jfehlig/libvirt,libvirt/libvirt,olafhering/libvirt,zippy2/libvirt,libvirt/libvirt,nertpinx/libvirt,zippy2/libvirt,crobinso/libvirt,nertpinx/libvirt,zippy2/libvirt,crobinso/libvirt,nertpinx/libvirt,olafhering/libvirt,jfehlig/libvirt,olafhering/libvirt,olafhering/libvirt,zippy2/libvirt,crobinso/libvirt,jfehlig/libvirt,nertpinx/libvirt,libvirt/libvirt