check IOMMU group devices usage when preparing device for vfio passthrough
check IOMMU group devices usage when preparing device for vfio passthrough

The virsh start <domain> fails with qemu error when the hostdevices of the
same iommu group are used actively by other vms. It is not clear which
hostdev from the same iommu group is used by any of the running guests.
User has to go through every guest xml to figure out who is using the
hostdev of same iommu group.

Solution:
Iterate the iommu group of the hostdev and error our neatly in case a
device in the same iommu group is busy. Reattach code also does the same
kind of check, remove duplicate code as well.

Signed-off-by: Shivaprasad G Bhat <90f736271cc61454bf7410f17f3d154578105aa0@linux.vnet.ibm.com>
Signed-off-by: Michal Privoznik <83d82aaba2eed257f4814b0c239c260c4caaadf0@redhat.com>

fabianfreyer/libvirt,rlaager/libvirt,jardasgit/libvirt,elmarco/libvirt,andreabolognani/libvirt,fabianfreyer/libvirt,elmarco/libvirt,andreabolognani/libvirt,datto/libvirt,crobinso/libvirt,crobinso/libvirt,jardasgit/libvirt,zippy2/libvirt,crobinso/libvirt,rlaager/libvirt,jfehlig/libvirt,datto/libvirt,VenkatDatta/libvirt,rlaager/libvirt,zippy2/libvirt,fabianfreyer/libvirt,rlaager/libvirt,shugaoye/libvirt,andreabolognani/libvirt,eskultety/libvirt,jardasgit/libvirt,agx/libvirt,jfehlig/libvirt,datto/libvirt,fabianfreyer/libvirt,VenkatDatta/libvirt,eskultety/libvirt,elmarco/libvirt,taget/libvirt,shugaoye/libvirt,agx/libvirt,shugaoye/libvirt,olafhering/libvirt,taget/libvirt,olafhering/libvirt,eskultety/libvirt,taget/libvirt,libvirt/libvirt,datto/libvirt,nertpinx/libvirt,VenkatDatta/libvirt,nertpinx/libvirt,eskultety/libvirt,fabianfreyer/libvirt,eskultety/libvirt,elmarco/libvirt,VenkatDatta/libvirt,nertpinx/libvirt,crobinso/libvirt,elmarco/libvirt,shugaoye/libvirt,nertpinx/libvirt,shugaoye/libvirt,andreabolognani/libvirt,taget/libvirt,VenkatDatta/libvirt,agx/libvirt,olafhering/libvirt,jfehlig/libvirt,libvirt/libvirt,jardasgit/libvirt,libvirt/libvirt,jardasgit/libvirt,rlaager/libvirt,agx/libvirt,agx/libvirt,olafhering/libvirt,zippy2/libvirt,nertpinx/libvirt,jfehlig/libvirt,taget/libvirt,zippy2/libvirt,datto/libvirt,libvirt/libvirt,andreabolognani/libvirt