Question

I have been trying to set cpu affinity for a VM. Now, I edited the VM xml file present in /etc/libvirt/qemu/$VM.xml and put cpuset attribute. I have 4 cores and I put cpuset = '1,3'. But still when I did virsh vcpuinfo $VM, it showed that my VM's vcpus are still attached to pcpus 0 and 2. What am I doing wrong?

Was it helpful?

Solution

Would you mind pasting out the elements of your domain xml? you may refer to [CPU Allocation] to compare.

A handy tool is command taskset -p <your qemu process id> to see the CPU allocation on the KVM hypervisor.

BTW: you need qemu v0.8.5+ to get this feature.

OTHER TIPS

Editing /etc/libvirt/qemu/$VM.xml under libvirt's hands is not what you should do, neither is setting the affinity without libvirt. In that case libvirt doesn't know about the settings.

The right thing to do is use 'virsh edit $VM', set what you want and stop and start the domain. You can also use virsh to pin each vCPU to particular host CPU(s):

for i in {1..X}; do   # X is the number of VCPUs
  virsh vcpupin $VM 0 1,3
done
virsh emulatorpin $VM 1,3

or

virsh numatune $VM --nodeset 1,3  # To pin to particular

You can use '--config' and '--live' to set it in config or for live domain respectively. For further options see the manual for comman virsh (man virsh).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top