Installation guide

Chapter 24. Miscellaneous administration tasks
188
b. Locate where the guest's virtual CPU count is specified. Find the vcpus element.
<vcpus>4</vcpus>
The guest in this example has four CPUs.
c. Add a cpuset attribute with the CPU numbers for the relevant NUMA cell.
<vcpus cpuset='4-7'>4</vcpus>
4. Save the configuration file and restart the guest.
The guest has been locked to CPUs 4 to 7.
Automatically locking guests to CPUs with virt-install
The virt-install provisioning tool provides a simple way to automatically apply a 'best fit' NUMA
policy when guests are created.
The cpuset option for virt-install can use a CPU set of processors or the parameter auto. The
auto parameter automatically determines the optimal CPU locking using the available NUMA data.
For a NUMA system, use the --cpuset=auto with the virt-install command when creating
new guests.
Tuning CPU affinity on running guests
There may be times where modifying CPU affinities on running guests is preferable to rebooting the
guest. The virsh vcpuinfo and virsh vcpupin commands can perform CPU affinity changes on
running guests.
The virsh vcpuinfo command gives up to date information about where each virtual CPU is
running.
In this example, guest1 is a guest with four virtual CPUs is running on a KVM host.
# virsh vcpuinfo guest1
VCPU: 0
CPU: 3
State: running
CPU time: 0.5s
CPU Affinity: yyyyyyyy
VCPU: 1
CPU: 1
State: running
CPU Affinity: yyyyyyyy
VCPU: 2
CPU: 1
State: running
CPU Affinity: yyyyyyyy
VCPU: 3
CPU: 2
State: running
CPU Affinity: yyyyyyyy
The virsh vcpuinfo output (the yyyyyyyy value of CPU Affinity) shows that the guest can
presently run on any CPU.