Virt manager - configuration for Windows VM

Hi,

What is the best practice for best possible performance when creating a Windows VM under virt manager?

I mean the configurations?

I have an old Business PC, HP Z230 SFF running Intel 4th Gen i7 4790 / 32GB DDR2 / SATA SSD with dedicated TPM v2 chip. Windows guest via Windows Host (Hyper-V) runs really smooth. Infact, Linux guests on Windows Host via Hyper-V runs somewhat excellent but I am unable to get similar performance via Virt Manager QEMU/KVM on Ubuntu 24 LTS Desktop Host.

Following are the configuration that I have managed to use via available information on Internet Search.

Configuration

<domain type="kvm">
  <name>VM-Win11-AVS</name>
  <uuid>0fec4d2a-67df-4ff0-9d69-415ce1b410f9</uuid>
  <metadata>
    <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
      <libosinfo:os id="http://microsoft.com/win/11"/>
    </libosinfo:libosinfo>
  </metadata>
  <memory>4194304</memory>
  <currentMemory>4194304</currentMemory>
  <memoryBacking>
    <source type="memfd"/>
    <access mode="shared"/>
  </memoryBacking>
  <vcpu current="8">8</vcpu>
  <os>
    <type arch="x86_64" machine="q35">hvm</type>
    <loader readonly="yes" secure="yes" type="pflash">/usr/share/OVMF/OVMF_CODE_4M.secboot.fd</loader>
  </os>
  <features>
    <acpi/>
    <apic/>
    <hyperv>
      <relaxed state="on"/>
      <vapic state="on"/>
      <spinlocks state="on" retries="8191"/>
    </hyperv>
    <vmport state="off"/>
    <smm state="on"/>
  </features>
  <cpu mode="host-passthrough">
    <topology sockets="1" cores="4" threads="2"/>
  </cpu>
  <clock offset="localtime">
    <timer name="rtc" tickpolicy="catchup"/>
    <timer name="pit" tickpolicy="delay"/>
    <timer name="hpet" present="no"/>
    <timer name="hypervclock" present="yes"/>
  </clock>
  <pm>
    <suspend-to-mem enabled="no"/>
    <suspend-to-disk enabled="no"/>
  </pm>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type="file" device="disk">
      <driver name="qemu" type="qcow2"/>
      <source file="/home/hunky/Documents/VM-Win11-AVS.qcow2"/>
      <target dev="vda" bus="virtio"/>
      <boot order="2"/>
    </disk>
    <disk type="file" device="cdrom">
      <driver name="qemu" type="raw"/>
      <source file="/media/HDD_160G/Download/Win11x64_24H2_Dec24.iso"/>
      <target dev="sdb" bus="sata"/>
      <readonly/>
      <boot order="1"/>
    </disk>
    <disk type="file" device="cdrom">
      <driver name="qemu" type="raw"/>
      <source file="/media/HDD_160G/Download/virtio-win-0.1.266.iso"/>
      <target dev="sdc" bus="sata"/>
      <readonly/>
      <boot order="3"/>
    </disk>
    <controller type="usb" model="qemu-xhci" ports="15"/>
    <controller type="pci" model="pcie-root"/>
    <controller type="pci" model="pcie-root-port"/>
    <controller type="pci" model="pcie-root-port"/>
    <controller type="pci" model="pcie-root-port"/>
    <controller type="pci" model="pcie-root-port"/>
    <controller type="pci" model="pcie-root-port"/>
    <controller type="pci" model="pcie-root-port"/>
    <controller type="pci" model="pcie-root-port"/>
    <controller type="pci" model="pcie-root-port"/>
    <controller type="pci" model="pcie-root-port"/>
    <controller type="pci" model="pcie-root-port"/>
    <controller type="pci" model="pcie-root-port"/>
    <controller type="pci" model="pcie-root-port"/>
    <controller type="pci" model="pcie-root-port"/>
    <controller type="pci" model="pcie-root-port"/>
    <interface type="bridge">
      <source bridge="br01"/>
      <mac address="00:15:5d:a0:e6:9f"/>
      <model type="virtio"/>
    </interface>
    <console type="pty"/>
    <channel type="spicevmc">
      <target type="virtio" name="com.redhat.spice.0"/>
    </channel>
    <input type="tablet" bus="usb"/>
    <tpm model="tpm-tis">
      <backend type="emulator" version="2.0"/>
    </tpm>
    <graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
      <image compression="off"/>
    </graphics>
    <sound model="ich9"/>
    <video>
      <model type="qxl"/>
    </video>
    <redirdev bus="usb" type="spicevmc"/>
    <redirdev bus="usb" type="spicevmc"/>
  </devices>
</domain>

I have ensured to install the VirtIO drivers and guest tools but still the performance is really poor compared to Windows Host → Hyper-V → Windows Guest on this same mahcine.

Can anyone help me to get the configuration right for a Windows (10/11) Guest on an Ubuntu 24 LTS Host with Virt Manager?

Thanks.

There are a number of good resources on youtube and on the web for this. You could start by checking your config with this site.
https://raphtlw.medium.com/how-to-set-up-a-kvm-qemu-windows-10-vm-ca1789411760#resources

1 Like

Hello,

Thanks for the reply.

I have gone through the article as mentioned by you and if you may please notice, mine is already the same as the article mentioned. Most the internet search given links are showing this same configuration.

But unfortunately, the performance is really poor with this configuration. Takes at-least 2 or 3 times longer to complete the installation compared to Hyper-V and runs really choppy and consumes high CPU load even at idle when compared to Hyper-V in this same machine !!

Just to clarify, guest is Windows 11 24H2 clean install up to date and host is Ubuntu 24 LTS Desktop clean install up to date.

Thanks.

have you run the kvm-ok tool to check if acceleration of VMs is even enabled in your system ?

$ kvm-ok 
INFO: /dev/kvm exists
KVM acceleration can be used
$

(else it will just fall back to do everything in software which is very slow)

1 Like

Hello,

Thanks for the reply

Here is the output.

root@H1:/home/hunky# kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used
root@H1:/home/hunky#

It seems it is enabled !!

Thanks.

1 Like