[libvirt] [PATCH v3 1/2] qemu: Restrict usage of hpet and kvm.pit timers by unsupported architectures

Kothapally Madhu Pavan kmp at linux.vnet.ibm.com
Tue Jul 25 14:36:08 UTC 2017


hpet and kvm.pit clock timers are specific to x86 architecture and
are not suppose to be used in other architectures. This patch restricts
the usage of hpet and kvm.pit timers in unsupported architectures.

Signed-off-by: Kothapally Madhu Pavan <kmp at linux.vnet.ibm.com>
---
 src/qemu/qemu_domain.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 2c8c9a7..e5e4208 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3083,12 +3083,28 @@ qemuDomainDefValidate(const virDomainDef *def,
     virQEMUCapsPtr qemuCaps = NULL;
     unsigned int topologycpus;
     int ret = -1;
+    size_t i;
 
     if (!(qemuCaps = virQEMUCapsCacheLookup(caps,
                                             driver->qemuCapsCache,
                                             def->emulator)))
         goto cleanup;
 
+    /* Restrict usage of unsupported clock sources */
+    for (i = 0; i < def->clock.ntimers; i++) {
+        virDomainTimerDefPtr timer = def->clock.timers[i];
+        if ((!(virQEMUCapsGet(qemuCaps, QEMU_CAPS_NO_HPET)) &&
+             (timer->name == VIR_DOMAIN_TIMER_NAME_HPET)) ||
+            (!(virQEMUCapsGet(qemuCaps, QEMU_CAPS_NO_KVM_PIT)) &&
+             (timer->name == VIR_DOMAIN_TIMER_NAME_PIT))) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("unsupported clock timer '%s' for %s architecture"),
+                           virDomainTimerNameTypeToString(def->clock.timers[i]->name),
+                           virArchToString(def->os.arch));
+            goto cleanup;
+        }
+    }
+
     if (def->mem.min_guarantee) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("Parameter 'min_guarantee' not supported by QEMU."));
-- 
1.8.3.1




More information about the libvir-list mailing list