[PATCH 17/20] virDomainWatchdogDef: Convert 'action' field to proper enum type

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

 



Convert the field and adjust the XML parser to use
virXMLPropEnumDefault().

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 17 ++++++-----------
 src/conf/domain_conf.h |  2 +-
 2 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5c1712cb46..f48020f893 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12065,7 +12065,6 @@ virDomainWatchdogDefParseXML(virDomainXMLOption *xmlopt,
                              unsigned int flags)
 {
     virDomainWatchdogDef *def;
-    g_autofree char *action = NULL;
 
     def = g_new0(virDomainWatchdogDef, 1);
 
@@ -12076,16 +12075,12 @@ virDomainWatchdogDefParseXML(virDomainXMLOption *xmlopt,
         goto error;
     }
 
-    action = virXMLPropString(node, "action");
-    if (action == NULL) {
-        def->action = VIR_DOMAIN_WATCHDOG_ACTION_RESET;
-    } else {
-        def->action = virDomainWatchdogActionTypeFromString(action);
-        if (def->action < 0) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("unknown watchdog action '%1$s'"), action);
-            goto error;
-        }
+    if (virXMLPropEnumDefault(node, "action",
+                              virDomainWatchdogActionTypeFromString,
+                              VIR_XML_PROP_NONE,
+                              &def->action,
+                              VIR_DOMAIN_WATCHDOG_ACTION_RESET) < 0) {
+        goto error;
     }
 
     if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags) < 0)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index e7c663b0e9..77e5b26957 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1760,7 +1760,7 @@ typedef enum {
 
 struct _virDomainWatchdogDef {
     virDomainWatchdogModel model;
-    int action;
+    virDomainWatchdogAction action;
     virDomainDeviceInfo info;
 };
 
-- 
2.41.0




[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