mirror of https://github.com/apache/cloudstack.git
COVERITY: Fixed issues reported by coverity NPEs, unwritten field access and self assignment
Signed-off-by: Sebastien Goasguen <runseb@gmail.com>
This commit is contained in:
parent
44c8e1f67f
commit
85bed5fa2b
|
|
@ -760,8 +760,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
try {
|
||||
orchestrateStart(vmUuid, params, planToDeploy, planner);
|
||||
} finally {
|
||||
if (VmJobEnabled.value())
|
||||
if (placeHolder != null) {
|
||||
_workJobDao.expunge(placeHolder.getId());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Outcome<VirtualMachine> outcome = startVmThroughJobQueue(vmUuid, params, planToDeploy);
|
||||
|
|
@ -1311,8 +1312,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
try {
|
||||
orchestrateStop(vmUuid, cleanUpEvenIfUnableToStop);
|
||||
} finally {
|
||||
if (VmJobEnabled.value())
|
||||
if (placeHolder != null) {
|
||||
_workJobDao.expunge(placeHolder.getId());
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
@ -1405,7 +1407,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Unable to transition the state but we're moving on because it's forced stop");
|
||||
}
|
||||
if (state == State.Starting || state == State.Migrating) {
|
||||
if ((state == State.Starting) || (state == State.Migrating) || (state == State.Stopping)) {
|
||||
if (work != null) {
|
||||
doCleanup = true;
|
||||
} else {
|
||||
|
|
@ -1414,8 +1416,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
}
|
||||
throw new CloudRuntimeException("Work item not found, We cannot stop " + vm + " when it is in state " + vm.getState());
|
||||
}
|
||||
} else if (state == State.Stopping) {
|
||||
doCleanup = true;
|
||||
}
|
||||
|
||||
if (doCleanup) {
|
||||
|
|
@ -1619,8 +1619,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
try {
|
||||
orchestrateStorageMigration(vmUuid, destPool);
|
||||
} finally {
|
||||
if (VmJobEnabled.value())
|
||||
if (placeHolder != null) {
|
||||
_workJobDao.expunge(placeHolder.getId());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Outcome<VirtualMachine> outcome = migrateVmStorageThroughJobQueue(vmUuid, destPool);
|
||||
|
|
@ -1711,8 +1712,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
try {
|
||||
orchestrateMigrate(vmUuid, srcHostId, dest);
|
||||
} finally {
|
||||
if (VmJobEnabled.value())
|
||||
if (placeHolder != null) {
|
||||
_workJobDao.expunge(placeHolder.getId());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Outcome<VirtualMachine> outcome = migrateVmThroughJobQueue(vmUuid, srcHostId, dest);
|
||||
|
|
@ -1993,8 +1995,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
try {
|
||||
orchestrateMigrateWithStorage(vmUuid, srcHostId, destHostId, volumeToPool);
|
||||
} finally {
|
||||
if (VmJobEnabled.value())
|
||||
if (placeHolder != null) {
|
||||
_workJobDao.expunge(placeHolder.getId());
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
@ -2289,8 +2292,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
try {
|
||||
orchestrateReboot(vmUuid, params);
|
||||
} finally {
|
||||
if (VmJobEnabled.value())
|
||||
if (placeHolder != null) {
|
||||
_workJobDao.expunge(placeHolder.getId());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Outcome<VirtualMachine> outcome = rebootVmThroughJobQueue(vmUuid, params);
|
||||
|
|
@ -3104,12 +3108,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
public String platform;
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public AgentVmInfo(String name, VMInstanceVO vm, State state, String host, String platform) {
|
||||
this.name = name;
|
||||
this.state = state;
|
||||
this.vm = vm;
|
||||
hostUuid = host;
|
||||
this.hostUuid = host;
|
||||
this.platform = platform;
|
||||
|
||||
}
|
||||
|
|
@ -3224,8 +3227,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
try {
|
||||
return orchestrateAddVmToNetwork(vm, network, requested);
|
||||
} finally {
|
||||
if (VmJobEnabled.value())
|
||||
if (placeHolder != null) {
|
||||
_workJobDao.expunge(placeHolder.getId());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Outcome<VirtualMachine> outcome = addVmToNetworkThroughJobQueue(vm, network, requested);
|
||||
|
|
@ -3235,7 +3239,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException("Operation is interrupted", e);
|
||||
} catch (java.util.concurrent.ExecutionException e) {
|
||||
throw new RuntimeException("Execution excetion", e);
|
||||
throw new RuntimeException("Execution exception", e);
|
||||
}
|
||||
|
||||
Object jobException = _jobMgr.unmarshallResultObject(outcome.getJob());
|
||||
|
|
@ -3336,8 +3340,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
try {
|
||||
return orchestrateRemoveNicFromVm(vm, nic);
|
||||
} finally {
|
||||
if (VmJobEnabled.value())
|
||||
if (placeHolder != null) {
|
||||
_workJobDao.expunge(placeHolder.getId());
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
@ -3583,8 +3588,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
try {
|
||||
orchestrateMigrateForScale(vmUuid, srcHostId, dest, oldSvcOfferingId);
|
||||
} finally {
|
||||
if (VmJobEnabled.value())
|
||||
if (placeHolder != null) {
|
||||
_workJobDao.expunge(placeHolder.getId());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Outcome<VirtualMachine> outcome = migrateVmForScaleThroughJobQueue(vmUuid, srcHostId, dest, oldSvcOfferingId);
|
||||
|
|
@ -3842,8 +3848,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
try {
|
||||
return orchestrateReConfigureVm(vmUuid, oldServiceOffering, reconfiguringOnExistingHost);
|
||||
} finally {
|
||||
if (VmJobEnabled.value())
|
||||
if (placeHolder != null) {
|
||||
_workJobDao.expunge(placeHolder.getId());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Outcome<VirtualMachine> outcome = reconfigureVmThroughJobQueue(vmUuid, oldServiceOffering, reconfiguringOnExistingHost);
|
||||
|
|
@ -3894,7 +3901,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
work.setStep(Step.Prepare);
|
||||
work.setResourceType(ItWorkVO.ResourceType.Host);
|
||||
work.setResourceId(vm.getHostId());
|
||||
work = _workDao.persist(work);
|
||||
_workDao.persist(work);
|
||||
boolean success = false;
|
||||
try {
|
||||
if (reconfiguringOnExistingHost) {
|
||||
|
|
@ -3916,8 +3923,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
} catch (AgentUnavailableException e) {
|
||||
throw e;
|
||||
} finally {
|
||||
// work.setStep(Step.Done);
|
||||
//_workDao.update(work.getId(), work);
|
||||
if (!success) {
|
||||
_capacityMgr.releaseVmCapacity(vm, false, false, vm.getHostId()); // release the new capacity
|
||||
vm.setServiceOfferingId(oldServiceOffering.getId());
|
||||
|
|
|
|||
Loading…
Reference in New Issue