Skip to content

Commit 349120f

Browse files
GutoVeroneziGutoVeronezi
andauthored
Externalize config to enable manually setting CPU topology on KVM VM (#5273)
* Externalize config to enable manually setting CPU topology on KVM VM * Change log level Co-authored-by: GutoVeronezi <daniel@scclouds.com.br>
1 parent 2215cd7 commit 349120f

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

agent/conf/agent.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,3 +270,6 @@ iscsi.session.cleanup.enabled=false
270270
# This parameter specifies the heartbeat update timeout in ms; The default value is 60000ms (1 min).
271271
# Depending on the use case, this timeout might need increasing/decreasing.
272272
# heartbeat.update.timeout=60000
273+
274+
# Enable manually setting CPU's topology on KVM's VM.
275+
# enable.manually.setting.cpu.topology.on.kvm.vm=true

agent/src/main/java/com/cloud/agent/properties/AgentProperties.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ public class AgentProperties{
3232
*/
3333
public static final Property<Integer> HEARTBEAT_UPDATE_TIMEOUT = new Property<Integer>("heartbeat.update.timeout", 60000);
3434

35+
/**
36+
* Enable manually setting CPU's topology on KVM's VM. <br>
37+
* Data type: boolean.<br>
38+
* Default value: true.
39+
*/
40+
public static final Property<Boolean> ENABLE_MANUALLY_SETTING_CPU_TOPOLOGY_ON_KVM_VM = new Property<Boolean>("enable.manually.setting.cpu.topology.on.kvm.vm", true);
41+
3542
public static class Property <T>{
3643
private final String name;
3744
private final T defaultValue;

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@
109109
import com.cloud.agent.api.to.NicTO;
110110
import com.cloud.agent.api.to.VirtualMachineTO;
111111
import com.cloud.agent.dao.impl.PropertiesStorage;
112+
import com.cloud.agent.properties.AgentProperties;
113+
import com.cloud.agent.properties.AgentPropertiesFileHandler;
112114
import com.cloud.agent.resource.virtualnetwork.VRScripts;
113115
import com.cloud.agent.resource.virtualnetwork.VirtualRouterDeployer;
114116
import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource;
@@ -411,6 +413,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
411413
protected MemStat _memStat = new MemStat(_dom0MinMem, _dom0OvercommitMem);
412414
private final LibvirtUtilitiesHelper libvirtUtilitiesHelper = new LibvirtUtilitiesHelper();
413415

416+
protected Boolean enableManuallySettingCpuTopologyOnKvmVm = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.ENABLE_MANUALLY_SETTING_CPU_TOPOLOGY_ON_KVM_VM);
417+
414418
protected long getHypervisorLibvirtVersion() {
415419
return _hypervisorLibvirtVersion;
416420
}
@@ -4502,6 +4506,11 @@ public boolean isSecureMode(String bootMode) {
45024506
}
45034507

45044508
private void setCpuTopology(CpuModeDef cmd, int vcpus, Map<String, String> details) {
4509+
if (!enableManuallySettingCpuTopologyOnKvmVm) {
4510+
s_logger.debug(String.format("Skipping manually setting CPU topology on VM's XML due to it is disabled in agent.properties {\"property\": \"%s\", \"value\": %s}.",
4511+
AgentProperties.ENABLE_MANUALLY_SETTING_CPU_TOPOLOGY_ON_KVM_VM.getName(), enableManuallySettingCpuTopologyOnKvmVm));
4512+
return;
4513+
}
45054514
// multi cores per socket, for larger core configs
45064515
int numCoresPerSocket = -1;
45074516
if (details != null) {

0 commit comments

Comments
 (0)