mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
virNodeDeviceCapVPDParseXML: Fix error reporting
Don't overwrite already reported errors and improve parsing of attributes. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
ea8d864d9e
commit
dd36db2607
@ -1059,11 +1059,11 @@ virNodeDeviceCapVPDParseXML(xmlXPathContextPtr ctxt, virPCIVPDResource **res)
|
|||||||
|
|
||||||
if (!(newres->name = virXPathString("string(./name)", ctxt))) {
|
if (!(newres->name = virXPathString("string(./name)", ctxt))) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
_("Could not read a device name from the <name> element"));
|
_("Could not read a device name from the <name> element"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((nfields = virXPathNodeSet("./fields[@access]", ctxt, &nodes)) < 0)
|
if ((nfields = virXPathNodeSet("./fields", ctxt, &nodes)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
for (i = 0; i < nfields; i++) {
|
for (i = 0; i < nfields; i++) {
|
||||||
@ -1071,27 +1071,19 @@ virNodeDeviceCapVPDParseXML(xmlXPathContextPtr ctxt, virPCIVPDResource **res)
|
|||||||
VIR_XPATH_NODE_AUTORESTORE(ctxt);
|
VIR_XPATH_NODE_AUTORESTORE(ctxt);
|
||||||
|
|
||||||
ctxt->node = nodes[i];
|
ctxt->node = nodes[i];
|
||||||
if (!(access = virXPathString("string(./@access[1])", ctxt))) {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
if (!(access = virXMLPropStringRequired(nodes[i], "access")))
|
||||||
_("VPD fields access type parsing has failed"));
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
if (STREQ(access, "readonly")) {
|
if (STREQ(access, "readonly")) {
|
||||||
if (virNodeDeviceCapVPDParseReadOnlyFields(ctxt, newres) < 0) {
|
if (virNodeDeviceCapVPDParseReadOnlyFields(ctxt, newres) < 0)
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
|
||||||
_("Could not parse %1$s VPD resource fields"), access);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
} else if (STREQ(access, "readwrite")) {
|
} else if (STREQ(access, "readwrite")) {
|
||||||
if (virNodeDeviceCapVPDParseReadWriteFields(ctxt, newres) < 0) {
|
if (virNodeDeviceCapVPDParseReadWriteFields(ctxt, newres) < 0)
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
|
||||||
_("Could not parse %1$s VPD resource fields"), access);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
_("Unsupported VPD field access type specified %1$s"),
|
_("Unsupported VPD field access type '%1$s'"),
|
||||||
access);
|
access);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user