]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix device assignment with root devices
authorChris Lalancette <clalance@redhat.com>
Tue, 19 Jan 2010 16:26:54 +0000 (11:26 -0500)
committerChris Lalancette <clalance@redhat.com>
Fri, 22 Jan 2010 14:42:45 +0000 (09:42 -0500)
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 <clalance@redhat.com>
src/util/pci.c

index 086b751235deffdcdf6ec6f564d247cbf6f56d28..0defbfed869c1d7d0f6e82b8fe422059243d3350 100644 (file)
@@ -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