Skip to content

Commit 18b5fb5

Browse files
committed
do not shutdown alien VMs upon host startup. Send StopCommand for out-of-band stopped VM to restore legacy XS/KVM behave
1 parent e051490 commit 18b5fb5

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

‎engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4132,7 +4132,9 @@ private void handlePowerOffReportWithNoPendingJobsOnVM(VMInstanceVO vm) {
41324132

41334133
s_logger.info("VM " + vm.getInstanceName() + " is sync-ed to at Stopped state according to power-off report from hypervisor");
41344134

4135-
// TODO: we need to forcely release all resource allocation
4135+
VirtualMachineGuru vmGuru = getVmGuru(vm);
4136+
VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm);
4137+
sendStop(vmGuru, profile, true);
41364138
break;
41374139

41384140
case Destroyed:

‎plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,15 @@ public XsHost getHost() {
347347
return _host;
348348
}
349349

350+
private static boolean isAlienVm(VM vm, Connection conn) throws XenAPIException, XmlRpcException {
351+
// TODO : we need a better way to tell whether or not the VM belongs to CloudStack
352+
String vmName = vm.getNameLabel(conn);
353+
if (vmName.matches("^[ivs]-\\d+-.+"))
354+
return false;
355+
356+
return true;
357+
}
358+
350359
protected boolean cleanupHaltedVms(Connection conn) throws XenAPIException, XmlRpcException {
351360
Host host = Host.getByUuid(conn, _host.uuid);
352361
Map<VM, VM.Record> vms = VM.getAllRecords(conn);
@@ -358,7 +367,7 @@ protected boolean cleanupHaltedVms(Connection conn) throws XenAPIException, XmlR
358367
continue;
359368
}
360369

361-
if (VmPowerState.HALTED.equals(vmRec.powerState) && vmRec.affinity.equals(host)) {
370+
if (VmPowerState.HALTED.equals(vmRec.powerState) && vmRec.affinity.equals(host) && !isAlienVm(vm, conn)) {
362371
try {
363372
vm.destroy(conn);
364373
} catch (Exception e) {

0 commit comments

Comments
 (0)