Friday, June 22, 2012

Getting WinXP (or Win 7, Server etc) to see all cores as a KVM guest

I'd installed a Win XP Pro x86_64 guest on a Fedora 13 x86_64 KVM host. The host had 8 hyperthreaded CPUs (16 virtual cores in total). I had assigned all 16 vcpus to the WinXP guest, but it only showed 2 in the task manager, though in the device manager, it showed 16. The problem had to do with licensing: XP Pro is limited to 2 physical CPUs (even though it can see 16 cpus in the device manager). It can support (at least) 4 cores per cpu however. So the solution is to specify this in the config, which I found (via googling) can be done by modifying the xml defining the guest. To find the layout of the host:

virsh capabilities | grep topology

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

Using 'virsh edit <domain>', find where the vcpus are set:

<vcpu>16</vcpu>

Then add the following below:


  <cpu>
    <topology sockets='2' cores='4' threads='2'/>
  </cpu>

Save it, and restart the guest. It now sees all vcpus.

I notice that from looking at the xml, libvirt reorders it slightly:


  <vcpu>16</vcpu>
  <os>
    <type arch='x86_64' machine='pc-0.13'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <cpu>
    <topology sockets='2' cores='4' threads='2'/>
  </cpu>


No comments: