]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Parse and format <target index='...'/>
authorAndrea Bolognani <abologna@redhat.com>
Wed, 22 Feb 2017 10:42:19 +0000 (11:42 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Sat, 15 Jul 2017 12:50:42 +0000 (14:50 +0200)
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
docs/formatdomain.html.in
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/conf/domain_conf.h

index 7f4bc1d21274f3fe405357a995187d75f8bbf48b..01c6fce23c6739dfda5d75d52f10ec37f37b998e 100644 (file)
         libvirt API to attach host devices to the correct
         pci-expander-bus when assigning them to the domain).
       </dd>
+      <dt><code>index</code></dt>
+      <dd>
+        pci-root controllers for pSeries guests use this attribute to
+        record the order they will show up in the guest.
+        <span class="since">Since 3.6.0</span>
+      </dd>
     </dl>
     <p>
       For machine types which provide an implicit PCI bus, the pci-root
index 2532f56acb49b9ea36589f35cbc4c3b4c9dc5917..fc1a40f96f1a72d7a5aad8159cc917eb208f79e2 100644 (file)
                     <ref name='uint8'/>
                   </attribute>
                 </optional>
+                <optional>
+                  <attribute name='index'>
+                    <ref name='uint8'/>
+                  </attribute>
+                </optional>
                 <optional>
                   <element name='node'>
                     <ref name='unsignedInt'/>
index ecc45cc48fc46a52367f38db0b2813facc9b1235..5dd1824701953b5ea5aba64a2cd75c45f54659ff 100644 (file)
@@ -1872,6 +1872,7 @@ virDomainControllerDefNew(virDomainControllerType type)
         def->opts.pciopts.chassis = -1;
         def->opts.pciopts.port = -1;
         def->opts.pciopts.busNr = -1;
+        def->opts.pciopts.targetIndex = -1;
         def->opts.pciopts.numaNode = -1;
         break;
     case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
@@ -9109,6 +9110,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
     char *chassis = NULL;
     char *port = NULL;
     char *busNr = NULL;
+    char *targetIndex = NULL;
     int numaNode = -1;
     char *ioeventfd = NULL;
     char *portsStr = NULL;
@@ -9181,6 +9183,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
                 chassis = virXMLPropString(cur, "chassis");
                 port = virXMLPropString(cur, "port");
                 busNr = virXMLPropString(cur, "busNr");
+                targetIndex = virXMLPropString(cur, "index");
                 processedTarget = true;
             }
         }
@@ -9399,6 +9402,30 @@ virDomainControllerDefParseXML(xmlNodePtr node,
                 goto error;
             }
         }
+        if (targetIndex) {
+            if (virStrToLong_i(targetIndex, NULL, 0,
+                               &def->opts.pciopts.targetIndex) < 0) {
+                virReportError(VIR_ERR_XML_ERROR,
+                               _("Invalid target index '%s' in PCI controller"),
+                               targetIndex);
+                goto error;
+            }
+            if (def->opts.pciopts.targetIndex < 0 ||
+                def->opts.pciopts.targetIndex > 31) {
+                virReportError(VIR_ERR_XML_ERROR,
+                               _("PCI controller target index '%s' out of "
+                                 "range - must be 0-31"),
+                               targetIndex);
+                goto error;
+            }
+            if ((def->idx == 0 && def->opts.pciopts.targetIndex != 0) ||
+                (def->idx != 0 && def->opts.pciopts.targetIndex == 0)) {
+                virReportError(VIR_ERR_XML_ERROR, "%s",
+                               _("Only the PCI controller with index 0 can "
+                                 "have target index 0, and vice versa"));
+                goto error;
+            }
+        }
         if (numaNode >= 0)
             def->opts.pciopts.numaNode = numaNode;
         break;
@@ -9420,6 +9447,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
     VIR_FREE(chassis);
     VIR_FREE(port);
     VIR_FREE(busNr);
+    VIR_FREE(targetIndex);
     VIR_FREE(ioeventfd);
     VIR_FREE(portsStr);
     VIR_FREE(iothread);
@@ -21873,6 +21901,7 @@ virDomainControllerDefFormat(virBufferPtr buf,
             def->opts.pciopts.chassis != -1 ||
             def->opts.pciopts.port != -1 ||
             def->opts.pciopts.busNr != -1 ||
+            def->opts.pciopts.targetIndex != -1 ||
             def->opts.pciopts.numaNode != -1) {
             virBufferAddLit(&childBuf, "<target");
             if (def->opts.pciopts.chassisNr != -1)
@@ -21887,6 +21916,9 @@ virDomainControllerDefFormat(virBufferPtr buf,
             if (def->opts.pciopts.busNr != -1)
                 virBufferAsprintf(&childBuf, " busNr='%d'",
                                   def->opts.pciopts.busNr);
+            if (def->opts.pciopts.targetIndex != -1)
+                virBufferAsprintf(&childBuf, " index='%d'",
+                                  def->opts.pciopts.targetIndex);
             if (def->opts.pciopts.numaNode == -1) {
                 virBufferAddLit(&childBuf, "/>\n");
             } else {
index 3d56d4836c09ec05bab0edc83e443089eabbf892..6e3608f24ba3a9fa680c750b0915b6272423086f 100644 (file)
@@ -786,6 +786,7 @@ struct _virDomainPCIControllerOpts {
     int chassis;
     int port;
     int busNr; /* used by pci-expander-bus, -1 == unspecified */
+    int targetIndex; /* used by spapr-pci-host-bridge, -1 == unspecified */
     /* numaNode is a *subelement* of target (to match existing
      * item in memory target config) -1 == unspecified
      */