bug 13449: running VMs can also have null host id, put a check

reviewed-by: kishan
This commit is contained in:
abhi 2012-02-04 20:14:31 +05:30
parent f50fa56b55
commit ff3ea9356c
1 changed files with 6 additions and 4 deletions

View File

@ -1685,10 +1685,11 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
}
} // END INIT
// host id can change
if (info != null && vm.getState() == State.Running){
// check for host id changed
Host host = _hostDao.findByGuid(info.getHostUuid());
if (host.getId() != vm.getHostId()){
if (info != null && vm.getState() == State.Running){
// check for host id changes
Host host = _hostDao.findByGuid(info.getHostUuid());
if (host != null && (vm.getHostId() == null || host.getId() != vm.getHostId())){
s_logger.info("Found vm " + vm.getInstanceName() + " with inconsistent host in db, new host is " + host.getId());
try {
stateTransitTo(vm, VirtualMachine.Event.AgentReportMigrated, host.getId());
} catch (NoTransitionException e) {
@ -1700,6 +1701,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
}
for (final AgentVmInfo left : infos.values()) {
if (VirtualMachineName.isValidVmName(left.name)) continue; // if the vm follows cloudstack naming ignore it for stopping
try {
Host host = _hostDao.findByGuid(left.getHostUuid());
if (host != null){