This is unreleased documentation for SUSE® Virtualization v1.9 (Dev).

CPU Limits

Every virtual machine in SUSE Virtualization runs inside a pod, which requests a specific CPU allocation from its assigned node. You can configure CPU limits to enforce execution ceilings for workloads during peak usage periods. Without CPU limits, virtual machines with unpredictable resource spikes can cause CPU contention, resulting in high context-switching latency and performance degradation for adjacent workloads on the same host.

Additionally, if a virtual machine experiences a process spike or runaway loop, a CPU limit prevents the virt-launcher container from consuming all physical CPU cores on the host. This safeguard protects critical services running on the host, such as control plane components and storage replicas.

CPU limit enforcement

In SUSE Virtualization, CPU settings map to two main fields in the virtual machine specification:

  • spec.template.spec.domain.cpu.cores: Defines the CPU topology (sockets, cores, and threads) exposed to the guest operating system

    Example (CPU topology):

    apiVersion: kubevirt.io/v1
    kind: VirtualMachineInstance
    spec:
      domain:
        cpu:
          sockets: 2
          cores: 1
          threads: 1
          dedicatedCpuPlacement: true
        resources:
          limits:
            memory: 2Gi
    [...]
  • spec.template.spec.domain.resources[requests/limits].cpu: Defines the CPU limits and requests enforced on the node level

    Example (CPU limits):

    apiVersion: kubevirt.io/v1
    kind: VirtualMachineInstance
    spec:
      domain:
        cpu:
          dedicatedCpuPlacement: true
        resources:
          limits:
            cpu: 2
            memory: 2Gi
    [...]

If no explicit topology is defined in spec.domain.cpu, SUSE Virtualization calculates the vCPU count based on the value of spec.domain.resources.requests.cpu or spec.domain.resources.limits.cpu.

To avoid performance degradation, avoid manually specifying values for both spec.domain.cpu and spec.domain.resources.limits.cpu.

For example, if you allocate 4 vCPUs to a virtual machine in spec.domain.cpu but manually set a CPU limit of 2 (2000m) in spec.domain.resources.limits.cpu:

  • The guest operating system detects 4 vCPUs and schedules multi-threaded tasks across all 4 virtual cores.

  • The host Linux kernel throttles the underlying QEMU process whenever its total execution time reaches the 2-core limit within a cgroup quota period.

Although the guest operating system will not crash, workloads can experience severe latency spikes during peak usage periods due to host-level CPU throttling.

Configuring CPU limits

SUSE Virtualization dynamically calculates and manages resource requests and limits for virtual machine pods based on the defined CPU topology and the cluster’s overcommit-config setting. Allow SUSE Virtualization to calculate these values automatically unless your workload specifically requires explicit manual allocation.

If necessary, you can explicitly set resource requests and limits when creating a virtual machine using the SUSE Virtualization UI (on the Basics tab of the Create Virtual Machine screen) or via a YAML manifest.

As a best practice, the number of vCPUs allocated to a virtual machine should not exceed the total number of physical CPU threads available on the underlying host.

Pinning CPU resources

CPU limits also interact with dedicated CPU resources. When CPU pinning is enabled, SUSE Virtualization adds dedicatedCpuPlacement: true to spec.template.spec.domain.cpu to allocate dedicated CPU resources to the virtual machine. As a result, CPU resource requests are automatically configured to match CPU limits to satisfy Kubernetes Guaranteed Quality of Service (QoS) requirements.

To support CPU pinning, CPU resource limits and requests must adhere to the following rules:

  • CPU requests and limits must be specified as whole numbers (for example, 2 or 4). Fractional CPU allocations (for example, 250m or 1.5) are not supported for pinned CPUs.

  • If CPU resources are manually declared under spec.template.spec.domain.resources, the requested CPU count must match the CPU limit.

For more information, see Requesting dedicated CPU resources in the KubeVirt documentation.

Overcommitting CPU resources

SUSE Virtualization allows you to overcommit resources on compute nodes. If you do not expect virtual machines to continuously consume their full CPU allocations, you can use the overcommit-config setting to optimize physical resource utilization.

Specifying values greater than 100% allows SUSE Virtualization to schedule additional virtual machines on a node, even when physical resources are nominally fully allocated. With the default setting "cpu":1600 (a 1600% allocation ratio), you can schedule up to 16 times the number of physical CPU cores available on the host.

For more information, see Node CPU allocation ratio in the KubeVirt documentation.