fbe740
From 67198a38ee3bce9ff19a8c80a593724d684d966e Mon Sep 17 00:00:00 2001
fbe740
Message-Id: <67198a38ee3bce9ff19a8c80a593724d684d966e@dist-git>
fbe740
From: Andrea Bolognani <abologna@redhat.com>
fbe740
Date: Fri, 14 Feb 2020 13:12:33 +0100
fbe740
Subject: [PATCH] qemu: Use switch statement in qemuBuildCpuCommandLine()
fbe740
MIME-Version: 1.0
fbe740
Content-Type: text/plain; charset=UTF-8
fbe740
Content-Transfer-Encoding: 8bit
fbe740
fbe740
Make sure we are taking all possible virDomainTimerNameType values
fbe740
into account. This will make upcoming changes easier.
fbe740
fbe740
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
fbe740
Reviewed-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
fbe740
Reviewed-by: Ján Tomko <jtomko@redhat.com>
fbe740
(cherry picked from commit f8e923c1ba70d7be53ea18d9b4de040763347f9e)
fbe740
fbe740
https://bugzilla.redhat.com/show_bug.cgi?id=1762634
fbe740
fbe740
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
fbe740
Message-Id: <20200214121237.623948-3-abologna@redhat.com>
fbe740
Reviewed-by: Ján Tomko <jtomko@redhat.com>
fbe740
---
fbe740
 src/qemu/qemu_command.c | 34 ++++++++++++++++++++++++----------
fbe740
 1 file changed, 24 insertions(+), 10 deletions(-)
fbe740
fbe740
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
fbe740
index d144855b0d..0ad09baa1d 100644
fbe740
--- a/src/qemu/qemu_command.c
fbe740
+++ b/src/qemu/qemu_command.c
fbe740
@@ -6616,16 +6616,30 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
fbe740
     for (i = 0; i < def->clock.ntimers; i++) {
fbe740
         virDomainTimerDefPtr timer = def->clock.timers[i];
fbe740
 
fbe740
-        if (timer->name == VIR_DOMAIN_TIMER_NAME_KVMCLOCK &&
fbe740
-            timer->present != -1) {
fbe740
-            qemuBuildCpuFeature(qemuCaps, &buf, "kvmclock",
fbe740
-                                !!timer->present);
fbe740
-        } else if (timer->name == VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK &&
fbe740
-                   timer->present == 1) {
fbe740
-            virBufferAddLit(&buf, ",hv-time");
fbe740
-        } else if (timer->name == VIR_DOMAIN_TIMER_NAME_TSC &&
fbe740
-                   timer->frequency > 0) {
fbe740
-            virBufferAsprintf(&buf, ",tsc-frequency=%lu", timer->frequency);
fbe740
+        switch ((virDomainTimerNameType)timer->name) {
fbe740
+        case VIR_DOMAIN_TIMER_NAME_KVMCLOCK:
fbe740
+            if (timer->present != -1) {
fbe740
+                qemuBuildCpuFeature(qemuCaps, &buf, "kvmclock",
fbe740
+                                    !!timer->present);
fbe740
+            }
fbe740
+            break;
fbe740
+        case VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK:
fbe740
+            if (timer->present == 1)
fbe740
+                virBufferAddLit(&buf, ",hv-time");
fbe740
+            break;
fbe740
+        case VIR_DOMAIN_TIMER_NAME_TSC:
fbe740
+            if (timer->frequency > 0)
fbe740
+                virBufferAsprintf(&buf, ",tsc-frequency=%lu", timer->frequency);
fbe740
+            break;
fbe740
+        case VIR_DOMAIN_TIMER_NAME_PLATFORM:
fbe740
+        case VIR_DOMAIN_TIMER_NAME_PIT:
fbe740
+        case VIR_DOMAIN_TIMER_NAME_RTC:
fbe740
+        case VIR_DOMAIN_TIMER_NAME_HPET:
fbe740
+            break;
fbe740
+        case VIR_DOMAIN_TIMER_NAME_LAST:
fbe740
+        default:
fbe740
+            virReportEnumRangeError(virDomainTimerNameType, timer->name);
fbe740
+            return -1;
fbe740
         }
fbe740
     }
fbe740
 
fbe740
-- 
fbe740
2.25.0
fbe740