nodedev: make iommuGroup optional for mdevs

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>
This commit is contained in:
Jonathon Jongsma 2020-06-18 16:05:54 -05:00 committed by Erik Skultety
parent ea33200488
commit 9baffe90b5
3 changed files with 18 additions and 13 deletions

View File

@ -390,8 +390,9 @@
<dt><code>iommuGroup</code></dt> <dt><code>iommuGroup</code></dt>
<dd> <dd>
This element supports a single attribute <code>number</code> This element supports a single attribute <code>number</code>
which holds the IOMMU group number the mediated device belongs which holds the IOMMU group number to which the mediated device
to. belongs. This is a read-only field that is reported by the
device driver.
</dd> </dd>
</dl> </dl>
</dd> </dd>

View File

@ -629,11 +629,13 @@
<data type='string'/> <data type='string'/>
</attribute> </attribute>
</element> </element>
<optional>
<element name='iommuGroup'> <element name='iommuGroup'>
<attribute name='number'> <attribute name='number'>
<ref name='unsignedInt'/> <ref name='unsignedInt'/>
</attribute> </attribute>
</element> </element>
</optional>
</define> </define>
<define name='capccwdev'> <define name='capccwdev'>

View File

@ -1775,13 +1775,15 @@ virNodeDevCapMdevParseXML(xmlXPathContextPtr ctxt,
goto out; goto out;
} }
if (virNodeDevCapsDefParseULong("number(./iommuGroup[1]/@number)", ctxt, /* 'iommuGroup' is optional, only report an error if the supplied value is
&mdev->iommuGroupNumber, def, * invalid (-2), not if it's missing (-1) */
_("missing iommuGroup number attribute for " if (virXPathUInt("number(./iommuGroup[1]/@number)",
"'%s'"), ctxt, &mdev->iommuGroupNumber) < -1) {
_("invalid iommuGroup number attribute for " virReportError(VIR_ERR_INTERNAL_ERROR,
"'%s'")) < 0) _("invalid iommuGroup number attribute for '%s'"),
def->name);
goto out; goto out;
}
ret = 0; ret = 0;
out: out: