Skip to content

Commit c9ce12a

Browse files
committed
fix: enforce the minimum cgroupv2 cpu shares to 2
1 parent a163831 commit c9ce12a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2796,7 +2796,15 @@ public int calculateCpuShares(VirtualMachineTO vmTO) {
27962796

27972797
if (hostCpuMaxCapacity > 0) {
27982798
int updatedCpuShares = (int) Math.ceil((requestedCpuShares * CGROUP_V2_UPPER_LIMIT) / (double) hostCpuMaxCapacity);
2799-
LOGGER.debug(String.format("This host utilizes cgroupv2 (as the max shares value is [%s]), thus, the VM requested shares of [%s] will be converted to " +
2799+
2800+
/**
2801+
* Libvirt < 9.1.0 enforces the range [2, 262144] to both cgroupv1 and cgroupv2.
2802+
* Therefore, if the shares value is determined to be < 2, then raise it to 2 to fit into the constraint.
2803+
* See: https://github.com/libvirt/libvirt/commit/38af6497610075e5fe386734b87186731d4c17ac
2804+
*/
2805+
if (updatedCpuShares < 2) updatedCpuShares = 2;
2806+
2807+
logger.debug(String.format("This host utilizes cgroupv2 (as the max shares value is [%s]), thus, the VM requested shares of [%s] will be converted to " +
28002808
"consider the host limits; the new CPU shares value is [%s].", hostCpuMaxCapacity, requestedCpuShares, updatedCpuShares));
28012809
return updatedCpuShares;
28022810
}

0 commit comments

Comments
 (0)