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

4
  • Are you sure that it's not showing you two dual-core procs?
    – phoebus
    Jan 11, 2010 at 8: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, 2010 at 8: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, 2010 at 8:42
  • @phoebus: yes, I mean the performance monitoring section of task manager. Definitely seems wonky to me...
    – jkp
    Jan 11, 2010 at 9:01

5 Answers 5

21

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.

8
  • 1
    That's correct. ATM there's no way to change the topology. Jan 11, 2010 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, 2010 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, 2010 at 15:15
  • Ah, cool... I should upgrade too then :) Jan 11, 2010 at 16:11
  • 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, 2016 at 19:30
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>
2
  • 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, 2011 at 17:31
  • 1
    I tried this on my RHEL 7.2 machine. Added <topology sockets='1' cores='4' threads='1'/> to my xml. virsh capabilities | grep topology shows <topology sockets='1' cores='6' threads='2'/>. 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, 2016 at 14:21
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>
1
  • This option was the only works for me! Thanks.
    – Felipe
    Oct 16, 2021 at 19:21
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.

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .