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