Skip to content

Commit 439d70f

Browse files
xen/xcpng: set vmr.VCPUsMax to minimum of global setting and host cpu cores (#7887)
Co-authored-by: dahn <daan.hoogland@gmail.com>
1 parent 26581b7 commit 439d70f

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/XenServerGuru.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package com.cloud.hypervisor;
1818

1919
import java.util.ArrayList;
20-
import java.util.Comparator;
2120
import java.util.List;
2221
import java.util.Map;
2322

@@ -96,14 +95,7 @@ public VirtualMachineTO implement(VirtualMachineProfile vm) {
9695
if (userVmVO != null) {
9796
HostVO host = hostDao.findById(userVmVO.getHostId());
9897
if (host != null) {
99-
List<HostVO> clusterHosts = hostDao.listByClusterAndHypervisorType(host.getClusterId(), host.getHypervisorType());
100-
HostVO hostWithMinSocket = clusterHosts.stream().min(Comparator.comparing(HostVO::getCpuSockets)).orElse(null);
101-
Integer vCpus = MaxNumberOfVCPUSPerVM.valueIn(host.getClusterId());
102-
if (hostWithMinSocket != null && hostWithMinSocket.getCpuSockets() != null &&
103-
hostWithMinSocket.getCpuSockets() < vCpus) {
104-
vCpus = hostWithMinSocket.getCpuSockets();
105-
}
106-
to.setVcpuMaxLimit(vCpus);
98+
to.setVcpuMaxLimit(MaxNumberOfVCPUSPerVM.valueIn(host.getClusterId()));
10799
}
108100
}
109101

plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,7 @@ public VM createVmFromTemplate(final Connection conn, final VirtualMachineTO vmS
13381338
vmr.VCPUsMax = (long)vmSpec.getCpus();
13391339
} else {
13401340
if (vmSpec.getVcpuMaxLimit() != null) {
1341-
vmr.VCPUsMax = (long)vmSpec.getVcpuMaxLimit();
1341+
vmr.VCPUsMax = Math.min(vmSpec.getVcpuMaxLimit(), (long) _host.getCpus());
13421342
}
13431343
}
13441344
} else {

0 commit comments

Comments
 (0)