Bug 11457 - NullPointerException while synching VM state from Starting -> Running between management server and agent

reviewed-by: Alex/Kelven

Changes:
1.	UserVmManagerImpl :: finalizeStart()
Added null check for the cmds.getAnswers() object. Return ‘true’ if null.

2.	VirtualMachineManagerImpl :: advanceStart()
Move the line to set PodId to the vm being started above the state transition where hostId gets set, so that podId is not null in case management server goes down when vm starts on the agent. On restart, podId is not updated during fullsync. So this will prevent podId remaining null.

vm.setPodId(dest.getPod().getId());
This commit is contained in:
prachi 2011-09-15 14:46:49 -07:00
parent bc724d702e
commit df17ce5648
2 changed files with 9 additions and 1 deletions

View File

@ -2751,6 +2751,14 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
@Override
public boolean finalizeStart(VirtualMachineProfile<UserVmVO> profile, long hostId, Commands cmds, ReservationContext context) {
UserVmVO vm = profile.getVirtualMachine();
Answer[] answersToCmds = cmds.getAnswers();
if(answersToCmds == null){
if(s_logger.isDebugEnabled()){
s_logger.debug("Returning from finalizeStart() since there are no answers to read");
}
return true;
}
Answer startAnswer = cmds.getAnswer(StartAnswer.class);
String returnedIp = null;
String originalIp = null;

View File

@ -692,6 +692,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
}
long destHostId = dest.getHost().getId();
vm.setPodId(dest.getPod().getId());
try {
if (!changeState(vm, Event.OperationRetry, destHostId, work, Step.Prepare)) {
@ -715,7 +716,6 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
cmds.addCommand(new StartCommand(vmTO));
vmGuru.finalizeDeployment(cmds, vmProfile, dest, ctx);
vm.setPodId(dest.getPod().getId());
work = _workDao.findById(work.getId());
if (work == null || work.getStep() != Step.Prepare) {