bug 11324: merge fix from branch 2.2.10

This commit is contained in:
Kelven Yang 2011-09-02 15:36:35 -07:00
parent 4d3d47f01c
commit 4ef35767f5
2 changed files with 18 additions and 1 deletions

View File

@ -3179,7 +3179,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
}
if(oldState != State.Starting && oldState != State.Migrating) {
s_logger.debug("VM " + vm + " is now missing from host report and VM is not at starting state, remove it from host VM-sync map");
s_logger.debug("VM " + vm + " is now missing from host report and VM is not at starting/migrating state, remove it from host VM-sync map, oldState: " + oldState);
_vms.remove(vm);
} else {
s_logger.debug("VM " + vm + " is missing from host report, but we will ignore VM " + vm + " in transition state " + oldState);

View File

@ -221,8 +221,25 @@ public class VirtualMachineMO extends BaseMO {
String result = _context.getServiceUtil().waitForTask(morTask);
if(result.equals("sucess")) {
_context.waitForTaskProgressDone(morTask);
// It seems that even if a power-off task is returned done, VM state may still not be marked,
// wait up to 5 seconds to make sure to avoid race conditioning for immediate following on operations
// that relies on a powered-off VM
long startTick = System.currentTimeMillis();
while(getPowerState() != VirtualMachinePowerState.poweredOff && System.currentTimeMillis() - startTick < 5000) {
try {
Thread.sleep(1000);
} catch(InterruptedException e) {
}
}
return true;
} else {
if(getPowerState() == VirtualMachinePowerState.poweredOff) {
// to help deal with possible race-condition
s_logger.info("Current power-off task failed. However, VM has been switched to the state we are expecting for");
return true;
}
s_logger.error("VMware powerOffVM_Task failed due to " + TaskMO.getTaskFailureInfo(_context, morTask));
}