Copilot commented on code in PR #12779:
URL: https://github.com/apache/cloudstack/pull/12779#discussion_r3181323592


##########
server/src/main/java/com/cloud/vm/UserVmManagerImpl.java:
##########
@@ -2493,7 +2477,7 @@ public boolean configure(String name, Map<String, Object> 
params) throws Configu
 
         _executor = Executors.newScheduledThreadPool(wrks, new 
NamedThreadFactory("UserVm-Scavenger"));
 
-        String vmIpWorkers = configs.get(VmIpFetchTaskWorkers.value());
+        String vmIpWorkers = 
configs.get(VmIpFetchTaskWorkers.value().toString());

Review Comment:
   `configs` is keyed by config *names* (e.g. `"expunge.workers"`, 
`Config.ScaleRetry.key()`). Using `VmIpFetchTaskWorkers.value().toString()` 
looks up by the current config *value* (e.g. `"10"`) instead of the key 
(`"externaldhcp.vmipfetchtask.workers"`), which effectively ignores the 
configured setting and falls back to the default. Use the config key (e.g. 
`VmIpFetchTaskWorkers.key()` or the literal key string) when reading from 
`configs`.
   



##########
server/src/main/java/com/cloud/vm/UserVmManagerImpl.java:
##########
@@ -3170,7 +3144,7 @@ private void generateNetworkUsageForVm(VirtualMachine vm, 
boolean isDisplay, Str
             NetworkVO network = _networkDao.findById(nic.getNetworkId());
             long isDefault = (nic.isDefaultNic()) ? 1 : 0;
             UsageEventUtils.publishUsageEvent(eventType, vm.getAccountId(), 
vm.getDataCenterId(), vm.getId(),
-                    Long.toString(nic.getId()), 
network.getNetworkOfferingId(), null, isDefault, vm.getClass().getName(), 
vm.getUuid(), isDisplay);
+                    Long.toString(nic.getId()), 
network.getNetworkOfferingId(), null, isDefault, vm.getClass().getName(), 
vm.getUuid(), true);

Review Comment:
   `generateNetworkUsageForVm(...)` ignores its `isDisplay` argument and always 
passes `true` as `displayResource` to `UsageEventUtils.publishUsageEvent(...)`. 
This changes behavior for hidden VMs and makes the `isDisplay` parameter 
ineffective. Pass `isDisplay` through so usage events respect the VM display 
flag.
   



##########
server/src/main/java/com/cloud/vm/UserVmManagerImpl.java:
##########
@@ -3497,18 +3471,18 @@ public UserVm rebootVirtualMachine(RebootVMCmd cmd) 
throws InsufficientCapacityE
         ServiceOfferingVO offering = 
serviceOfferingDao.findById(vmInstance.getId(), serviceOfferingId);
         if (offering != null && offering.getRemoved() == null) {
             if (offering.isVolatileVm()) {
-                return restoreVMInternal(caller, vmInstance);
+                return restoreVMInternal(vmInstance);
             }
         } else {
             throw new InvalidParameterValueException("Unable to find service 
offering: " + serviceOfferingId + " corresponding to the Instance");
         }
 
-        Boolean enterSetup = cmd.getBootIntoSetup();
-        if (enterSetup != null && enterSetup && 
!HypervisorType.VMware.equals(vmInstance.getHypervisorType())) {
+        boolean enterSetup = Boolean.TRUE.equals(cmd.getBootIntoSetup());
+        if (enterSetup && 
!HypervisorType.VMware.equals(vmInstance.getHypervisorType())) {
             throw new InvalidParameterValueException("Booting into a hardware 
setup menu is not implemented on " + vmInstance.getHypervisorType());
         }
 
-        UserVm userVm = 
rebootVirtualMachine(CallContext.current().getCallingUserId(), vmId, enterSetup 
== null ? false : cmd.getBootIntoSetup(), cmd.isForced());
+        UserVm userVm = rebootVirtualMachine(vmId, cmd.getBootIntoSetup(), 
cmd.isForced());

Review Comment:
   `rebootVirtualMachine` expects a primitive boolean for `enterSetup`, but the 
call passes `cmd.getBootIntoSetup()` (a `Boolean`). This won’t compile and also 
ignores the already-computed `enterSetup` variable. Pass `enterSetup` (or 
`Boolean.TRUE.equals(...)`) to match the method signature.
   



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