1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-26 03:21:44 +03:00

virDomainTimerDef: Convert 'tickpolicy' field to proper enum type

Convert the field, adjust the XML parser to use virXMLPropEnum and add
the VIR_DOMAIN_TIMER_TICKPOLICY_LAST enum case to all appropriate
'switch' statements.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2022-10-24 15:05:21 +02:00
parent 7fc2c87200
commit 7fb8adc7cd
4 changed files with 15 additions and 10 deletions

View File

@ -10546,7 +10546,6 @@ virDomainTimerDefParseXML(xmlNodePtr node,
VIR_XPATH_NODE_AUTORESTORE(ctxt)
xmlNodePtr catchup;
int ret;
g_autofree char *tickpolicy = NULL;
g_autofree char *track = NULL;
g_autofree char *mode = NULL;
@ -10561,14 +10560,9 @@ virDomainTimerDefParseXML(xmlNodePtr node,
&def->present) < 0)
return NULL;
tickpolicy = virXMLPropString(node, "tickpolicy");
if (tickpolicy != NULL) {
if ((def->tickpolicy = virDomainTimerTickpolicyTypeFromString(tickpolicy)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown timer tickpolicy '%s'"), tickpolicy);
return NULL;
}
}
if (virXMLPropEnum(node, "tickpolicy", virDomainTimerTickpolicyTypeFromString,
VIR_XML_PROP_NONZERO, &def->tickpolicy) < 0)
return NULL;
track = virXMLPropString(node, "track");
if (track != NULL) {

View File

@ -2474,7 +2474,7 @@ struct _virDomainTimerCatchupDef {
struct _virDomainTimerDef {
virDomainTimerNameType name;
virTristateBool present;
int tickpolicy; /* enum virDomainTimerTickpolicyType */
virDomainTimerTickpolicyType tickpolicy;
virDomainTimerCatchupDef catchup;

View File

@ -5747,6 +5747,8 @@ qemuBuildClockArgStr(virDomainClockDef *def)
case VIR_DOMAIN_TIMER_TICKPOLICY_MERGE:
case VIR_DOMAIN_TIMER_TICKPOLICY_DISCARD:
return NULL;
case VIR_DOMAIN_TIMER_TICKPOLICY_LAST:
break;
}
break; /* no need to check other timers - there is only one rtc */
}
@ -5818,6 +5820,8 @@ qemuBuildClockCommandLine(virCommand *cmd,
case VIR_DOMAIN_TIMER_TICKPOLICY_MERGE:
/* no way to support this mode for pit in qemu */
return -1;
case VIR_DOMAIN_TIMER_TICKPOLICY_LAST:
break;
}
break;
@ -6201,6 +6205,7 @@ qemuBuildCpuCommandLine(virCommand *cmd,
case VIR_DOMAIN_TIMER_TICKPOLICY_NONE:
case VIR_DOMAIN_TIMER_TICKPOLICY_CATCHUP:
case VIR_DOMAIN_TIMER_TICKPOLICY_MERGE:
case VIR_DOMAIN_TIMER_TICKPOLICY_LAST:
break;
}
break;

View File

@ -572,6 +572,8 @@ qemuValidateDomainDefClockTimers(const virDomainDef *def,
virDomainTimerTickpolicyTypeToString(
timer->tickpolicy));
return -1;
case VIR_DOMAIN_TIMER_TICKPOLICY_LAST:
break;
}
break;
@ -598,6 +600,8 @@ qemuValidateDomainDefClockTimers(const virDomainDef *def,
virDomainTimerTickpolicyTypeToString(
timer->tickpolicy));
return -1;
case VIR_DOMAIN_TIMER_TICKPOLICY_LAST:
break;
}
break;
@ -650,6 +654,8 @@ qemuValidateDomainDefClockTimers(const virDomainDef *def,
virDomainTimerNameTypeToString(timer->name),
virDomainTimerTickpolicyTypeToString(timer->tickpolicy));
return -1;
case VIR_DOMAIN_TIMER_TICKPOLICY_LAST:
break;
}
break;
}