mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
kvm: FIX cpucorespersocket is not working on KVM (#4497)
This commit is contained in:
parent
837372488f
commit
93f3d35207
@ -2302,14 +2302,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
if (vmTO.getType() == VirtualMachine.Type.User) {
|
||||
cmd.setFeatures(_cpuFeatures);
|
||||
}
|
||||
// multi cores per socket, for larger core configs
|
||||
if (vcpus % 6 == 0) {
|
||||
final int sockets = vcpus / 6;
|
||||
cmd.setTopology(6, sockets);
|
||||
} else if (vcpus % 4 == 0) {
|
||||
final int sockets = vcpus / 4;
|
||||
cmd.setTopology(4, sockets);
|
||||
}
|
||||
setCpuTopology(cmd, vcpus, vmTO.getDetails());
|
||||
vm.addComp(cmd);
|
||||
}
|
||||
|
||||
@ -4230,4 +4223,26 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setCpuTopology(CpuModeDef cmd, int vcpus, Map<String, String> details) {
|
||||
// multi cores per socket, for larger core configs
|
||||
int numCoresPerSocket = -1;
|
||||
if (details != null) {
|
||||
final String coresPerSocket = details.get(VmDetailConstants.CPU_CORE_PER_SOCKET);
|
||||
final int intCoresPerSocket = NumbersUtil.parseInt(coresPerSocket, numCoresPerSocket);
|
||||
if (intCoresPerSocket > 0 && vcpus % intCoresPerSocket == 0) {
|
||||
numCoresPerSocket = intCoresPerSocket;
|
||||
}
|
||||
}
|
||||
if (numCoresPerSocket <= 0) {
|
||||
if (vcpus % 6 == 0) {
|
||||
numCoresPerSocket = 6;
|
||||
} else if (vcpus % 4 == 0) {
|
||||
numCoresPerSocket = 4;
|
||||
} else {
|
||||
numCoresPerSocket = 1;
|
||||
}
|
||||
}
|
||||
cmd.setTopology(numCoresPerSocket, vcpus / numCoresPerSocket);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2478,6 +2478,15 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
if (ovfPropertyVO != null && ovfPropertyVO.isPassword()) {
|
||||
details.put(detailName, DBEncryptionUtil.encrypt(details.get(detailName)));
|
||||
}
|
||||
} else if (VmDetailConstants.CPU_CORE_PER_SOCKET.equals(detailName)) {
|
||||
try {
|
||||
final int val = Integer.parseInt(details.get(detailName));
|
||||
if (val <= 0) {
|
||||
throw new InvalidParameterValueException("Please enter a positive integer value for the vm setting: " + detailName);
|
||||
}
|
||||
} catch (final NumberFormatException e) {
|
||||
throw new InvalidParameterValueException("Please enter an integer value for vm setting: " + detailName);
|
||||
}
|
||||
}
|
||||
}
|
||||
vmInstance.setDetails(details);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user