Skip to content

Commit 6f7c486

Browse files
committed
CLOUDSTACK-7473: Vm migration is not supported for LXC. When host is put in maintenance mode, stop the Vms instead of migrating
1 parent abfb469 commit 6f7c486

5 files changed

Lines changed: 11 additions & 8 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ public void stop(String vmUuid) throws ResourceUnavailableException {
12081208

12091209

12101210
protected boolean getExecuteInSequence(HypervisorType hypervisorType) {
1211-
if (HypervisorType.KVM == hypervisorType) {
1211+
if (HypervisorType.KVM == hypervisorType || HypervisorType.LXC == hypervisorType) {
12121212
return false;
12131213
} else {
12141214
return ExecuteInSequence.value();

plugins/hypervisors/kvm/src/com/cloud/ha/KVMInvestigator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ public Boolean isVmAlive(com.cloud.vm.VirtualMachine vm, Host host) {
5757

5858
@Override
5959
public Status isAgentAlive(Host agent) {
60-
if (agent.getHypervisorType() != Hypervisor.HypervisorType.KVM) {
60+
if (agent.getHypervisorType() != Hypervisor.HypervisorType.KVM && agent.getHypervisorType() != Hypervisor.HypervisorType.LXC) {
6161
return null;
6262
}
6363
CheckOnHostCommand cmd = new CheckOnHostCommand(agent);
6464
List<HostVO> neighbors = _resourceMgr.listHostsInClusterByStatus(agent.getClusterId(), Status.Up);
6565
for (HostVO neighbor : neighbors) {
66-
if (neighbor.getId() == agent.getId() || neighbor.getHypervisorType() != Hypervisor.HypervisorType.KVM) {
66+
if (neighbor.getId() == agent.getId() || (neighbor.getHypervisorType() != Hypervisor.HypervisorType.KVM && neighbor.getHypervisorType() != Hypervisor.HypervisorType.LXC)) {
6767
continue;
6868
}
6969
try {

server/src/com/cloud/ha/KVMFencer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public KVMFencer() {
7474

7575
@Override
7676
public Boolean fenceOff(VirtualMachine vm, Host host) {
77-
if (host.getHypervisorType() != HypervisorType.KVM) {
77+
if (host.getHypervisorType() != HypervisorType.KVM && host.getHypervisorType() != HypervisorType.LXC) {
7878
s_logger.debug("Don't know how to fence non kvm hosts " + host.getHypervisorType());
7979
return null;
8080
}
@@ -83,7 +83,7 @@ public Boolean fenceOff(VirtualMachine vm, Host host) {
8383
FenceCommand fence = new FenceCommand(vm, host);
8484

8585
for (HostVO h : hosts) {
86-
if (h.getHypervisorType() == HypervisorType.KVM) {
86+
if (h.getHypervisorType() == HypervisorType.KVM || h.getHypervisorType() == HypervisorType.LXC) {
8787
if (h.getStatus() != Status.Up) {
8888
continue;
8989
}

server/src/com/cloud/resource/ResourceManagerImpl.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,6 +1195,9 @@ private boolean doMaintain(final long hostId) {
11951195
if (hosts == null || hosts.isEmpty() || !answer.getMigrate()) {
11961196
// for the last host in this cluster, stop all the VMs
11971197
_haMgr.scheduleStop(vm, hostId, WorkType.ForceStop);
1198+
} else if (HypervisorType.LXC.equals(host.getHypervisorType())){
1199+
//Stop LXC Vms. LXC doesn't support migration
1200+
_haMgr.scheduleStop(vm, hostId, WorkType.Stop);
11981201
} else {
11991202
_haMgr.scheduleMigration(vm);
12001203
}
@@ -2092,7 +2095,7 @@ private boolean doCancelMaintenance(long hostId) {
20922095
_agentMgr.pullAgentOutMaintenance(hostId);
20932096

20942097
// for kvm, need to log into kvm host, restart cloudstack-agent
2095-
if (host.getHypervisorType() == HypervisorType.KVM) {
2098+
if (host.getHypervisorType() == HypervisorType.KVM || host.getHypervisorType() == HypervisorType.LXC) {
20962099

20972100
boolean sshToAgent = Boolean.parseBoolean(_configDao.getValue(Config.KvmSshToAgentEnabled.key()));
20982101
if (!sshToAgent) {
@@ -2166,7 +2169,7 @@ private boolean doUmanageHost(long hostId) {
21662169
return true;
21672170
}
21682171

2169-
if (host.getHypervisorType() == HypervisorType.KVM) {
2172+
if (host.getHypervisorType() == HypervisorType.KVM || host.getHypervisorType() == HypervisorType.LXC) {
21702173
MaintainAnswer answer = (MaintainAnswer)_agentMgr.easySend(hostId, new MaintainCommand());
21712174
}
21722175

server/src/com/cloud/storage/StorageManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ public PrimaryDataStoreInfo createPool(CreateStoragePoolCmd cmd) throws Resource
641641
} else {
642642
throw new InvalidParameterValueException("Missing parameter hypervisor. Hypervisor type is required to create zone wide primary storage.");
643643
}
644-
if (hypervisorType != HypervisorType.KVM && hypervisorType != HypervisorType.VMware && hypervisorType != HypervisorType.Hyperv && hypervisorType != HypervisorType.Any) {
644+
if (hypervisorType != HypervisorType.KVM && hypervisorType != HypervisorType.VMware && hypervisorType != HypervisorType.Hyperv && hypervisorType != HypervisorType.LXC && hypervisorType != HypervisorType.Any) {
645645
throw new InvalidParameterValueException("zone wide storage pool is not supported for hypervisor type " + hypervisor);
646646
}
647647
}

0 commit comments

Comments
 (0)