]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
vmspawn: Disable hpet for vmspawn x86 virtual machines
authorDaanDeMeyer <daan.j.demeyer@gmail.com>
Thu, 3 Jul 2025 08:37:25 +0000 (10:37 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 10 Jul 2025 14:14:52 +0000 (16:14 +0200)
hpet is an emulated clocksource that is generally discouraged in favor
of kvm-clock or tsc for virtual machines. While vmspawn's virtual machines
already use kvm-clock, leaving hpet enabled causes qemu on the host to
consume a non-trivial amount of cpu, so let's disable the hpet feature since
we're not making use of it anyway.

src/vmspawn/vmspawn-util.h
src/vmspawn/vmspawn.c

index a8a69a9e50f053c0bffd4b052e5b25aded923046..f851fd48e033400bd03261892ebfe04ed161bbe8 100644 (file)
 #  define ARCHITECTURE_SUPPORTS_SMM 0
 #endif
 
+#if defined(__x86_64__) || defined(__i386__)
+#  define ARCHITECTURE_SUPPORTS_HPET 1
+#else
+#  define ARCHITECTURE_SUPPORTS_HPET 0
+#endif
+
 #if defined(__x86_64__) || defined(__i386__)
 #  define QEMU_MACHINE_TYPE "q35"
 #elif defined(__arm__) || defined(__aarch64__) || defined(__riscv) || defined(__loongarch64)
index a3dd1432b2806bbe4f54f91fd4cd6b983e563089..2771b2634982495f3be1517c4d0f85d4da3067f0 100644 (file)
@@ -1578,10 +1578,11 @@ static int run_virtual_machine(int kvm_device_fd, int vhost_device_fd) {
                             "falling back to OVMF firmware blobs without Secure Boot support.");
 
         shm = arg_directory || arg_runtime_mounts.n_mounts != 0 ? ",memory-backend=mem" : "";
+        const char *hpet = ARCHITECTURE_SUPPORTS_HPET ? ",hpet=off" : "";
         if (ARCHITECTURE_SUPPORTS_SMM)
-                machine = strjoin("type=" QEMU_MACHINE_TYPE ",smm=", on_off(ovmf_config->supports_sb), shm);
+                machine = strjoin("type=" QEMU_MACHINE_TYPE ",smm=", on_off(ovmf_config->supports_sb), shm, hpet);
         else
-                machine = strjoin("type=" QEMU_MACHINE_TYPE, shm);
+                machine = strjoin("type=" QEMU_MACHINE_TYPE, shm, hpet);
         if (!machine)
                 return log_oom();