]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virDomainTimerDef: Convert 'name' field to proper enum type
authorPeter Krempa <pkrempa@redhat.com>
Mon, 24 Oct 2022 12:58:39 +0000 (14:58 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 2 Nov 2022 08:20:58 +0000 (09:20 +0100)
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>
src/conf/domain_conf.c
src/conf/domain_conf.h

index 7c718ce799b8da66a84a5060af8cd9e7a70a7d26..aa949766e1874954208c92d849a2e1a4bffd4384 100644 (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,
index ba411bfa0241c8ad2ee1bcb6e0c940e0491c7e41..de6aefed2d7f1b4d715734b4a117abc42a00e5ca 100644 (file)
@@ -2472,7 +2472,7 @@ struct _virDomainTimerCatchupDef {
 };
 
 struct _virDomainTimerDef {
-    int name;
+    virDomainTimerNameType name;
     virTristateBool present;
     int tickpolicy; /* enum virDomainTimerTickpolicyType */