User Tools

Site Tools


kvm:set_cpu_shares_for_live_running_instance_permanently

This is an old revision of the document!


KVM - Set CPU Shares For Live Running Instance Permanently

virsh schedinfo VM_ID \
  --set cpu_shares=[0-262144] \
  --live \
  --current \
  --config

NOTE: KVM represents each virtual CPU as a thread in the host Linux system, actually as a thread in the QEMU process.

On Linux, you can use taskset to force specific threads onto specific CPUs. So that will let you assign one VCPU to one physical CPU and two VCPUs to another. See, for example, https://groups.google.com/forum/#!topic/linuxkernelnewbies/qs5IiIA4xnw.

A virtual CPU equates to 1 physical core, but when your VM attempts to process something, it can potentially run on any of the cores that happen to be available at that moment. The scheduler handles this, and the VM is not aware of it. You can assign multiple vCPUs to a VM which allows it to run concurrently across several cores.

Cores are shared between all VMs as needed, so you could have a 4-core system, and 10 VMs running on it with 2 vCPUs assigned to each. VMs share all the cores in your system quite efficiently as determined by the scheduler. This is one of the main benefits of virtualization - making the most use of under-subscribed resources to power multiple OS instances.

If your VMs are so busy that they have to contend for CPU time, the outcome is that VMs may have to wait for CPU time. Again, this is transparent to the VM and handled by the scheduler.


References

kvm/set_cpu_shares_for_live_running_instance_permanently.1597837295.txt.gz · Last modified: 2020/08/19 11:41 by 192.168.1.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki