You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ko...@apache.org on 2014/06/10 11:04:22 UTC

git commit: updated refs/heads/4.4-forward to 390e498

Repository: cloudstack
Updated Branches:
  refs/heads/4.4-forward a1f278e9d -> 390e498dc


Fixed issues reported by coverity NPEs, unwritten field access and self assignment

Signed-off-by: Koushik Das <ko...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/390e498d
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/390e498d
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/390e498d

Branch: refs/heads/4.4-forward
Commit: 390e498dc58a89f0b060c50e5b796061bc97342e
Parents: a1f278e
Author: Rajani Karuturi <ra...@gmail.com>
Authored: Tue Jun 10 13:52:43 2014 +0530
Committer: Koushik Das <ko...@apache.org>
Committed: Tue Jun 10 14:23:43 2014 +0530

----------------------------------------------------------------------
 .../com/cloud/vm/VirtualMachineManagerImpl.java | 49 +++++++++++---------
 1 file changed, 27 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/390e498d/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
index 9b63043..4502365 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -775,8 +775,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, planner);
@@ -1352,8 +1353,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
             try {
                 orchestrateStop(vmUuid, cleanUpEvenIfUnableToStop);
             } finally {
-                if (VmJobEnabled.value())
+                if (placeHolder != null) {
                     _workJobDao.expunge(placeHolder.getId());
+                }
             }
 
         } else {
@@ -1451,7 +1453,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 {
@@ -1460,8 +1462,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) {
@@ -1681,8 +1681,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);
@@ -1775,8 +1776,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);
@@ -2072,8 +2074,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 {
@@ -2418,8 +2421,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);
@@ -3282,12 +3286,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
         public String hostUuid;
         public VMInstanceVO vm;
 
-        @SuppressWarnings("unchecked")
         public AgentVmInfo(String name, VMInstanceVO vm, State state, String host) {
-            name = name;
-            state = state;
-            vm = vm;
-            hostUuid = host;
+            this.name = name;
+            this.state = state;
+            this.vm = vm;
+            this.hostUuid = host;
         }
 
         public AgentVmInfo(String name, VMInstanceVO vm, State state) {
@@ -3392,8 +3395,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);
@@ -3403,7 +3407,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());
@@ -3506,8 +3510,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 {
@@ -3758,8 +3763,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);
@@ -4021,8 +4027,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);
@@ -4074,7 +4081,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) {
@@ -4096,8 +4103,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());