Table of Contents
Virtual Machine Performance
This page provides information on advanced configuration steps that can help improve virtual machine performance. The steps are ordered from most to least impactful.
For further information, refer to: libvirt docs
1. CPU configuration
Especially helpful on hybrid P-core/E-core CPUs:
-
Use “host-passthrough” and one socket with multiple cores:
<cpu mode="host-passthrough" check="none"> <topology sockets="1" dies="1" clusters="1" cores="4" threads="1"/> </cpu>
-
Inspect core topology:
lscpu -e=CPU,CORE,SOCKET,NODE,ONLINE,MAXMHZ,MINMHZ -
Pin guest vCPUs to P-cores and move emulator/IOThread work to E-cores, e.g.:
<cputune> <vcpupin vcpu="0" cpuset="HOST_PCPU_0"/> <vcpupin vcpu="1" cpuset="HOST_PCPU_1"/> <vcpupin vcpu="2" cpuset="HOST_PCPU_2"/> <emulatorpin cpuset="HOST_E_CPUS"/> <iothreadpin iothread="1" cpuset="HOST_E_CPUS"/> </cputune>
2. Use RDP
Use SPICE mainly as console/recovery access and RDP via e.g. Remmina for normal Windows desktop usage.
3. Disk Configuration
Use VirtIO / VirtIO-SCSI for disk and network. Migrate your Disk from emulated SATA by following these steps:
-
Install virtio-win drivers on Linux and virtio-win-guest-tools inside the Windows guest
-
Add a temporary 1GB VirtIO disk so Windows installs the driver, verify that it is recognized, then shut the VM off
-
Switch the boot disk to VirtIO whilst pointing at the same source file and remove the old virtual SATA drive
Recommended XML Disk configuration:
<iothreads>1</iothreads> <driver name="qemu" type="qcow2" cache="none" io="native" discard="unmap" queues="4" iothread="1"/>
4. Check QCOW2 Chains
qemu-img info --backing-chain /path/to/disk.qcow2
Long snapshot chains can hurt random-I/O performance.
Flatten when necessary: (after creating a backup ofc)
qemu-img convert -p -f qcow2 -O qcow2 \ old.qcow2 new-flat.qcow2
5. Btrfs: Avoid CoW-on-CoW
For QCOW2 on Btrfs, use a NOCOW directory to avoid using two CoW layers at once:
sudo mkdir -p /var/lib/libvirt/images/nocow sudo chattr +C /var/lib/libvirt/images/nocow sudo restorecon -Rv /var/lib/libvirt/images/nocow
Verify:
lsattr -d /var/lib/libvirt/images/nocow
Create/copy the new image into this directory after setting +C and point your VM's disk configuration to this new file
Bonus: Dynamic Resolution Updating
It is possible to automatically match the VM's resolution to the windows/resolution of the host. If this is not working out of the box, try these steps:
-
add a SPICE channel to your VM configuration, e.g.:
<channel type="spicevmc"> <target type="virtio" name="com.redhat.spice.0"/> </channel>
-
install the Spice Guest Tools – Windows binaries inside the VM
-
enable dynamic resolution updates in virt-manager:
View → Scale Display → Auto resize VM with windowor in Remmina:Action Bar > Toggle dynamic resolution update
