Pcornel
Virtualization · Resource Management

CPU Shares

Cheat sheet · https://pcornel.dk/topic.php?topic=3614

Back to the Topic

Answer

CPU shares set a VM's relative priority only when the host is contended: a VM with twice the shares gets about twice the CPU. Shares have no effect on an idle host and are inherited relative to resource pools.

Remember

  • Shares are relative weights, not guaranteed amounts.
  • They only matter while the host is contended.
  • VMs in a pool share the pool's allocation.

First checks

  • qm set <vmid> --cpuunits 2048 — weight (Proxmox; default 100 cgroup v2)
  • Set-VMProcessor <vm> -RelativeWeight 200 — Hyper-V weight
  • virsh schedinfo <vm> --set cpu_shares=2048 — libvirt

Commands

qm set 101 --cpuunits 200

Verify in this order

contention → shares ratio → CPU time

Where it usually breaks

First mismatch in management intent → host/cluster capability → hypervisor runtime/task → virtual resource/device → guest state → workload-visible read-back; preserve identity/native error/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=3614

Confirmation

Confirm action

Continue?