From bf814aeaddcc2725d39cf1c253a338da1d325b44 Mon Sep 17 00:00:00 2001 From: Kelven Yang Date: Fri, 26 Aug 2011 16:24:33 -0700 Subject: [PATCH] bug 11263: only update host Id when VM is in running state when detected external VM migration --- .../src/com/cloud/vm/VirtualMachineManagerImpl.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java index 73153e39605..5e769a1124c 100755 --- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -1577,13 +1577,20 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene } } - if(vm.getHostId() == null || hostId != vm.getHostId()) { + if(serverState == State.Running) { try { - stateTransitTo(vm, VirtualMachine.Event.AgentReportMigrated, hostId); + if(hostId != vm.getHostId()) { + if (s_logger.isDebugEnabled()) { + s_logger.debug("detected host change when VM " + vm + " is at running state, VM could be live-migrated externally from host " + + vm.getHostId() + " to host " + hostId); + } + + stateTransitTo(vm, VirtualMachine.Event.AgentReportMigrated, hostId); + } } catch (NoTransitionException e) { s_logger.warn(e.getMessage()); } - } + } } if (agentState == serverState) {