mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-24 21:45:21 +00:00
virPCIEDeviceInfoLinkParseXML: Use virXMLProp*
Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
fee958313d
commit
bfba1758a2
@ -1601,38 +1601,16 @@ virPCIEDeviceInfoLinkParseXML(xmlXPathContextPtr ctxt,
|
|||||||
virPCIELink *lnk)
|
virPCIELink *lnk)
|
||||||
{
|
{
|
||||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||||
int speed;
|
|
||||||
g_autofree char *speedStr = NULL;
|
|
||||||
g_autofree char *portStr = NULL;
|
|
||||||
|
|
||||||
ctxt->node = linkNode;
|
if (virXMLPropUInt(linkNode, "width", 0, VIR_XML_PROP_REQUIRED, &lnk->width) < 0)
|
||||||
|
|
||||||
if (virXPathUInt("number(./@width)", ctxt, &lnk->width) < 0) {
|
|
||||||
virReportError(VIR_ERR_XML_DETAIL, "%s",
|
|
||||||
_("mandatory attribute 'width' is missing or malformed"));
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
if ((speedStr = virXPathString("string(./@speed)", ctxt))) {
|
if (virXMLPropEnum(linkNode, "speed", virPCIELinkSpeedTypeFromString,
|
||||||
if ((speed = virPCIELinkSpeedTypeFromString(speedStr)) < 0) {
|
VIR_XML_PROP_NONE, &lnk->speed) < 0)
|
||||||
virReportError(VIR_ERR_XML_DETAIL,
|
return -1;
|
||||||
_("malformed 'speed' attribute: %s"),
|
|
||||||
speedStr);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
lnk->speed = speed;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((portStr = virXPathString("string(./@port)", ctxt))) {
|
if (virXMLPropInt(linkNode, "port", 10, VIR_XML_PROP_NONE, &lnk->port, -1) < 0)
|
||||||
if (virStrToLong_i(portStr, NULL, 10, &lnk->port) < 0) {
|
return -1;
|
||||||
virReportError(VIR_ERR_XML_DETAIL,
|
|
||||||
_("malformed 'port' attribute: %s"),
|
|
||||||
portStr);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
lnk->port = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user