virDomainTimerDef: Convert 'name' field to proper enum type

Adjust the type and the corresponding parser to use virXMLPropEnum.

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 14:58:39 +02:00
parent a9a2ecec54
commit 7fc2c87200
2 changed files with 3 additions and 12 deletions

View File

@ -10546,24 +10546,15 @@ virDomainTimerDefParseXML(xmlNodePtr node,
VIR_XPATH_NODE_AUTORESTORE(ctxt)
xmlNodePtr catchup;
int ret;
g_autofree char *name = NULL;
g_autofree char *tickpolicy = NULL;
g_autofree char *track = NULL;
g_autofree char *mode = NULL;
ctxt->node = node;
name = virXMLPropString(node, "name");
if (name == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("missing timer name"));
if (virXMLPropEnum(node, "name", virDomainTimerNameTypeFromString,
VIR_XML_PROP_REQUIRED, &def->name) < 0)
return NULL;
}
if ((def->name = virDomainTimerNameTypeFromString(name)) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown timer name '%s'"), name);
return NULL;
}
if (virXMLPropTristateBool(node, "present",
VIR_XML_PROP_NONE,

View File

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