Skip to content

Commit b6c7ab7

Browse files
committed
Do not consider watchdogs for aarch64 as its not supported
1 parent f94afd3 commit b6c7ab7

File tree

5 files changed

+37
-7
lines changed

5 files changed

+37
-7
lines changed

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

Lines changed: 2 additions & 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: this value will be ignored in case arch is aarch64
519520
* Data type: String.<br>
520521
* Default value: <code>i6300esb</code>
521522
*/
@@ -524,6 +525,7 @@ public class AgentProperties{
524525
/**
525526
* Action to take when the Guest/Instance is no longer notifying the Watchdog timer.<br>
526527
* Possible values: none | reset | poweroff <br>
528+
* PLEASE NOTE: this value will be ignored in case arch is aarch64
527529
* Data type: String.<br>
528530
* Default value: <code>none</code>
529531
*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2667,7 +2667,7 @@ protected DevicesDef createDevicesDef(VirtualMachineTO vmTO, GuestDef guest, int
26672667
}
26682668

26692669
protected WatchDogDef createWatchDogDef() {
2670-
return new WatchDogDef(watchDogAction, watchDogModel);
2670+
return new WatchDogDef(watchDogAction, watchDogModel, guestCpuArch);
26712671
}
26722672

26732673
protected void createArm64UsbDef(DevicesDef devices) {

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ public boolean parseDomainXML(String domXML) {
7878
desc = getTagValue("description", rootElement);
7979
name = getTagValue("name", rootElement);
8080

81+
String arch = null;
82+
NodeList nodeType = rootElement.getElementsByTagName("type");
83+
if (nodeType.getLength() > 0) {
84+
Element item = (Element) nodeType.item(0);
85+
arch = item.getAttribute("arch");
86+
}
87+
8188
Element devices = (Element)rootElement.getElementsByTagName("devices").item(0);
8289
NodeList disks = devices.getElementsByTagName("disk");
8390
for (int i = 0; i < disks.getLength(); i++) {
@@ -379,10 +386,11 @@ public boolean parseDomainXML(String domXML) {
379386
}
380387

381388
if (StringUtils.isEmpty(action)) {
382-
def = new WatchDogDef(WatchDogModel.valueOf(model.toUpperCase()));
389+
def = new WatchDogDef(WatchDogModel.valueOf(model.toUpperCase()), arch);
383390
} else {
384391
def = new WatchDogDef(WatchDogAction.valueOf(action.toUpperCase()),
385-
WatchDogModel.valueOf(model.toUpperCase()));
392+
WatchDogModel.valueOf(model.toUpperCase()),
393+
arch);
386394
}
387395

388396
watchDogDefs.add(def);

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2323,17 +2323,22 @@ public String toString() {
23232323
WatchDogModel model = WatchDogModel.I6300ESB;
23242324
WatchDogAction action = WatchDogAction.NONE;
23252325

2326-
public WatchDogDef(WatchDogAction action) {
2326+
String arch;
2327+
2328+
public WatchDogDef(WatchDogAction action, String arch) {
23272329
this.action = action;
2330+
this.arch = arch;
23282331
}
23292332

2330-
public WatchDogDef(WatchDogModel model) {
2333+
public WatchDogDef(WatchDogModel model, String arch) {
23312334
this.model = model;
2335+
this.arch = arch;
23322336
}
23332337

2334-
public WatchDogDef(WatchDogAction action, WatchDogModel model) {
2338+
public WatchDogDef(WatchDogAction action, WatchDogModel model, String arch) {
23352339
this.action = action;
23362340
this.model = model;
2341+
this.arch = arch;
23372342
}
23382343

23392344
public WatchDogAction getAction() {
@@ -2346,6 +2351,9 @@ public WatchDogModel getModel() {
23462351

23472352
@Override
23482353
public String toString() {
2354+
if (StringUtils.isNotBlank(arch) && "aarch64".equalsIgnoreCase(arch)) {
2355+
return "";
2356+
}
23492357
StringBuilder wacthDogBuilder = new StringBuilder();
23502358
wacthDogBuilder.append("<watchdog model='" + model + "' action='" + action + "'/>\n");
23512359
return wacthDogBuilder.toString();

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
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;
35+
import org.junit.Assert;
3436
import org.junit.Test;
3537
import org.junit.runner.RunWith;
3638
import org.mockito.junit.MockitoJUnitRunner;
@@ -532,11 +534,21 @@ public void testWatchDogDef() {
532534
LibvirtVMDef.WatchDogDef.WatchDogModel model = LibvirtVMDef.WatchDogDef.WatchDogModel.I6300ESB;
533535
LibvirtVMDef.WatchDogDef.WatchDogAction action = LibvirtVMDef.WatchDogDef.WatchDogAction.RESET;
534536

535-
LibvirtVMDef.WatchDogDef def = new LibvirtVMDef.WatchDogDef(action, model);
537+
LibvirtVMDef.WatchDogDef def = new LibvirtVMDef.WatchDogDef(action, model, null);
536538
assertEquals(model, def.getModel());
537539
assertEquals(action, def.getAction());
538540
}
539541

542+
@Test
543+
public void testWatchDofDefAarch64() {
544+
LibvirtVMDef.WatchDogDef.WatchDogModel model = LibvirtVMDef.WatchDogDef.WatchDogModel.I6300ESB;
545+
LibvirtVMDef.WatchDogDef.WatchDogAction action = LibvirtVMDef.WatchDogDef.WatchDogAction.RESET;
546+
LibvirtVMDef.WatchDogDef def = new LibvirtVMDef.WatchDogDef(action, model, "aarch64");
547+
String result = def.toString();
548+
Assert.assertNotNull(result);
549+
Assert.assertTrue(StringUtils.isBlank(result));
550+
}
551+
540552
@Test
541553
public void testSCSIDef() {
542554
SCSIDef def = new SCSIDef((short)0, 0, 0, 9, 0, 4);

0 commit comments

Comments
 (0)