Spaceman1984 commented on a change in pull request #4443:
URL: https://github.com/apache/cloudstack/pull/4443#discussion_r521403666



##########
File path: 
plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/XenServerGuru.java
##########
@@ -98,7 +98,18 @@ public VirtualMachineTO implement(VirtualMachineProfile vm) {
         if (userVmVO != null) {
             HostVO host = hostDao.findById(userVmVO.getHostId());
             if (host != null) {
-                
to.setVcpuMaxLimit(MaxNumberOfVCPUSPerVM.valueIn(host.getClusterId()));
+                if (host.getCpus() < 
MaxNumberOfVCPUSPerVM.valueIn(host.getClusterId())) {
+                    String message = String.valueOf(new StringBuilder()
+                            .append("Ignoring global max vCPUs limit (from 
global setting xen.vm.vcpu.max) on vm ")
+                            .append(vm.getUuid()).append(" and setting VM max 
vCPU to host pCPU max: ")
+                            .append(host.getCpus())
+                            .append(". Requested number of virtual CPUs 
exceeds number of host physical CPUs"));
+                    logger.info(message);
+                    to.setVcpuMaxLimit(host.getCpus());
+                } else {
+                    logger.info("Setting vm: " + vm.getUuid() + " max vCPU 
limit (from global setting xen.vm.vcpu.max) to: " + 
MaxNumberOfVCPUSPerVM.valueIn(host.getClusterId()));
+                    
to.setVcpuMaxLimit(MaxNumberOfVCPUSPerVM.valueIn(host.getClusterId()));
+                }

Review comment:
       Done




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

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


Reply via email to