]> xenbits.xensource.com Git - libvirt.git/commitdiff
nodedev: make iommuGroup optional for mdevs
authorJonathon Jongsma <jjongsma@redhat.com>
Thu, 18 Jun 2020 21:05:54 +0000 (16:05 -0500)
committerErik Skultety <eskultet@redhat.com>
Fri, 19 Jun 2020 08:39:54 +0000 (10:39 +0200)
When parsing a nodedev xml file, the iommuGroup element should be
optional. This element should be read-only and is determined by the
device driver. While this is a change to existing behavior, it doesn't
break backwards-compatibility because it makes the parser less strict.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
docs/formatnode.html.in
docs/schemas/nodedev.rng
src/conf/node_device_conf.c

index 76eae928dea597ea2ccbc884239e11fa231fe751..4ed43ec0cb1a6bba7104dbbd1826febd34239765 100644 (file)
               <dt><code>iommuGroup</code></dt>
               <dd>
                 This element supports a single attribute <code>number</code>
-                which holds the IOMMU group number the mediated device belongs
-                  to.
+                which holds the IOMMU group number to which the mediated device
+                belongs. This is a read-only field that is reported by the
+                device driver.
               </dd>
             </dl>
           </dd>
index fe6ffa0b5318bbd6b4d6e077f58f6b3af3e7df13..ca3a79db87ed5b6d232a92e0f62491a49bc7f404 100644 (file)
         <data type='string'/>
       </attribute>
     </element>
-    <element name='iommuGroup'>
-      <attribute name='number'>
-        <ref name='unsignedInt'/>
-      </attribute>
-    </element>
+    <optional>
+      <element name='iommuGroup'>
+        <attribute name='number'>
+          <ref name='unsignedInt'/>
+        </attribute>
+      </element>
+    </optional>
   </define>
 
   <define name='capccwdev'>
index bccdbd0af82c600769bf5c0c2e1985102208b258..2ef4514f05e2afce04e0e743758cd5a563249fc3 100644 (file)
@@ -1775,13 +1775,15 @@ virNodeDevCapMdevParseXML(xmlXPathContextPtr ctxt,
         goto out;
     }
 
-    if (virNodeDevCapsDefParseULong("number(./iommuGroup[1]/@number)", ctxt,
-                                    &mdev->iommuGroupNumber, def,
-                                    _("missing iommuGroup number attribute for "
-                                      "'%s'"),
-                                    _("invalid iommuGroup number attribute for "
-                                      "'%s'")) < 0)
+    /* 'iommuGroup' is optional, only report an error if the supplied value is
+     * invalid (-2), not if it's missing (-1) */
+    if (virXPathUInt("number(./iommuGroup[1]/@number)",
+                     ctxt, &mdev->iommuGroupNumber) < -1) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("invalid iommuGroup number attribute for '%s'"),
+                       def->name);
         goto out;
+    }
 
     ret = 0;
  out: