mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-8424: Add cpu features if guest.cpu.features is set
This improvements checks for "guest.cpu.features" property which is a space
separated list of cpu features that is specific for a host. When added, it
will add <feature policy='require' name='{{feature-you-listed}}'/> in the
<cpu> section of the generated vm spec xml.
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit ea7fd37783cbc7ec78de5a5e84395381b1800a3e)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
bede34d297
commit
58cc569273
@ -126,6 +126,9 @@ hypervisor.type=kvm
|
|||||||
# on,run virsh capabilities for more details.
|
# on,run virsh capabilities for more details.
|
||||||
# guest.cpu.model=
|
# guest.cpu.model=
|
||||||
#
|
#
|
||||||
|
# This param will require CPU features on the <cpu> section
|
||||||
|
# guest.cpu.features=vmx vme
|
||||||
|
#
|
||||||
# vm.memballoon.disable=true
|
# vm.memballoon.disable=true
|
||||||
# Disable memory ballooning on vm guests for overcommit, by default overcommit
|
# Disable memory ballooning on vm guests for overcommit, by default overcommit
|
||||||
# feature enables balloon and sets currentMemory to a minimum value.
|
# feature enables balloon and sets currentMemory to a minimum value.
|
||||||
|
|||||||
@ -451,6 +451,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||||||
protected boolean _noMemBalloon = false;
|
protected boolean _noMemBalloon = false;
|
||||||
protected String _guestCpuMode;
|
protected String _guestCpuMode;
|
||||||
protected String _guestCpuModel;
|
protected String _guestCpuModel;
|
||||||
|
protected List<String> _cpuFeatures;
|
||||||
protected boolean _noKvmClock;
|
protected boolean _noKvmClock;
|
||||||
protected String _videoHw;
|
protected String _videoHw;
|
||||||
protected int _videoRam;
|
protected int _videoRam;
|
||||||
@ -862,6 +863,16 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||||||
params.put("guest.cpu.model", _guestCpuModel);
|
params.put("guest.cpu.model", _guestCpuModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String cpuFeatures = (String)params.get("guest.cpu.features");
|
||||||
|
if (cpuFeatures != null) {
|
||||||
|
_cpuFeatures = new ArrayList<String>();
|
||||||
|
for (String feature: cpuFeatures.split(" ")) {
|
||||||
|
if (feature != null || !feature.isEmpty()) {
|
||||||
|
_cpuFeatures.add(feature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String[] info = NetUtils.getNetworkParams(_privateNic);
|
String[] info = NetUtils.getNetworkParams(_privateNic);
|
||||||
|
|
||||||
_monitor = new KVMHAMonitor(null, info[0], _heartBeatPath);
|
_monitor = new KVMHAMonitor(null, info[0], _heartBeatPath);
|
||||||
@ -3675,6 +3686,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||||||
CpuModeDef cmd = new CpuModeDef();
|
CpuModeDef cmd = new CpuModeDef();
|
||||||
cmd.setMode(_guestCpuMode);
|
cmd.setMode(_guestCpuMode);
|
||||||
cmd.setModel(_guestCpuModel);
|
cmd.setModel(_guestCpuModel);
|
||||||
|
cmd.setFeatures(_cpuFeatures);
|
||||||
// multi cores per socket, for larger core configs
|
// multi cores per socket, for larger core configs
|
||||||
if (vcpus % 6 == 0) {
|
if (vcpus % 6 == 0) {
|
||||||
int sockets = vcpus / 6;
|
int sockets = vcpus / 6;
|
||||||
|
|||||||
@ -1043,6 +1043,7 @@ public class LibvirtVMDef {
|
|||||||
public static class CpuModeDef {
|
public static class CpuModeDef {
|
||||||
private String _mode;
|
private String _mode;
|
||||||
private String _model;
|
private String _model;
|
||||||
|
private List<String> _features;
|
||||||
private int _coresPerSocket = -1;
|
private int _coresPerSocket = -1;
|
||||||
private int _sockets = -1;
|
private int _sockets = -1;
|
||||||
|
|
||||||
@ -1050,6 +1051,12 @@ public class LibvirtVMDef {
|
|||||||
_mode = mode;
|
_mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFeatures(List<String> features) {
|
||||||
|
if (features != null) {
|
||||||
|
_features = features;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setModel(String model) {
|
public void setModel(String model) {
|
||||||
_model = model;
|
_model = model;
|
||||||
}
|
}
|
||||||
@ -1074,6 +1081,12 @@ public class LibvirtVMDef {
|
|||||||
modeBuilder.append("<cpu>");
|
modeBuilder.append("<cpu>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_features != null) {
|
||||||
|
for (String feature : _features) {
|
||||||
|
modeBuilder.append("<feature policy='require' name='" + feature + "'/>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// add topology
|
// add topology
|
||||||
if (_sockets > 0 && _coresPerSocket > 0) {
|
if (_sockets > 0 && _coresPerSocket > 0) {
|
||||||
modeBuilder.append("<topology sockets='" + _sockets + "' cores='" + _coresPerSocket + "' threads='1' />");
|
modeBuilder.append("<topology sockets='" + _sockets + "' cores='" + _coresPerSocket + "' threads='1' />");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user