mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 23:07:44 +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)
|
xmlNodePtr node)
|
||||||
{
|
{
|
||||||
virNetworkDHCPLeaseTimeDef *new_lease = NULL;
|
virNetworkDHCPLeaseTimeDef *new_lease = NULL;
|
||||||
g_autofree char *expirystr = NULL;
|
|
||||||
g_autofree char *unitstr = NULL;
|
|
||||||
unsigned long long expiry;
|
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;
|
return 0;
|
||||||
|
|
||||||
if (virStrToLong_ull(expirystr, NULL, 10, &expiry) < 0) {
|
if (virXMLPropEnumDefault(node, "unit",
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
virNetworkDHCPLeaseTimeUnitTypeFromString,
|
||||||
_("failed to parse expiry value '%s'"), expirystr);
|
VIR_XML_PROP_NONE, &unit,
|
||||||
|
VIR_NETWORK_DHCP_LEASETIME_UNIT_MINUTES) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
if ((unitstr = virXMLPropString(node, "unit"))) {
|
|
||||||
if ((unit = virNetworkDHCPLeaseTimeUnitTypeFromString(unitstr)) < 0) {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
|
||||||
_("Invalid unit: %s"), unitstr);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* infinite */
|
/* infinite */
|
||||||
if (expiry > 0) {
|
if (expiry > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user