On Fri, 2015-10-30 at 04:57 +0530, Shivaprasad G Bhat wrote: > It is incorrect to attempt the device reattach of a function, > when some other domain is using some functions belonging to the same iommu > group. > > Signed-off-by: Shivaprasad G Bhat <sbhat@xxxxxxxxxxxxxxxxxx> > --- > src/util/virhostdev.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c > index de029a0..91f28e9 100644 > --- a/src/util/virhostdev.c > +++ b/src/util/virhostdev.c > @@ -1590,6 +1590,7 @@ virHostdevPCINodeDeviceReAttach(virHostdevManagerPtr hostdev_mgr, > virPCIDevicePtr pci) > { > virPCIDeviceAddressPtr devAddr = NULL; > + bool usesVfio = STREQ_NULLABLE(virPCIDeviceGetStubDriver(pci), "vfio-pci"); > struct virHostdevIsPCINodeDeviceUsedData data = {hostdev_mgr, NULL, > false}; > int ret = -1; > @@ -1600,8 +1601,16 @@ virHostdevPCINodeDeviceReAttach(virHostdevManagerPtr hostdev_mgr, > if (!(devAddr = virPCIDeviceGetAddress(pci))) > goto out; > > - if (virHostdevIsPCINodeDeviceUsed(devAddr, &data)) > + if (usesVfio) { > + /* Doesn't matter which function. If any domain is actively using the > + iommu group, refuse to reattach */ Please indent this comment properly. The second line should start with * as well. > + if (virPCIDeviceAddressIOMMUGroupIterate(devAddr, > + virHostdevIsPCINodeDeviceUsed, > + &data) < 0) > + goto out; > + } else if (virHostdevIsPCINodeDeviceUsed(devAddr, &data)) { > goto out; > + } > > virPCIDeviceReattachInit(pci); Cheers. -- Andrea Bolognani Software Engineer - Virtualization Team -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list