mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
virPCIDeviceAddressParseXML: Use virXMLProp*
Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
917a3dc200
commit
e1e2e7ec46
@ -200,52 +200,29 @@ virPCIDeviceAddressParseXML(xmlNodePtr node,
|
|||||||
{
|
{
|
||||||
xmlNodePtr cur;
|
xmlNodePtr cur;
|
||||||
xmlNodePtr zpci = NULL;
|
xmlNodePtr zpci = NULL;
|
||||||
g_autofree char *domain = virXMLPropString(node, "domain");
|
|
||||||
g_autofree char *bus = virXMLPropString(node, "bus");
|
|
||||||
g_autofree char *slot = virXMLPropString(node, "slot");
|
|
||||||
g_autofree char *function = virXMLPropString(node, "function");
|
|
||||||
g_autofree char *multi = virXMLPropString(node, "multifunction");
|
|
||||||
|
|
||||||
memset(addr, 0, sizeof(*addr));
|
memset(addr, 0, sizeof(*addr));
|
||||||
|
|
||||||
if (domain &&
|
if (virXMLPropUInt(node, "domain", 0, VIR_XML_PROP_NONE,
|
||||||
virStrToLong_uip(domain, NULL, 0, &addr->domain) < 0) {
|
&addr->domain) < 0)
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("Cannot parse <address> 'domain' attribute"));
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
if (bus &&
|
if (virXMLPropUInt(node, "bus", 0, VIR_XML_PROP_NONE,
|
||||||
virStrToLong_uip(bus, NULL, 0, &addr->bus) < 0) {
|
&addr->bus) < 0)
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("Cannot parse <address> 'bus' attribute"));
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
if (slot &&
|
if (virXMLPropUInt(node, "slot", 0, VIR_XML_PROP_NONE,
|
||||||
virStrToLong_uip(slot, NULL, 0, &addr->slot) < 0) {
|
&addr->slot) < 0)
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("Cannot parse <address> 'slot' attribute"));
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
if (function &&
|
if (virXMLPropUInt(node, "function", 0, VIR_XML_PROP_NONE,
|
||||||
virStrToLong_uip(function, NULL, 0, &addr->function) < 0) {
|
&addr->function) < 0)
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
return -1;
|
||||||
_("Cannot parse <address> 'function' attribute"));
|
|
||||||
|
if (virXMLPropTristateSwitch(node, "multifunction", VIR_XML_PROP_NONE,
|
||||||
|
&addr->multi) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
if (multi) {
|
|
||||||
int value;
|
|
||||||
if ((value = virTristateSwitchTypeFromString(multi)) <= 0) {
|
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
||||||
_("Unknown value '%s' for <address> 'multifunction' attribute"),
|
|
||||||
multi);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
addr->multi = value;
|
|
||||||
}
|
|
||||||
if (!virPCIDeviceAddressIsEmpty(addr) && !virPCIDeviceAddressIsValid(addr, true))
|
if (!virPCIDeviceAddressIsEmpty(addr) && !virPCIDeviceAddressIsValid(addr, true))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user