From 7e295ec4e191bc2cd254ec6381c5876dfbffd280 Mon Sep 17 00:00:00 2001 From: Nicolas Vazquez Date: Thu, 23 Jan 2025 09:15:02 -0300 Subject: [PATCH] [KVM] Add watchdog model none to disable use of watchdogs on KVM agent (#10203) --- agent/conf/agent.properties | 1 + .../com/cloud/agent/properties/AgentProperties.java | 1 + .../cloud/hypervisor/kvm/resource/LibvirtVMDef.java | 6 +++++- .../hypervisor/kvm/resource/LibvirtVMDefTest.java | 11 +++++++++++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/agent/conf/agent.properties b/agent/conf/agent.properties index 3b6a7b7de29..515614fff16 100644 --- a/agent/conf/agent.properties +++ b/agent/conf/agent.properties @@ -286,6 +286,7 @@ hypervisor.type=kvm # The model of Watchdog timer to present to the Guest. # For all models refer to the libvirt documentation. +# PLEASE NOTE: to disable the watchdogs definitions, use value: none #vm.watchdog.model=i6300esb # Action to take when the Guest/Instance is no longer notifying the Watchdog timer. diff --git a/agent/src/main/java/com/cloud/agent/properties/AgentProperties.java b/agent/src/main/java/com/cloud/agent/properties/AgentProperties.java index 8f97edc3935..52679811f7c 100644 --- a/agent/src/main/java/com/cloud/agent/properties/AgentProperties.java +++ b/agent/src/main/java/com/cloud/agent/properties/AgentProperties.java @@ -516,6 +516,7 @@ public class AgentProperties{ /** * The model of Watchdog timer to present to the Guest.
* For all models refer to the libvirt documentation.
+ * PLEASE NOTE: to disable the watchdogs definitions, use value: none * Data type: String.
* Default value: i6300esb */ diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java index a67294ecadb..39373ab6e3b 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java @@ -2293,7 +2293,7 @@ public class LibvirtVMDef { public static class WatchDogDef { enum WatchDogModel { - I6300ESB("i6300esb"), IB700("ib700"), DIAG288("diag288"), ITCO("itco"); + I6300ESB("i6300esb"), IB700("ib700"), DIAG288("diag288"), ITCO("itco"), NONE("none"); String model; WatchDogModel(String model) { @@ -2346,6 +2346,10 @@ public class LibvirtVMDef { @Override public String toString() { + if (WatchDogModel.NONE == model) { + // Do not add watchodogs when the model is set to none + return ""; + } StringBuilder wacthDogBuilder = new StringBuilder(); wacthDogBuilder.append("\n"); return wacthDogBuilder.toString(); diff --git a/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java b/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java index c41d487b63c..bcbf6a2238b 100644 --- a/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java +++ b/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java @@ -31,6 +31,7 @@ import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.MemBalloonDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.SCSIDef; import org.apache.cloudstack.utils.qemu.QemuObject; +import org.apache.commons.lang3.StringUtils; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.junit.MockitoJUnitRunner; @@ -537,6 +538,16 @@ public class LibvirtVMDefTest extends TestCase { assertEquals(action, def.getAction()); } + @Test + public void testWatchDofDefNone() { + LibvirtVMDef.WatchDogDef.WatchDogModel model = LibvirtVMDef.WatchDogDef.WatchDogModel.NONE; + LibvirtVMDef.WatchDogDef.WatchDogAction action = LibvirtVMDef.WatchDogDef.WatchDogAction.RESET; + LibvirtVMDef.WatchDogDef def = new LibvirtVMDef.WatchDogDef(action, model); + String result = def.toString(); + assertNotNull(result); + assertTrue(StringUtils.isBlank(result)); + } + @Test public void testSCSIDef() { SCSIDef def = new SCSIDef((short)0, 0, 0, 9, 0, 4);