From: Tim Wiederhake Date: Wed, 21 Apr 2021 12:08:02 +0000 (+0200) Subject: virPCIDeviceAddressParseXML: Use virXMLProp* X-Git-Tag: v7.3.0-rc1~104 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e1e2e7ec46191a83eadf32be8a87901b01488a6d;p=thirdparty%2Flibvirt.git virPCIDeviceAddressParseXML: Use virXMLProp* Signed-off-by: Tim Wiederhake Reviewed-by: Peter Krempa --- diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index 9abbd5ebb7..801552a9cf 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -200,52 +200,29 @@ virPCIDeviceAddressParseXML(xmlNodePtr node, { xmlNodePtr cur; 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)); - if (domain && - virStrToLong_uip(domain, NULL, 0, &addr->domain) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse
'domain' attribute")); + if (virXMLPropUInt(node, "domain", 0, VIR_XML_PROP_NONE, + &addr->domain) < 0) return -1; - } - if (bus && - virStrToLong_uip(bus, NULL, 0, &addr->bus) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse
'bus' attribute")); + if (virXMLPropUInt(node, "bus", 0, VIR_XML_PROP_NONE, + &addr->bus) < 0) return -1; - } - if (slot && - virStrToLong_uip(slot, NULL, 0, &addr->slot) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse
'slot' attribute")); + if (virXMLPropUInt(node, "slot", 0, VIR_XML_PROP_NONE, + &addr->slot) < 0) return -1; - } - if (function && - virStrToLong_uip(function, NULL, 0, &addr->function) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse
'function' attribute")); + if (virXMLPropUInt(node, "function", 0, VIR_XML_PROP_NONE, + &addr->function) < 0) + return -1; + + if (virXMLPropTristateSwitch(node, "multifunction", VIR_XML_PROP_NONE, + &addr->multi) < 0) return -1; - } - if (multi) { - int value; - if ((value = virTristateSwitchTypeFromString(multi)) <= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Unknown value '%s' for
'multifunction' attribute"), - multi); - return -1; - } - addr->multi = value; - } if (!virPCIDeviceAddressIsEmpty(addr) && !virPCIDeviceAddressIsValid(addr, true)) return -1;