[PATCH 32/43] virDomainTimerDef: Convert 'name' field to proper enum type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Adjust the type and the corresponding parser to use virXMLPropEnum.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 13 ++-----------
 src/conf/domain_conf.h |  2 +-
 2 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7c718ce799..aa949766e1 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -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,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index ba411bfa02..de6aefed2d 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2472,7 +2472,7 @@ struct _virDomainTimerCatchupDef {
 };

 struct _virDomainTimerDef {
-    int name;
+    virDomainTimerNameType name;
     virTristateBool present;
     int tickpolicy; /* enum virDomainTimerTickpolicyType */

-- 
2.37.3




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux