Skip to content

Commit

Permalink
xen: check hosts cpu cores intead of cpu sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
weizhouapache committed Aug 28, 2023
1 parent d5ab297 commit 89fe6a7
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ public VirtualMachineTO implement(VirtualMachineProfile vm) {
HostVO host = hostDao.findById(userVmVO.getHostId());
if (host != null) {
List<HostVO> clusterHosts = hostDao.listByClusterAndHypervisorType(host.getClusterId(), host.getHypervisorType());
HostVO hostWithMinSocket = clusterHosts.stream().min(Comparator.comparing(HostVO::getCpuSockets)).orElse(null);
HostVO hostWithMinCpus = clusterHosts.stream().min(Comparator.comparing(HostVO::getCpus)).orElse(null);
Integer vCpus = MaxNumberOfVCPUSPerVM.valueIn(host.getClusterId());
if (hostWithMinSocket != null && hostWithMinSocket.getCpuSockets() != null &&
hostWithMinSocket.getCpuSockets() < vCpus) {
vCpus = hostWithMinSocket.getCpuSockets();
if (hostWithMinCpus != null && hostWithMinCpus.getCpus() != null &&
hostWithMinCpus.getCpus() < vCpus) {
vCpus = hostWithMinCpus.getCpus();
}
to.setVcpuMaxLimit(vCpus);
}
Expand Down

0 comments on commit 89fe6a7

Please sign in to comment.