From 89fe6a7bec8253d0665fcaaeace7c193a7c5cf96 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Mon, 28 Aug 2023 09:05:54 +0200 Subject: [PATCH] xen: check hosts cpu cores intead of cpu sockets --- .../src/main/java/com/cloud/hypervisor/XenServerGuru.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/XenServerGuru.java b/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/XenServerGuru.java index a8d7a6e268e4..449f93b83108 100644 --- a/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/XenServerGuru.java +++ b/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/XenServerGuru.java @@ -97,11 +97,11 @@ public VirtualMachineTO implement(VirtualMachineProfile vm) { HostVO host = hostDao.findById(userVmVO.getHostId()); if (host != null) { List 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); }