[PATCH v3 2/5] conf: add PCI controllers

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

 



Add new controller type 'pci' with models 'pci-root' and 'pci-bridge'.
---
 docs/formatdomain.html.in     | 22 +++++++++++++++++++++-
 docs/schemas/domaincommon.rng | 12 ++++++++++++
 src/conf/domain_conf.c        | 21 ++++++++++++++++++++-
 src/conf/domain_conf.h        |  9 +++++++++
 4 files changed, 62 insertions(+), 2 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 888c005..4a700f9 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2124,7 +2124,7 @@
     <p>
       Each controller has a mandatory attribute <code>type</code>,
       which must be one of "ide", "fdc", "scsi", "sata", "usb",
-      "ccid", or "virtio-serial", and a mandatory
+      "ccid", "virtio-serial" or "pci", and a mandatory
       attribute <code>index</code> which is the decimal integer
       describing in which order the bus controller is encountered (for
       use in <code>controller</code> attributes
@@ -2177,6 +2177,26 @@
   &lt;/devices&gt;
   ...</pre>
 
+    <p>
+      PCI controllers have an optional <code>model</code> attribute with
+      possible values <code>pci-root</code> or <code>pci-bridge</code>.
+      For machine types which provide an implicit pci bus, the pci-root
+      controller with index=0 is auto-added and required to use PCI devices.
+      PCI root has no address.
+      PCI bridges are auto-added if there are too many devices to fit on
+      the one bus provided by pci-root, or a PCI bus number greater than zero
+      was specified. (<span class="since">since 1.0.5</span>)
+    </p>
+<pre>
+  ...
+  &lt;devices&gt;
+    &lt;controller type='pci' index='0' model='pci-root'/&gt;
+    &lt;controller type='pci' index='1' model='pci-bridge'&gt;
+      &lt;address type='pci' domain='0' bus='0' slot='5' function='0' multifunction=off'/&gt;
+    &lt;/controller&gt;
+  &lt;/devices&gt;
+  ...</pre>
+
     <h4><a name="elementsLease">Device leases</a></h4>
 
     <p>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 3976b82..cf91c2d 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1475,6 +1475,18 @@
               <ref name="usbmaster"/>
             </optional>
           </group>
+          <!-- pci has an optional attribute "model" -->
+          <group>
+            <attribute name="type">
+              <value>pci</value>
+            </attribute>
+            <attribute name="model">
+              <choice>
+                <value>pci-root</value>
+                <value>pci-bridge</value>
+              </choice>
+            </attribute>
+          </group>
           <!-- virtio-serial has optional "ports" and "vectors" -->
           <group>
             <attribute name="type">
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 8d57256..1e7de52 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -300,7 +300,12 @@ VIR_ENUM_IMPL(virDomainController, VIR_DOMAIN_CONTROLLER_TYPE_LAST,
               "sata",
               "virtio-serial",
               "ccid",
-              "usb")
+              "usb",
+              "pci")
+
+VIR_ENUM_IMPL(virDomainControllerModelPCI, VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST,
+              "pci-root",
+              "pci-bridge")
 
 VIR_ENUM_IMPL(virDomainControllerModelSCSI, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST,
               "auto",
@@ -5144,6 +5149,8 @@ virDomainControllerModelTypeFromString(const virDomainControllerDefPtr def,
         return virDomainControllerModelSCSITypeFromString(model);
     else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_USB)
         return virDomainControllerModelUSBTypeFromString(model);
+    else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI)
+        return virDomainControllerModelPCITypeFromString(model);
 
     return -1;
 }
@@ -5261,6 +5268,16 @@ virDomainControllerDefParseXML(xmlNodePtr node,
         }
         break;
     }
+    case VIR_DOMAIN_CONTROLLER_TYPE_PCI:
+        switch (def->model) {
+        case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT:
+            if (def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
+                virReportError(VIR_ERR_XML_ERROR, "%s",
+                               _("pci-root controller should not "
+                                 "have an address"));
+                goto error;
+            }
+        }
 
     default:
         break;
@@ -13488,6 +13505,8 @@ virDomainControllerModelTypeToString(virDomainControllerDefPtr def,
         return virDomainControllerModelSCSITypeToString(model);
     else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_USB)
         return virDomainControllerModelUSBTypeToString(model);
+    else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI)
+        return virDomainControllerModelPCITypeToString(model);
 
     return NULL;
 }
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 89515de..3cb626b 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -696,11 +696,19 @@ enum virDomainControllerType {
     VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL,
     VIR_DOMAIN_CONTROLLER_TYPE_CCID,
     VIR_DOMAIN_CONTROLLER_TYPE_USB,
+    VIR_DOMAIN_CONTROLLER_TYPE_PCI,
 
     VIR_DOMAIN_CONTROLLER_TYPE_LAST
 };
 
 
+enum virDomainControllerModelPCI {
+    VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT,
+    VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE,
+
+    VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST
+};
+
 enum virDomainControllerModelSCSI {
     VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO,
     VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC,
@@ -2425,6 +2433,7 @@ VIR_ENUM_DECL(virDomainIoEventFd)
 VIR_ENUM_DECL(virDomainVirtioEventIdx)
 VIR_ENUM_DECL(virDomainDiskCopyOnRead)
 VIR_ENUM_DECL(virDomainController)
+VIR_ENUM_DECL(virDomainControllerModelPCI)
 VIR_ENUM_DECL(virDomainControllerModelSCSI)
 VIR_ENUM_DECL(virDomainControllerModelUSB)
 VIR_ENUM_DECL(virDomainFS)
-- 
1.8.1.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[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]