[libvirt] [PATCH 06/13] conf: new pci controller model "pcie-root-port"

Laine Stump laine at laine.org
Mon Jun 22 18:44:11 UTC 2015


This controller can be connected (at domain startup time only - not
hotpluggable) only to a port on the pcie root complex ("pcie-root" in
libvirt config), hence the new connect type
VIR_PCI_CONNECT_TYPE_PCIE_ROOT. It provides a hotpluggable port that
will accept any PCI or PCIe device.
---
 docs/formatdomain.html.in                          | 16 +++++++++--
 docs/schemas/domaincommon.rng                      |  1 +
 src/conf/domain_addr.c                             | 10 +++++--
 src/conf/domain_addr.h                             |  5 +++-
 src/conf/domain_conf.c                             |  3 +-
 src/conf/domain_conf.h                             |  1 +
 .../qemuxml2argv-pcie-root-port.xml                | 33 ++++++++++++++++++++++
 tests/qemuxml2xmltest.c                            |  1 +
 8 files changed, 64 insertions(+), 6 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcie-root-port.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index fb3e2fb..e6c140a 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2997,10 +2997,11 @@
     <p>
       PCI controllers have an optional <code>model</code> attribute with
       possible values <code>pci-root</code>, <code>pcie-root</code>,
-      <code>pci-bridge</code>, or <code>dmi-to-pci-bridge</code>.
+      <code>pcie-root-port</code>, <code>pci-bridge</code>,
+      or <code>dmi-to-pci-bridge</code>.
       (pci-root and pci-bridge <span class="since">since 1.0.5</span>,
       pcie-root and dmi-to-pci-bridge <span class="since">since
-      1.1.2</span>)
+      1.1.2</span>, pcie-root-port <span class="since">since 1.2.17</span>)
       The root controllers (<code>pci-root</code> and <code>pcie-root</code>)
       have an optional <code>pcihole64</code> element specifying how big
       (in kilobytes, or in the unit specified by <code>pcihole64</code>'s
@@ -3054,6 +3055,17 @@
       auto-determined by libvirt will be placed on this pci-bridge
       device.  (<span class="since">since 1.1.2</span>).
     </p>
+    <p>
+      Domains with an implicit pcie-root can also add controllers
+      with <code>model='pcie-root-port'</code>. This is a simple type of
+      bridge device that can connect only to one of the 31 slots on
+      the pcie-root bus on its upstream side, and makes a single
+      (PCIe, hotpluggable) port (at slot='0') available on the
+      downstream side. This controller can be used to provide a single
+      slot to later hotplug a PCIe device (but is not itself
+      hotpluggable - it must be in the configuration when the domain
+      is started). (<span class="since">since 1.2.17</span>)
+    </p>
 <pre>
   ...
   <devices>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index f0f7400..6139dfb 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1751,6 +1751,7 @@
                   <choice>
                     <value>pci-bridge</value>
                     <value>dmi-to-pci-bridge</value>
+                    <value>pcie-root-port</value>
                   </choice>
                 </attribute>
               </group>
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 2be98c5..4b5e81e 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -183,9 +183,9 @@ virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPtr bus,
     case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
         /* slots 1 - 31, no hotplug, PCIe only unless the address was
          * specified in user config *and* the particular device being
-         * attached also allows it
+         * attached also allows it.
          */
-        bus->flags = VIR_PCI_CONNECT_TYPE_PCIE;
+        bus->flags = VIR_PCI_CONNECT_TYPE_PCIE | VIR_PCI_CONNECT_TYPE_PCIE_ROOT;
         bus->minSlot = 1;
         bus->maxSlot = VIR_PCI_ADDRESS_SLOT_LAST;
         break;
@@ -196,6 +196,12 @@ virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPtr bus,
         bus->minSlot = 1;
         bus->maxSlot = VIR_PCI_ADDRESS_SLOT_LAST;
         break;
+    case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT:
+        /* provides one slot which is pcie and hotpluggable */
+        bus->flags = VIR_PCI_CONNECT_TYPE_PCIE | VIR_PCI_CONNECT_HOTPLUGGABLE;
+        bus->minSlot = 1;
+        bus->maxSlot = 1;
+        break;
     default:
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Invalid PCI controller model %d"), model);
diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
index dcfd2e5..2a0ff96 100644
--- a/src/conf/domain_addr.h
+++ b/src/conf/domain_addr.h
@@ -39,6 +39,8 @@ typedef enum {
    /* PCI devices can connect to this bus */
    VIR_PCI_CONNECT_TYPE_PCIE    = 1 << 3,
    /* PCI Express devices can connect to this bus */
+   VIR_PCI_CONNECT_TYPE_PCIE_ROOT = 1 << 4,
+   /* for devices that can only connect to pcie-root (i.e. root-port) */
 } virDomainPCIConnectFlags;
 
 typedef struct {
@@ -70,7 +72,8 @@ typedef virDomainPCIAddressSet *virDomainPCIAddressSetPtr;
  * allowed, e.g. PCI, PCIe, switch
  */
 # define VIR_PCI_CONNECT_TYPES_MASK \
-   (VIR_PCI_CONNECT_TYPE_PCI | VIR_PCI_CONNECT_TYPE_PCIE)
+   (VIR_PCI_CONNECT_TYPE_PCI | VIR_PCI_CONNECT_TYPE_PCIE | \
+    VIR_PCI_CONNECT_TYPE_PCIE_ROOT)
 
 /* combination of all bits that could be used to connect a normal
  * endpoint device (i.e. excluding the connection possible between an
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ca55981..0bdd51e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -323,7 +323,8 @@ VIR_ENUM_IMPL(virDomainControllerModelPCI, VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST,
               "pci-root",
               "pcie-root",
               "pci-bridge",
-              "dmi-to-pci-bridge")
+              "dmi-to-pci-bridge",
+              "pcie-root-port")
 
 VIR_ENUM_IMPL(virDomainControllerModelSCSI, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST,
               "auto",
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index ba17a8d..946210e 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -752,6 +752,7 @@ typedef enum {
     VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT,
     VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE,
     VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE,
+    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT,
 
     VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST
 } virDomainControllerModelPCI;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pcie-root-port.xml b/tests/qemuxml2argvdata/qemuxml2argv-pcie-root-port.xml
new file mode 100644
index 0000000..a1fc354
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pcie-root-port.xml
@@ -0,0 +1,33 @@
+<domain type='qemu'>
+  <name>q35-test</name>
+  <uuid>11dbdcdd-4c3b-482b-8903-9bdb8c0a2774</uuid>
+  <memory unit='KiB'>2097152</memory>
+  <currentMemory unit='KiB'>2097152</currentMemory>
+  <vcpu placement='static' cpuset='0-1'>2</vcpu>
+  <os>
+    <type arch='x86_64' machine='q35'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/libexec/qemu-kvm</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='sda' bus='sata'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='pci' index='0' model='pcie-root'/>
+    <controller type='pci' index='1' model='dmi-to-pci-bridge'/>
+    <controller type='pci' index='2' model='pci-bridge'/>
+    <controller type='pci' index='3' model='pcie-root-port'/>
+    <controller type='pci' index='4' model='pcie-root-port'/>
+    <controller type='sata' index='0'/>
+    <video>
+      <model type='qxl' ram='65536' vram='32768' vgamem='8192' heads='1'/>
+    </video>
+    <memballoon model='none'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 44b388c..2acbae1 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -566,6 +566,7 @@ mymain(void)
     DO_TEST_DIFFERENT("pci-autoadd-idx");
     DO_TEST_DIFFERENT("pcie-root");
     DO_TEST_DIFFERENT("q35");
+    DO_TEST("pcie-root-port");
 
     DO_TEST("hostdev-scsi-lsi");
     DO_TEST("hostdev-scsi-virtio-scsi");
-- 
2.1.0




More information about the libvir-list mailing list