From: Chris Lalancette Date: Tue, 19 Jan 2010 16:26:54 +0000 (-0500) Subject: Fix device assignment with root devices X-Git-Tag: v0.7.6~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=654dd2902d44ca2e7d2d162543680f94d1a00fda;p=thirdparty%2Flibvirt.git Fix device assignment with root devices The patches to add ACS checking to PCI device passthrough introduced a bug. With the current code, if you try to passthrough a device on the root bus (i.e. bus 0), then it denies the passthrough. This is because the code in pciDeviceIsBehindSwitchLackingACS() to check for a parent device doesn't take into account the possibility of the root bus. If we are on the root bus, it means we legitimately can't find a parent, and it also means that we don't have to worry about whether ACS is enabled. Therefore return 0 (indicating we don't lack ACS) from pciDeviceIsBehindSwitchLackingACS(). Signed-off-by: Chris Lalancette --- diff --git a/src/util/pci.c b/src/util/pci.c index 086b751235..0defbfed86 100644 --- a/src/util/pci.c +++ b/src/util/pci.c @@ -1198,11 +1198,20 @@ pciDeviceIsBehindSwitchLackingACS(virConnectPtr conn, { pciDevice *parent; - if (!(parent = pciGetParentDevice(conn, dev))) { - pciReportError(conn, VIR_ERR_NO_SUPPORT, - _("Failed to find parent device for %s"), - dev->name); - return -1; + parent = pciGetParentDevice(conn, dev); + if (!parent) { + /* if we have no parent, and this is the root bus, ACS doesn't come + * into play since devices on the root bus can't P2P without going + * through the root IOMMU. + */ + if (dev->bus == 0) + return 0; + else { + pciReportError(conn, VIR_ERR_NO_SUPPORT, + _("Failed to find parent device for %s"), + dev->name); + return -1; + } } /* XXX we should rather fail when we can't find device's parent and