DaanHoogland commented on code in PR #10221:
URL: https://github.com/apache/cloudstack/pull/10221#discussion_r1922717244


##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java:
##########
@@ -2796,7 +2796,15 @@ public int calculateCpuShares(VirtualMachineTO vmTO) {
 
         if (hostCpuMaxCapacity > 0) {
             int updatedCpuShares = (int) Math.ceil((requestedCpuShares * 
CGROUP_V2_UPPER_LIMIT) / (double) hostCpuMaxCapacity);
-            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 " +
+
+            /**
+             * Libvirt < 9.1.0 enforces the range [2, 262144] to both cgroupv1 
and cgroupv2.
+             * Therefore, if the shares value is determined to be < 2, then 
raise it to 2 to fit into the constraint.
+             * See: 
https://github.com/libvirt/libvirt/commit/38af6497610075e5fe386734b87186731d4c17ac
+             */
+            if (updatedCpuShares < 2) updatedCpuShares = 2;
+
+            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 " +
                     "consider the host limits; the new CPU shares value is 
[%s].", hostCpuMaxCapacity, requestedCpuShares, updatedCpuShares));

Review Comment:
   ```suggestion
               LOGGER.debug(String.format("This host utilizes cgroupv2 (as the 
max shares value is [{}]), thus, the VM requested shares of [{}] will be 
converted to " +
                       "consider the host limits; the new CPU shares value is 
[{}].", hostCpuMaxCapacity, requestedCpuShares, updatedCpuShares);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to