KVM: High host CPU load after upgrading VM to windows 10 1803

Solution 1:

Found someone with the same issue and a possible fix for it here: https://forum.proxmox.com/threads/high-cpu-load-for-windows-10-guests-when-idle.44531/

Tested changing my own config, and setting hpet to yes in the vm xml fixed it for me.

  <clock offset='localtime'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='yes'/>
    <timer name='hypervclock' present='yes'/>
  </clock>

hpet part is important.

Solution 2:

Got the same issue with Windows 10 21H1 and qemu-kvm-4.2.0. When windows machine was idle, I got around 30% cpu usage. After the fix, I get about 5%.

Got the issue resolved by adding hv_synic & hv_stimer hyperv enlightments. You might get stuck with the following error

error: Failed to start domain mymachine.local
error: internal error: process exited while connecting to monitor: Hyper-V synthetic timers (hv-stimer) requires Hyper-V clocksources (hv-time)
Hyper-V synthetic interrupt controller (hv-synic) requires Hyper-V VP_INDEX MSR (hv-vpindex)
2021-09-22T20:30:06.440656Z qemu-kvm: kvm_init_vcpu failed: Function not implemented

In order to get the above enlightments to work, you have to add hv_time (which is translated to hypervclock in libvirt) and hv_vpindex enlightments too.

My final libvirt XML file looks like

  <features>
    <acpi/>
    <apic/>
    <hyperv>
      <relaxed state='on'/>
      <vapic state='on'/>
      <spinlocks state='on' retries='8191'/>
      <vpindex state='on'/>
      <synic state='on'/>
      <stimer state='on'/>
    </hyperv>
    <smm state='on'/>
  </features>

  <clock offset='localtime'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='discard'/>
    <timer name='hpet' present='yes'/>
    <timer name='hypervclock' present='yes'/>
  </clock>

Disclaimer: This has been done under CentOS 8, but should work under any libvirt controlled KVM.