mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
virNetworkDHCPLeaseTimeDefParseXML: Use virXMLProp*
Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
9013204afe
commit
fee958313d
@ -410,27 +410,21 @@ virNetworkDHCPLeaseTimeDefParseXML(virNetworkDHCPLeaseTimeDef **lease,
|
||||
xmlNodePtr node)
|
||||
{
|
||||
virNetworkDHCPLeaseTimeDef *new_lease = NULL;
|
||||
g_autofree char *expirystr = NULL;
|
||||
g_autofree char *unitstr = NULL;
|
||||
unsigned long long expiry;
|
||||
int unit = VIR_NETWORK_DHCP_LEASETIME_UNIT_MINUTES;
|
||||
virNetworkDHCPLeaseTimeUnitType unit;
|
||||
int rc;
|
||||
|
||||
if (!(expirystr = virXMLPropString(node, "expiry")))
|
||||
if ((rc = virXMLPropULongLong(node, "expiry", 0, VIR_XML_PROP_NONE, &expiry)) < 0)
|
||||
return -1;
|
||||
|
||||
if (rc == 0)
|
||||
return 0;
|
||||
|
||||
if (virStrToLong_ull(expirystr, NULL, 10, &expiry) < 0) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
_("failed to parse expiry value '%s'"), expirystr);
|
||||
if (virXMLPropEnumDefault(node, "unit",
|
||||
virNetworkDHCPLeaseTimeUnitTypeFromString,
|
||||
VIR_XML_PROP_NONE, &unit,
|
||||
VIR_NETWORK_DHCP_LEASETIME_UNIT_MINUTES) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((unitstr = virXMLPropString(node, "unit"))) {
|
||||
if ((unit = virNetworkDHCPLeaseTimeUnitTypeFromString(unitstr)) < 0) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
_("Invalid unit: %s"), unitstr);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* infinite */
|
||||
if (expiry > 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user