mirror of https://github.com/apache/cloudstack.git
do not shutdown alien VMs upon host startup. Send StopCommand for out-of-band stopped VM to restore legacy XS/KVM behave
This commit is contained in:
parent
e051490cea
commit
18b5fb5a3c
|
|
@ -4132,7 +4132,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
|
||||
s_logger.info("VM " + vm.getInstanceName() + " is sync-ed to at Stopped state according to power-off report from hypervisor");
|
||||
|
||||
// TODO: we need to forcely release all resource allocation
|
||||
VirtualMachineGuru vmGuru = getVmGuru(vm);
|
||||
VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm);
|
||||
sendStop(vmGuru, profile, true);
|
||||
break;
|
||||
|
||||
case Destroyed:
|
||||
|
|
|
|||
|
|
@ -347,6 +347,15 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
return _host;
|
||||
}
|
||||
|
||||
private static boolean isAlienVm(VM vm, Connection conn) throws XenAPIException, XmlRpcException {
|
||||
// TODO : we need a better way to tell whether or not the VM belongs to CloudStack
|
||||
String vmName = vm.getNameLabel(conn);
|
||||
if (vmName.matches("^[ivs]-\\d+-.+"))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean cleanupHaltedVms(Connection conn) throws XenAPIException, XmlRpcException {
|
||||
Host host = Host.getByUuid(conn, _host.uuid);
|
||||
Map<VM, VM.Record> vms = VM.getAllRecords(conn);
|
||||
|
|
@ -358,7 +367,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
continue;
|
||||
}
|
||||
|
||||
if (VmPowerState.HALTED.equals(vmRec.powerState) && vmRec.affinity.equals(host)) {
|
||||
if (VmPowerState.HALTED.equals(vmRec.powerState) && vmRec.affinity.equals(host) && !isAlienVm(vm, conn)) {
|
||||
try {
|
||||
vm.destroy(conn);
|
||||
} catch (Exception e) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue