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