bhouse-nexthop commented on code in PR #14378:
URL: https://github.com/apache/cloudstack/pull/14378#discussion_r4721365788


##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java:
##########
@@ -7187,22 +7185,45 @@ protected void deleteIfExists(String snapshotPath) {
         }
     }
 
-    public void setInterfaceDefQueueSettings(Map<String, String> details, 
Integer cpus, InterfaceDef interfaceDef) {
+    private Integer getMultiqueueFromVmDetails(Map<String, String> details) {
         String nicMultiqueueNumber = 
details.get(VmDetailConstants.NIC_MULTIQUEUE_NUMBER);
         if (nicMultiqueueNumber != null) {
             try {
-                Integer nicMultiqueueNumberInteger = 
Integer.valueOf(nicMultiqueueNumber);
-                if (nicMultiqueueNumberInteger == 
InterfaceDef.MULTI_QUEUE_NUMBER_MEANS_CPU_CORES) {
-                    if (cpus != null) {
-                        interfaceDef.setMultiQueueNumber(cpus);
-                    }
-                } else {
-                    
interfaceDef.setMultiQueueNumber(nicMultiqueueNumberInteger);
-                }
+                return Integer.valueOf(nicMultiqueueNumber);
             } catch (NumberFormatException ex) {
-                LOGGER.warn(String.format("VM details %s is not a valid 
integer value %s", VmDetailConstants.NIC_MULTIQUEUE_NUMBER, 
nicMultiqueueNumber));
+                logger.warn("VM detail [{}] is not a valid integer value {}.", 
VmDetailConstants.NIC_MULTIQUEUE_NUMBER, nicMultiqueueNumber);
             }
         }
+
+        return null;
+    }
+
+    public void setInterfaceDefQueueSettings(Map<String, String> details, 
Integer cpus, InterfaceDef interfaceDef, Integer multiqueueForVrs, boolean 
isVr) {
+        if (details == null) {
+            details = new HashMap<>();
+        }
+
+        Integer nicMultiqueueNumber = getMultiqueueFromVmDetails(details);
+        if (nicMultiqueueNumber != null) {
+            logger.info("VM detail [{}] is equal to [{}]; therefore, it will 
be used as the multiqueue value.", VmDetailConstants.NIC_MULTIQUEUE_NUMBER, 
nicMultiqueueNumber);
+        } else if (isVr && multiqueueForVrs != null) {
+            logger.info("VM detail [{}] has not been specified. The target VM 
is a VR and it has an associated multiqueue number. " +
+                    "Considering this associated value, equal to [{}], as the 
multiqueue value.", VmDetailConstants.NIC_MULTIQUEUE_NUMBER, multiqueueForVrs);
+            nicMultiqueueNumber = multiqueueForVrs;
+        }
+
+        if (nicMultiqueueNumber != null) {
+            if (nicMultiqueueNumber == 
InterfaceDef.MULTI_QUEUE_NUMBER_MEANS_CPU_CORES && cpus != null && cpus > 0) {
+                logger.info("The NIC multiqueue number is equal to [{}]. Thus, 
defining the multiqueue value as the number of vCPUs [{}].", 
InterfaceDef.MULTI_QUEUE_NUMBER_MEANS_CPU_CORES, cpus);
+                interfaceDef.setMultiQueueNumber(cpus);

Review Comment:
   Explicit values are capped at 256, but `-1` resolves to the raw vCPU count. 
A VR with more than 256 vCPUs and `-1` (offering or global) gets more queues 
than a tap device allows, and fails to start. Not a realistic size, but cheap 
to guard:
   
   ```java
   interfaceDef.setMultiQueueNumber(Math.min(cpus, 256));
   ```
   
   (User VMs had the same gap before this PR.)



##########
server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java:
##########
@@ -8671,6 +8726,14 @@ private void 
applyResolvedValuesToCommand(CloneNetworkOfferingCmd cmd, NetworkOf
             applyIfNotProvided(cmd, requestParams, "guestIptype", 
ApiConstants.GUEST_IP_TYPE, cmd.getGuestIpType(), 
sourceOffering.getGuestType().toString());
             applyIfNotProvided(cmd, requestParams, "maxConnections", 
ApiConstants.MAX_CONNECTIONS, cmd.getMaxconnections(), 
sourceOffering.getConcurrentConnections());
 
+            boolean isL2Offering = 
StringUtils.equalsIgnoreCase(GuestType.L2.name(), cmd.getGuestIpType());
+            if (!isL2Offering && BooleanUtils.isFalse(cmd.getForVpc())) {

Review Comment:
   `forVpc` is only copied from the source offering further down 
(`applyBooleanIfNotProvided(... "forVpc" ...)`), so here it's still null when 
the caller doesn't pass `forvpc`. `isFalse(null)` is false, and the public 
value is never copied.
   
   Repro: `cloneNetworkOffering sourceofferingid=<isolated offering with 
publicmultiqueuenumber=4> name=x`. The clone has no public value and falls back 
to `router.nic.multiqueue.number`, with no error. The UI form has a `forvpc` 
switch for isolated offerings, so this mostly shows up from the API 
(CloudMonkey, Terraform).
   
   ```java
   boolean forVpc = cmd.getForVpc() != null ? cmd.getForVpc() : 
sourceOffering.isForVpc();
   if (!isL2Offering && !forVpc) {
   ```
   
   or move this block below the boolean copies.



-- 
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