[PATCH 33/43] virDomainTimerDef: Convert 'tickpolicy' field to proper enum type

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

 



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@xxxxxxxxxx>
---
 src/conf/domain_conf.c   | 12 +++---------
 src/conf/domain_conf.h   |  2 +-
 src/qemu/qemu_command.c  |  5 +++++
 src/qemu/qemu_validate.c |  6 ++++++
 4 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index aa949766e1..4810aa7b82 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -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) {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index de6aefed2d..2733d12fcd 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2474,7 +2474,7 @@ struct _virDomainTimerCatchupDef {
 struct _virDomainTimerDef {
     virDomainTimerNameType name;
     virTristateBool present;
-    int tickpolicy; /* enum virDomainTimerTickpolicyType */
+    virDomainTimerTickpolicyType tickpolicy;

     virDomainTimerCatchupDef catchup;

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 150824f2e1..7507ab46ab 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -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;
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 079009ea4b..f8f2a0fd32 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -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;
         }
-- 
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