vmspawn: Disable hpet for vmspawn x86 virtual machines

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.
This commit is contained in:
DaanDeMeyer
2025-07-03 10:37:25 +02:00
committed by Daan De Meyer
parent 0b565facc4
commit 8ba6c2b7f5
2 changed files with 9 additions and 2 deletions

View File

@@ -27,6 +27,12 @@
# 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)

View 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();