Why does my Windows 7 VM running under Linux' KVM not use all the virtual processors?

Solution 1:

On libvirt 0.8.3, if you type:

virsh capabilities | grep topology

it will list the topology of the host:

<topology sockets='1' cores='4' threads='1'/>

The numbers refer to sockets, cores per socket, and threads per core. Add this line to the cpu entry in the xml file to allow windows to use all 4 cores, e.g.:

 <vcpu>4</vcpu>
 <cpu>
     <topology sockets='1' cores='4' threads='1'/>
 </cpu>

Solution 2:

I suspect the processors are being presented as single core processors in separate sockets. Windows 7 ultimate supports up to 2 socket systems, so it will use 2 processors.

I don't know if you can configure KVM to present the processors as either a single quad core CPU or 2 dual core CPUs, which should resolve the problem.


Solution 3:

Topology settings are fully supported in virt-manager since Ubuntu 15.04.

From virt-manager > CPUs > Topology:

  • Check: Manually set CPU topology
  • Sockets: 2
  • Cores: 2
  • Threads: 2

The following is created from the above settings in virt-manager. You do not need to enter these with virsh edit.

<vcpu placement='static'>8</vcpu>
<cpu mode='host-model'>
  <model fallback='allow'/>
  <topology sockets='2' cores='2' threads='2'/>
</cpu>

Topology stopped being recognized by windows after an update, and again limits the Virtual CPU's to 2 sockets.

To fix this, use 'virsh edit' to hide the kvm feature, and add hyperv features. After a complete shutdown and reboot the windows VM will again recognize multiple CPU's.

Why does my Windows 7 VM running under Linux' KVM not use all the virtual processors?

<features>
  <acpi/>
  <apic/>
  <hyperv>
    <relaxed state='on'/>
    <vapic state='on'/>
    <spinlocks state='on' retries='8191'/>
  </hyperv>
  <kvm>
    <hidden state='on'/>
  </kvm>
</features>

Solution 4:

In RHEL/CentOS 5.5 (kvm >= 83-164.el5) the kvm binary supports the "-smp N,cores=N" option too (there are backport patches in the package); however, the libvirt version does not support the <topology> element in the domain XML. A workaround is to create a wrapper script for /usr/libexec/kvm which adds the appropriate option and specify that script in the <emulator> element instead of the default path.