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