Repository: cloudstack Updated Branches: refs/heads/master bede34d29 -> 58cc56927
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.ya...@shapeblue.com> (cherry picked from commit ea7fd37783cbc7ec78de5a5e84395381b1800a3e) Signed-off-by: Rohit Yadav <rohit.ya...@shapeblue.com> Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/58cc5692 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/58cc5692 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/58cc5692 Branch: refs/heads/master Commit: 58cc569273905c50d089f9fd82fe80028b4e9775 Parents: bede34d Author: Rohit Yadav <rohit.ya...@shapeblue.com> Authored: Tue Apr 28 13:16:04 2015 +0200 Committer: Rohit Yadav <rohit.ya...@shapeblue.com> Committed: Tue Apr 28 13:19:49 2015 +0200 ---------------------------------------------------------------------- agent/conf/agent.properties | 3 +++ .../kvm/resource/LibvirtComputingResource.java | 12 ++++++++++++ .../cloud/hypervisor/kvm/resource/LibvirtVMDef.java | 13 +++++++++++++ 3 files changed, 28 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/58cc5692/agent/conf/agent.properties ---------------------------------------------------------------------- diff --git a/agent/conf/agent.properties b/agent/conf/agent.properties index 13138f8..fcd8b5c 100644 --- a/agent/conf/agent.properties +++ b/agent/conf/agent.properties @@ -126,6 +126,9 @@ hypervisor.type=kvm # on,run virsh capabilities for more details. # guest.cpu.model= # +# This param will require CPU features on the <cpu> section +# guest.cpu.features=vmx vme +# # vm.memballoon.disable=true # Disable memory ballooning on vm guests for overcommit, by default overcommit # feature enables balloon and sets currentMemory to a minimum value. http://git-wip-us.apache.org/repos/asf/cloudstack/blob/58cc5692/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index b6ac38c..06b7614 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -451,6 +451,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv protected boolean _noMemBalloon = false; protected String _guestCpuMode; protected String _guestCpuModel; + protected List<String> _cpuFeatures; protected boolean _noKvmClock; protected String _videoHw; protected int _videoRam; @@ -862,6 +863,16 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv 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); _monitor = new KVMHAMonitor(null, info[0], _heartBeatPath); @@ -3675,6 +3686,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv CpuModeDef cmd = new CpuModeDef(); cmd.setMode(_guestCpuMode); cmd.setModel(_guestCpuModel); + cmd.setFeatures(_cpuFeatures); // multi cores per socket, for larger core configs if (vcpus % 6 == 0) { int sockets = vcpus / 6; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/58cc5692/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java index 5c8d337..bd6e042 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java @@ -1043,6 +1043,7 @@ public class LibvirtVMDef { public static class CpuModeDef { private String _mode; private String _model; + private List<String> _features; private int _coresPerSocket = -1; private int _sockets = -1; @@ -1050,6 +1051,12 @@ public class LibvirtVMDef { _mode = mode; } + public void setFeatures(List<String> features) { + if (features != null) { + _features = features; + } + } + public void setModel(String model) { _model = model; } @@ -1074,6 +1081,12 @@ public class LibvirtVMDef { modeBuilder.append("<cpu>"); } + if (_features != null) { + for (String feature : _features) { + modeBuilder.append("<feature policy='require' name='" + feature + "'/>"); + } + } + // add topology if (_sockets > 0 && _coresPerSocket > 0) { modeBuilder.append("<topology sockets='" + _sockets + "' cores='" + _coresPerSocket + "' threads='1' />");