@@ -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