15

All

I've had a problem on my server since I migrated one of my VM's from Windows 2008 Server to Windows 7 (ultimate): though I've assigned four cores to the VM and it even seems to see them, it seems to think it has two cores!

It recognises my processors but doesn't use them!

Can anyone tell me what's going on here? I thought it could have been some incompatibility between KVM and Windows 7 but since it sees the virtual processors I'm beginning to think not...any clues?

Here's a screenshot of process manager showing only two cores on the same box:

Task manager

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
jkp
  • 429
  • 3
  • 7
  • 14
  • Are you sure that it's not showing you two dual-core procs? – phoebus Jan 11 '10 at 08:20
  • @phoebus: I did wonder that, but then on all versions of windows where I have run this setup before I see four cores when looking in processor monitor, which I don't here. – jkp Jan 11 '10 at 08:23
  • When you say processor monitor, do you mean the performance monitoring section of task manager? Because based solely on your screenshots, you're showing evidence of two, two-core processors. If that's the case, you should see all 4 cores in the performance monitor. If you don't, then yes, something is wonky. – phoebus Jan 11 '10 at 08:42
  • @phoebus: yes, I mean the performance monitoring section of task manager. Definitely seems wonky to me... – jkp Jan 11 '10 at 09:01

5 Answers5

26

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>
Mark Dayel
  • 361
  • 3
  • 3
  • knew it, but forgot about it - well then again there's serverfault and all those people writing all this awesome stuff. thanks for the tip! – fen Nov 12 '11 at 17:31
  • 1
    I tried this on my RHEL 7.2 machine. Added `` to my xml. `virsh capabilities | grep topology` shows ``. CRITICAL: performed a `kill -HUP nnnnn` where nnnnn is the PID of my libvirtd process. Started the VM. It worked. +1 ! Thanks! ...But don't forget to kick libvirtd with either a HUP signal or a restart! – Mike S Apr 28 '16 at 14:21
19

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.

xenny
  • 780
  • 4
  • 8
  • 1
    That's correct. ATM there's no way to change the topology. – Luca Tettamanti Jan 11 '10 at 12:49
  • 1
    Wow, I did't know this. Thanks for correctly putting your finger on the issue. @Luca: do you know if such support is planned? I'm I actually using the extra two cores or are they going to waste? – jkp Jan 11 '10 at 13:55
  • 2
    @Luca: actually since qemu 0.12 you can change the topology. I've upgraded my userspace kvm components but I think I need the new kernel mod for it to work....anyway, it can be done :) – jkp Jan 11 '10 at 15:15
  • Ah, cool... I should upgrade too then :) – Luca Tettamanti Jan 11 '10 at 16:11
  • Keep in mind that you can run the newest kvm kernel module on your current older kernel. You will probably have to compile the module yourself unless you can find a repository for your distro that has the binary for you. But building a module isn't too difficult to do. – 3dinfluence Jan 19 '11 at 01:25
  • 1
    This answer is old by now. See @Mark Dayel's answer for a how-to. By this time your kvm/libvirt/qemu should be recent enough to handle more than 2 CPUs just fine. – Mike S Apr 28 '16 at 19:30
  • @LucaTettamanti That is [incorrect](https://s16.postimg.io/c9qjmzgdx/libvirt_topology.png) now (over five years later) – doug65536 Aug 27 '16 at 16:01
5

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>
rickfoosusa
  • 231
  • 4
  • 5
2

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.

Sergey Vlasov
  • 6,088
  • 1
  • 19
  • 30
1

It is worth noting that Ubuntu 10.4 (Lucid) has version 0.7.5 of libvirt while support for topology was added to libvirt in version 0.7.6. Ubuntu 10.10 (Maverick) has 0.8.3 libvirt and so should be able to directly support the topology specification in the XML without a wrapper.

user67327
  • 197
  • 2
  • 8