Skip to content

Commit d3eace2

Browse files
committed
Add watchdog model none to disable use of watchdogs on KVM agent
1 parent 96b757c commit d3eace2

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ public class AgentProperties{
516516
/**
517517
* The model of Watchdog timer to present to the Guest.<br>
518518
* For all models refer to the libvirt documentation.<br>
519+
* PLEASE NOTE: to disable the watchdogs definitions, use value: none
519520
* Data type: String.<br>
520521
* Default value: <code>i6300esb</code>
521522
*/

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2293,7 +2293,7 @@ public String toString() {
22932293

22942294
public static class WatchDogDef {
22952295
enum WatchDogModel {
2296-
I6300ESB("i6300esb"), IB700("ib700"), DIAG288("diag288"), ITCO("itco");
2296+
I6300ESB("i6300esb"), IB700("ib700"), DIAG288("diag288"), ITCO("itco"), NONE("none");
22972297
String model;
22982298

22992299
WatchDogModel(String model) {
@@ -2346,6 +2346,10 @@ public WatchDogModel getModel() {
23462346

23472347
@Override
23482348
public String toString() {
2349+
if (WatchDogModel.NONE == model) {
2350+
// Do not add watchodogs when the model is set to none
2351+
return "";
2352+
}
23492353
StringBuilder wacthDogBuilder = new StringBuilder();
23502354
wacthDogBuilder.append("<watchdog model='" + model + "' action='" + action + "'/>\n");
23512355
return wacthDogBuilder.toString();

plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.MemBalloonDef;
3232
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.SCSIDef;
3333
import org.apache.cloudstack.utils.qemu.QemuObject;
34+
import org.apache.commons.lang3.StringUtils;
3435
import org.junit.Test;
3536
import org.junit.runner.RunWith;
3637
import org.mockito.junit.MockitoJUnitRunner;
@@ -537,6 +538,16 @@ public void testWatchDogDef() {
537538
assertEquals(action, def.getAction());
538539
}
539540

541+
@Test
542+
public void testWatchDofDefNone() {
543+
LibvirtVMDef.WatchDogDef.WatchDogModel model = LibvirtVMDef.WatchDogDef.WatchDogModel.NONE;
544+
LibvirtVMDef.WatchDogDef.WatchDogAction action = LibvirtVMDef.WatchDogDef.WatchDogAction.RESET;
545+
LibvirtVMDef.WatchDogDef def = new LibvirtVMDef.WatchDogDef(action, model);
546+
String result = def.toString();
547+
assertNotNull(result);
548+
assertTrue(StringUtils.isBlank(result));
549+
}
550+
540551
@Test
541552
public void testSCSIDef() {
542553
SCSIDef def = new SCSIDef((short)0, 0, 0, 9, 0, 4);

0 commit comments

Comments
 (0)