From: DaanDeMeyer Date: Thu, 3 Jul 2025 08:37:25 +0000 (+0200) Subject: vmspawn: Disable hpet for vmspawn x86 virtual machines X-Git-Tag: v258-rc1~117 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ba6c2b7f51ca7cdb0031e10dca8ab6bd06071a1;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/vmspawn/vmspawn-util.h b/src/vmspawn/vmspawn-util.h index a8a69a9e50f..f851fd48e03 100644 --- a/src/vmspawn/vmspawn-util.h +++ b/src/vmspawn/vmspawn-util.h @@ -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) diff --git a/src/vmspawn/vmspawn.c b/src/vmspawn/vmspawn.c index a3dd1432b28..2771b263498 100644 --- a/src/vmspawn/vmspawn.c +++ b/src/vmspawn/vmspawn.c @@ -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();