bug 13439: update host id for running VMs if changed during full sync

reviewed-by: kishan
This commit is contained in:
abhi 2012-02-04 10:46:58 +05:30
parent f6dba09677
commit f50fa56b55
2 changed files with 17 additions and 3 deletions

View File

@ -6646,6 +6646,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
synchronized (_cluster.intern()) {
s_vms.clear(_cluster);
}
boolean success=false;
try {
Map<VM, VM.Record> vm_map = VM.getAllRecords(conn); //USE THIS TO GET ALL VMS FROM A CLUSTER
for (VM.Record record: vm_map.values()) {
@ -6661,6 +6662,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
host_uuid = host.getUuid(conn);
synchronized (_cluster.intern()) {
s_vms.put(_cluster, host_uuid, vm_name, state);
success=true;
}
}
if (s_logger.isTraceEnabled()) {
@ -6672,7 +6674,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
s_logger.warn(msg, e);
throw new CloudRuntimeException(msg);
}
return s_vms.getClusterVmState(_cluster);
return success ? s_vms.getClusterVmState(_cluster) : null;
}

View File

@ -1683,8 +1683,20 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
e.printStackTrace();
}
}
}
} // 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()){
try {
stateTransitTo(vm, VirtualMachine.Event.AgentReportMigrated, host.getId());
} catch (NoTransitionException e) {
s_logger.warn(e.getMessage());
}
}
}
}
for (final AgentVmInfo left : infos.values()) {