a41c76
From 8152b6ac3b740bfe1155e3c4c251684cc5b3192e Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <8152b6ac3b740bfe1155e3c4c251684cc5b3192e@dist-git>
a41c76
From: Andrea Bolognani <abologna@redhat.com>
a41c76
Date: Fri, 14 Feb 2020 13:12:36 +0100
a41c76
Subject: [PATCH] qemu: Validate configuration for the armvtimer timer
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
Its use is limited to certain guest types, and it only supports
a41c76
a subset of all possible tick policies.
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 aeddab230cd1e2a12d5d6352971bb70ea067a1c4)
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-6-abologna@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/qemu/qemu_domain.c | 38 ++++++++++++++++++++++++++++++++++++++
a41c76
 1 file changed, 38 insertions(+)
a41c76
a41c76
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
a41c76
index 4de4f9da53..1bed117eb0 100644
a41c76
--- a/src/qemu/qemu_domain.c
a41c76
+++ b/src/qemu/qemu_domain.c
a41c76
@@ -5506,6 +5506,44 @@ qemuDomainDefValidateClockTimers(const virDomainDef *def,
a41c76
             break;
a41c76
 
a41c76
         case VIR_DOMAIN_TIMER_NAME_ARMVTIMER:
a41c76
+            if (def->virtType != VIR_DOMAIN_VIRT_KVM ||
a41c76
+                !qemuDomainIsARMVirt(def)) {
a41c76
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
a41c76
+                               _("Configuring the '%s' timer is not supported "
a41c76
+                                 "for virtType=%s arch=%s machine=%s guests"),
a41c76
+                               virDomainTimerNameTypeToString(timer->name),
a41c76
+                               virDomainVirtTypeToString(def->virtType),
a41c76
+                               virArchToString(def->os.arch),
a41c76
+                               def->os.machine);
a41c76
+                return -1;
a41c76
+            }
a41c76
+            if (timer->present == 0) {
a41c76
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
a41c76
+                               _("The '%s' timer can't be disabled"),
a41c76
+                               virDomainTimerNameTypeToString(timer->name));
a41c76
+                return -1;
a41c76
+            }
a41c76
+            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CPU_KVM_NO_ADJVTIME)) {
a41c76
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
a41c76
+                               _("Configuring the '%s' timer is not supported "
a41c76
+                                 "with this QEMU binary"),
a41c76
+                               virDomainTimerNameTypeToString(timer->name));
a41c76
+                return -1;
a41c76
+            }
a41c76
+
a41c76
+            switch (timer->tickpolicy) {
a41c76
+            case -1:
a41c76
+            case VIR_DOMAIN_TIMER_TICKPOLICY_DELAY:
a41c76
+            case VIR_DOMAIN_TIMER_TICKPOLICY_DISCARD:
a41c76
+                break;
a41c76
+            case VIR_DOMAIN_TIMER_TICKPOLICY_CATCHUP:
a41c76
+            case VIR_DOMAIN_TIMER_TICKPOLICY_MERGE:
a41c76
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
a41c76
+                               _("The '%s' timer does not support tickpolicy '%s'"),
a41c76
+                               virDomainTimerNameTypeToString(timer->name),
a41c76
+                               virDomainTimerTickpolicyTypeToString(timer->tickpolicy));
a41c76
+                return -1;
a41c76
+            }
a41c76
             break;
a41c76
         }
a41c76
     }
a41c76
-- 
a41c76
2.25.0
a41c76