[libvirt PATCH v2 02/17] conf: Introduce VIR_PCI_CONNECT_INTEGRATED

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This new flag can be used to convince the PCI address assignment
algorithm to place a device directly on the root bus. It will be
used to implement support for virtio-iommu, which needs to be an
integrated device in order to work correctly.

Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 src/conf/domain_addr.c | 17 +++++++++++++++++
 src/conf/domain_addr.h | 26 +++++++++++++++-----------
 2 files changed, 32 insertions(+), 11 deletions(-)

diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 49ca775a52..1173143635 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -303,6 +303,23 @@ virDomainPCIAddressFlagsCompatible(virPCIDeviceAddress *addr,
     virErrorNumber errType = (fromConfig
                               ? VIR_ERR_XML_ERROR : VIR_ERR_INTERNAL_ERROR);
 
+    if (devFlags & VIR_PCI_CONNECT_INTEGRATED) {
+        if (addr->bus == 0) {
+            /* pcie-root doesn't usually allow endpoint devices to be
+             * plugged directly into it, but for integrated devices
+             * that's exactly what we want */
+            busFlags |= VIR_PCI_CONNECT_AUTOASSIGN;
+        } else {
+            if (reportError) {
+                virReportError(errType,
+                               _("The device at PCI address %s needs to be "
+                                 "an integrated device (bus=0)"),
+                               addrStr);
+            }
+            return false;
+        }
+    }
+
     if (fromConfig) {
         /* If the requested connection was manually specified in
          * config, allow a PCI device to connect to a PCIe slot, or
diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
index 814b556024..1772ea7088 100644
--- a/src/conf/domain_addr.h
+++ b/src/conf/domain_addr.h
@@ -35,24 +35,28 @@ typedef enum {
     VIR_PCI_CONNECT_AUTOASSIGN = 1 << 0, /* okay to autoassign a device to this controller */
     VIR_PCI_CONNECT_HOTPLUGGABLE = 1 << 1, /* is hotplug needed/supported */
 
+    /* Set for devices that can only work as integrated devices (directly
+     * connected to pci.0 or pcie.0, with no additional buses in between) */
+    VIR_PCI_CONNECT_INTEGRATED = 1 << 2,
+
     /* set for devices that can share a single slot in auto-assignment
      * (by assigning one device to each of the 8 functions on the slot)
      */
-    VIR_PCI_CONNECT_AGGREGATE_SLOT = 1 << 2,
+    VIR_PCI_CONNECT_AGGREGATE_SLOT = 1 << 3,
 
     /* kinds of devices as a bitmap so they can be combined (some PCI
      * controllers permit connecting multiple types of devices)
      */
-    VIR_PCI_CONNECT_TYPE_PCI_DEVICE = 1 << 3,
-    VIR_PCI_CONNECT_TYPE_PCIE_DEVICE = 1 << 4,
-    VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT = 1 << 5,
-    VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT = 1 << 6,
-    VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_DOWNSTREAM_PORT = 1 << 7,
-    VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE = 1 << 8,
-    VIR_PCI_CONNECT_TYPE_PCI_EXPANDER_BUS = 1 << 9,
-    VIR_PCI_CONNECT_TYPE_PCIE_EXPANDER_BUS = 1 << 10,
-    VIR_PCI_CONNECT_TYPE_PCI_BRIDGE = 1 << 11,
-    VIR_PCI_CONNECT_TYPE_PCIE_TO_PCI_BRIDGE = 1 << 12,
+    VIR_PCI_CONNECT_TYPE_PCI_DEVICE = 1 << 4,
+    VIR_PCI_CONNECT_TYPE_PCIE_DEVICE = 1 << 5,
+    VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT = 1 << 6,
+    VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT = 1 << 7,
+    VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_DOWNSTREAM_PORT = 1 << 8,
+    VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE = 1 << 9,
+    VIR_PCI_CONNECT_TYPE_PCI_EXPANDER_BUS = 1 << 10,
+    VIR_PCI_CONNECT_TYPE_PCIE_EXPANDER_BUS = 1 << 11,
+    VIR_PCI_CONNECT_TYPE_PCI_BRIDGE = 1 << 12,
+    VIR_PCI_CONNECT_TYPE_PCIE_TO_PCI_BRIDGE = 1 << 13,
 } virDomainPCIConnectFlags;
 
 /* a combination of all bits that describe the type of connections
-- 
2.35.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux