[PATCH 34/43] virDomainTimerDef: Convert 'track' field to proper enum type

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

 



Adjust the parser and add missing switch cases to make the complier
happy.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/conf/domain_conf.c   | 13 ++++---------
 src/conf/domain_conf.h   |  2 +-
 src/qemu/qemu_command.c  |  2 ++
 src/qemu/qemu_validate.c |  2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 4810aa7b82..d91c058868 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 *track = NULL;
     g_autofree char *mode = NULL;

     ctxt->node = node;
@@ -10564,14 +10563,10 @@ virDomainTimerDefParseXML(xmlNodePtr node,
                        VIR_XML_PROP_NONZERO, &def->tickpolicy) < 0)
         return NULL;

-    track = virXMLPropString(node, "track");
-    if (track != NULL) {
-        if ((def->track = virDomainTimerTrackTypeFromString(track)) <= 0) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("unknown timer track '%s'"), track);
-            return NULL;
-        }
-    }
+    if (virXMLPropEnum(node, "track", virDomainTimerTrackTypeFromString,
+                       VIR_XML_PROP_NONZERO, &def->track) < 0)
+        return NULL;
+

     ret = virXPathULongLong("string(./@frequency)", ctxt, &def->frequency);
     if (ret == -1) {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 2733d12fcd..36b6757c3c 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2479,7 +2479,7 @@ struct _virDomainTimerDef {
     virDomainTimerCatchupDef catchup;

     /* track is only valid for name='platform|rtc' */
-    int track;  /* enum virDomainTimerTrackType */
+    virDomainTimerTrackType track;

     /* frequency & mode are only valid for name='tsc' */
     unsigned long long frequency; /* in Hz, unspecified = 0 */
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 7507ab46ab..bf82878e7a 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5732,6 +5732,8 @@ qemuBuildClockArgStr(virDomainClockDef *def)
             case VIR_DOMAIN_TIMER_TRACK_REALTIME:
                 virBufferAddLit(&buf, ",clock=rt");
                 break;
+            case VIR_DOMAIN_TIMER_TRACK_LAST:
+                break;
             }

             switch (def->timers[i]->tickpolicy) {
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index f8f2a0fd32..1456a69351 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -554,6 +554,8 @@ qemuValidateDomainDefClockTimers(const virDomainDef *def,
                                _("unsupported rtc timer track '%s'"),
                                virDomainTimerTrackTypeToString(timer->track));
                 return -1;
+            case VIR_DOMAIN_TIMER_TRACK_LAST:
+                break;
             }

             switch (timer->tickpolicy) {
-- 
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