O'Reilly logo

KVM Virtualization Cookbook by Konstantin Ivanov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

To pin a KVM virtual machine to a specific CPU and to change the CPU shares, perform the following:

  1. Obtain information about the available CPU cores on the hypervisor:
root@kvm:~# virsh nodeinfoCPU model: x86_64CPU(s): 40CPU frequency: 2593 MHzCPU socket(s): 1Core(s) per socket: 10Thread(s) per core: 2NUMA cell(s): 2Memory size: 131918328 KiBroot@kvm:~#
  1. Get information about the CPU allocation for the KVM guest:
root@kvm:~# virsh vcpuinfo kvm1VCPU: 0CPU: 2State: runningCPU time: 9.1sCPU Affinity: yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyroot@kvm:~#
  1. Pin the KVM instance CPU (VCPU: 0) to the first hypervisor CPU (CPU: 0) and display the result:
root@kvm:~# virsh vcpupin kvm1 0 0 --liveroot@kvm:~# virsh vcpuinfo kvm1 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required