mirror of https://github.com/apache/cloudstack.git
xen/xcpng: set vmr.VCPUsMax to minimum of global setting and host cpu cores (#7887)
Co-authored-by: dahn <daan.hoogland@gmail.com>
This commit is contained in:
parent
26581b7741
commit
439d70fd2b
|
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue