Skip to content

Commit 464d793

Browse files
author
Kelven Yang
committed
1) Remove customer field applied to virtual machine in VMware. 2) always track VM host change in VMware regardless whether or not native HA is enabled
1 parent 08fc2b2 commit 464d793

4 files changed

Lines changed: 35 additions & 18 deletions

File tree

api/src/com/cloud/hypervisor/HypervisorGuru.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,11 @@ public interface HypervisorGuru extends Adapter {
4343
* @return delegated host id if the command will be delegated
4444
*/
4545
long getCommandHostDelegation(long hostId, Command cmd);
46+
47+
/**
48+
* @return true if VM can be migrated independently with CloudStack, and therefore CloudStack needs to track and reflect host change
49+
* into CloudStack database, false if CloudStack enforces VM sync logic
50+
*
51+
*/
52+
boolean trackVmHostChange();
4653
}

server/src/com/cloud/hypervisor/KVMGuru.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,9 @@ public <T extends VirtualMachine> VirtualMachineTO implement(
5252

5353
return to;
5454
}
55+
56+
@Override
57+
public boolean trackVmHostChange() {
58+
return false;
59+
}
5560
}

server/src/com/cloud/hypervisor/XenServerGuru.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,9 @@ public <T extends VirtualMachine> VirtualMachineTO implement(VirtualMachineProfi
5858

5959
return to;
6060
}
61+
62+
@Override
63+
public boolean trackVmHostChange() {
64+
return false;
65+
}
6166
}

server/src/com/cloud/vm/VirtualMachineManagerImpl.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,16 +1444,15 @@ public Commands deltaSync(long hostId, Map<String, State> newStates) {
14441444
Map<Long, AgentVmInfo> states = convertToInfos(newStates);
14451445
Commands commands = new Commands(OnError.Continue);
14461446

1447-
boolean nativeHA = _agentMgr.isHostNativeHAEnabled(hostId);
1448-
14491447
for (Map.Entry<Long, AgentVmInfo> entry : states.entrySet()) {
14501448
AgentVmInfo info = entry.getValue();
14511449

14521450
VMInstanceVO vm = info.vm;
14531451

14541452
Command command = null;
14551453
if (vm != null) {
1456-
command = compareState(vm, info, false, nativeHA);
1454+
HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vm.getHypervisorType());
1455+
command = compareState(vm, info, false, hvGuru.trackVmHostChange());
14571456
} else {
14581457
if (s_logger.isDebugEnabled()) {
14591458
s_logger.debug("Cleaning up a VM that is no longer found: " + info.name);
@@ -1666,8 +1665,6 @@ public Commands fullSync(final long hostId, final Map<String, State> newStates)
16661665

16671666
Map<Long, AgentVmInfo> infos = convertToInfos(newStates);
16681667

1669-
boolean nativeHA = _agentMgr.isHostNativeHAEnabled(hostId);
1670-
16711668
for (VMInstanceVO vm : vms) {
16721669
AgentVmInfo info = infos.remove(vm.getId());
16731670

@@ -1678,30 +1675,33 @@ public Commands fullSync(final long hostId, final Map<String, State> newStates)
16781675
} else {
16791676
castedVm = info.vm;
16801677
}
1678+
1679+
HypervisorGuru hvGuru = _hvGuruMgr.getGuru(castedVm.getHypervisorType());
16811680

1682-
Command command = compareState(castedVm, info, true, nativeHA);
1681+
Command command = compareState(castedVm, info, true, hvGuru.trackVmHostChange());
16831682
if (command != null) {
16841683
commands.addCommand(command);
16851684
}
16861685
}
16871686

16881687
for (final AgentVmInfo left : infos.values()) {
1689-
if (nativeHA) {
1690-
for (VirtualMachineGuru<? extends VMInstanceVO> vmGuru : _vmGurus.values()) {
1691-
VMInstanceVO vm = vmGuru.findByName(left.name);
1692-
if (vm == null) {
1688+
for (VirtualMachineGuru<? extends VMInstanceVO> vmGuru : _vmGurus.values()) {
1689+
VMInstanceVO vm = vmGuru.findByName(left.name);
1690+
if (vm == null) {
1691+
s_logger.warn("Stopping a VM that we have no record of: " + left.name);
1692+
commands.addCommand(cleanup(left.name));
1693+
} else {
1694+
HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vm.getHypervisorType());
1695+
if(hvGuru.trackVmHostChange()) {
1696+
Command command = compareState(vm, left, true, true);
1697+
if (command != null) {
1698+
commands.addCommand(command);
1699+
}
1700+
} else {
16931701
s_logger.warn("Stopping a VM that we have no record of: " + left.name);
16941702
commands.addCommand(cleanup(left.name));
1695-
} else {
1696-
Command command = compareState(vm, left, true, nativeHA);
1697-
if (command != null) {
1698-
commands.addCommand(command);
1699-
}
17001703
}
17011704
}
1702-
} else {
1703-
s_logger.warn("Stopping a VM that we have no record of: " + left.name);
1704-
commands.addCommand(cleanup(left.name));
17051705
}
17061706
}
17071707

0 commit comments

Comments
 (0)