mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 23:07:44 +00:00
conf: node_device: fix mdev_types format and XML parsing code to match schema
The nodedev schema defines that a mdev_types capability must have one or more type elements. The XML parsing and the format allows to accept and to write mdev_types capability without any type element. This patches fixes this. Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
ae110dc58b
commit
689ff3c6c6
@ -277,6 +277,7 @@ virNodeDeviceCapPCIDefFormat(virBufferPtr buf,
|
||||
virPCIHeaderTypeToString(data->pci_dev.hdrType));
|
||||
}
|
||||
if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_MDEV) {
|
||||
if (data->pci_dev.nmdev_types > 0) {
|
||||
virBufferAddLit(buf, "<capability type='mdev_types'>\n");
|
||||
virBufferAdjustIndent(buf, 2);
|
||||
for (i = 0; i < data->pci_dev.nmdev_types; i++) {
|
||||
@ -297,6 +298,7 @@ virNodeDeviceCapPCIDefFormat(virBufferPtr buf,
|
||||
virBufferAdjustIndent(buf, -2);
|
||||
virBufferAddLit(buf, "</capability>\n");
|
||||
}
|
||||
}
|
||||
if (data->pci_dev.nIommuGroupDevices) {
|
||||
virBufferAsprintf(buf, "<iommuGroup number='%d'>\n",
|
||||
data->pci_dev.iommuGroupNumber);
|
||||
@ -1531,6 +1533,12 @@ virNodeDevPCICapMdevTypesParseXML(xmlXPathContextPtr ctxt,
|
||||
if ((nmdev_types = virXPathNodeSet("./type", ctxt, &nodes)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (nmdev_types == 0) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
_("missing <type> element in <capability> element"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
orignode = ctxt->node;
|
||||
for (i = 0; i < nmdev_types; i++) {
|
||||
ctxt->node = nodes[i];
|
||||
|
Loading…
Reference in New Issue
Block a user