Merge release branch 4.18 to main

* 4.18:
  xen/xcpng: set vmr.VCPUsMax to minimum of global setting and host cpu cores (#7887)
This commit is contained in:
Daan Hoogland 2023-08-28 14:53:23 +02:00
commit 40d7da6707
2 changed files with 2 additions and 10 deletions

View File

@ -17,7 +17,6 @@
package com.cloud.hypervisor;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
@ -96,14 +95,7 @@ public class XenServerGuru extends HypervisorGuruBase implements HypervisorGuru,
if (userVmVO != null) {
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);
Integer vCpus = MaxNumberOfVCPUSPerVM.valueIn(host.getClusterId());
if (hostWithMinSocket != null && hostWithMinSocket.getCpuSockets() != null &&
hostWithMinSocket.getCpuSockets() < vCpus) {
vCpus = hostWithMinSocket.getCpuSockets();
}
to.setVcpuMaxLimit(vCpus);
to.setVcpuMaxLimit(MaxNumberOfVCPUSPerVM.valueIn(host.getClusterId()));
}
}

View File

@ -1338,7 +1338,7 @@ public abstract class CitrixResourceBase extends ServerResourceBase implements S
vmr.VCPUsMax = (long)vmSpec.getCpus();
} else {
if (vmSpec.getVcpuMaxLimit() != null) {
vmr.VCPUsMax = (long)vmSpec.getVcpuMaxLimit();
vmr.VCPUsMax = Math.min(vmSpec.getVcpuMaxLimit(), (long) _host.getCpus());
}
}
} else {