[PATCH v3 13/29] conf: parse and format <target chip-id='...'/>

Daniel Henrique Barboza danielhb413 at gmail.com
Wed Feb 23 13:19:36 UTC 2022


The 'chip-id' attribute indicates which chip/socket that owns the
PowerNV pcie-root controller.

Reviewed-by: Ján Tomko <jtomko at redhat.com>
Reviewed-by: Peter Krempa <pkrempa at redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413 at gmail.com>
---
 docs/formatdomain.rst         |  6 ++++++
 docs/schemas/domaincommon.rng |  5 +++++
 src/conf/domain_conf.c        | 15 +++++++++++++++
 src/conf/domain_conf.h        |  1 +
 4 files changed, 27 insertions(+)

diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index 9202cd3107..4693c22707 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -3897,6 +3897,12 @@ generated by libvirt. :since:`Since 1.2.19 (QEMU only).`
 ``index``
    pci-root controllers for pSeries guests use this attribute to record the
    order they will show up in the guest. :since:`Since 3.6.0`
+``chip-id``
+   pcie-root controllers for ``powernv`` domains use this attribute to indicate
+   the chip that will own the controller. A chip is equivalent to a CPU socket.
+   E.g. a ``powernv`` domain with ``<topology> sockets=3`` will have 3 chips.
+   chip-id=0 refers to the first chip, chip-id=1 refers to the second chip and
+   so on. :since:`Since 8.1.0`
 
 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
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index f472055700..d85290a164 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2655,6 +2655,11 @@
                     <ref name="unsignedInt"/>
                   </element>
                 </optional>
+                <optional>
+                  <attribute name="chip-id">
+                    <ref name="uint8"/>
+                  </attribute>
+                </optional>
               </element>
             </optional>
             <!-- *-root controllers have an optional element "pcihole64"-->
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 955bb36d9f..44327e2abb 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2385,6 +2385,7 @@ virDomainControllerDefNew(virDomainControllerType type)
         def->opts.pciopts.busNr = -1;
         def->opts.pciopts.targetIndex = -1;
         def->opts.pciopts.numaNode = -1;
+        def->opts.pciopts.chipId = -1;
         break;
     case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS:
         def->opts.xenbusopts.maxGrantFrames = -1;
@@ -9605,6 +9606,16 @@ virDomainControllerDefParseXML(virDomainXMLOption *xmlopt,
                 virReportError(VIR_ERR_XML_ERROR,
                                _("Invalid target index '%i' in PCI controller"),
                                def->opts.pciopts.targetIndex);
+
+            if ((rc = virXMLPropInt(targetNodes[0], "chip-id", 0, VIR_XML_PROP_NONE,
+                                    &def->opts.pciopts.chipId,
+                                    def->opts.pciopts.chipId)) < 0)
+                return NULL;
+
+            if ((rc == 1) && def->opts.pciopts.chipId == -1)
+                virReportError(VIR_ERR_XML_ERROR,
+                               _("Invalid target chip-id '%i' in PCI controller"),
+                               def->opts.pciopts.chipId);
         }
     } else if (ntargetNodes > 1) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -23843,6 +23854,7 @@ virDomainControllerDefFormat(virBuffer *buf,
             def->opts.pciopts.busNr != -1 ||
             def->opts.pciopts.targetIndex != -1 ||
             def->opts.pciopts.numaNode != -1 ||
+            def->opts.pciopts.chipId != -1 ||
             def->opts.pciopts.hotplug != VIR_TRISTATE_SWITCH_ABSENT) {
             virBufferAddLit(&childBuf, "<target");
             if (def->opts.pciopts.chassisNr != -1)
@@ -23860,6 +23872,9 @@ virDomainControllerDefFormat(virBuffer *buf,
             if (def->opts.pciopts.targetIndex != -1)
                 virBufferAsprintf(&childBuf, " index='%d'",
                                   def->opts.pciopts.targetIndex);
+            if (def->opts.pciopts.chipId != -1)
+                virBufferAsprintf(&childBuf, " chip-id='%d'",
+                                  def->opts.pciopts.chipId);
             if (def->opts.pciopts.hotplug != VIR_TRISTATE_SWITCH_ABSENT) {
                 virBufferAsprintf(&childBuf, " hotplug='%s'",
                                   virTristateSwitchTypeToString(def->opts.pciopts.hotplug));
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 6848b3a81f..7938c4aa19 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -751,6 +751,7 @@ struct _virDomainPCIControllerOpts {
     int port;
     int busNr; /* used by pci-expander-bus, -1 == unspecified */
     int targetIndex; /* used by spapr-pci-host-bridge, -1 == unspecified */
+    int chipId; /* used by powernv pcie-root controllers, -1 == unspecified */
     /* numaNode is a *subelement* of target (to match existing
      * item in memory target config) -1 == unspecified
      */
-- 
2.35.1




More information about the libvir-list mailing list