Arik Hadas has uploaded a new change for review.

Change subject: core: aaa
......................................................................

core: aaa

Change-Id: I8a3a10864d64e67a36942e01869b8f41c67f032a
Signed-off-by: Arik Hadas <aha...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
2 files changed, 35 insertions(+), 46 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/44/23644/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java
index a536940..b072f74 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java
@@ -379,28 +379,14 @@
     }
 
     @Override
-    public void runningSucceded() {
-        try {
-            super.runningSucceded();
-        }
-        finally {
-            freeLock();
-        }
-    }
-
-    @Override
     public void reportCompleted() {
         try {
-            super.reportCompleted();
+            // Decrement the pending counters here as this is the only place 
which
+            // is called consistently regardless of the migration result.
+            decreasePendingVms(getVdsDestinationId());
         }
         finally {
-            /*
-             * Decrement the pending counters here as this is the only place 
which
-             * is called consistently regardless of the migration result.
-             */
-            decreasePendingVms(getVdsDestinationId());
-
-            freeLock();
+            super.reportCompleted();    
         }
     }
 
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
index 187a822..1b2f3dc 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
@@ -152,31 +152,36 @@
      */
     @Override
     public void runningSucceded() {
-        setSucceeded(true);
-        setActionReturnValue(VMStatus.Up);
-        log();
-        ExecutionHandler.setAsyncJob(getExecutionContext(), false);
-        ExecutionHandler.endJob(getExecutionContext(), true);
-        notifyHostsVmFailed();
+        try {
+            setSucceeded(true);
+            setActionReturnValue(VMStatus.Up);
+            log();
+            ExecutionHandler.setAsyncJob(getExecutionContext(), false);
+            ExecutionHandler.endJob(getExecutionContext(), true);
+            notifyHostsVmFailed();
 
-        if (getVm().getLastVdsRunOn() == null || 
!getVm().getLastVdsRunOn().equals(getCurrentVdsId())) {
-            getVm().setLastVdsRunOn(getCurrentVdsId());
+            if (getVm().getLastVdsRunOn() == null || 
!getVm().getLastVdsRunOn().equals(getCurrentVdsId())) {
+                getVm().setLastVdsRunOn(getCurrentVdsId());
+            }
+
+            if (StringUtils.isNotEmpty(getVm().getHibernationVolHandle())) {
+                removeVmHibernationVolumes();
+
+                // In order to prevent a race where VdsUpdateRuntimeInfo saves 
the Vm Dynamic as UP prior to execution of
+                // this method (which is a part of the cached VM command,
+                // so the state this method is aware to is RESTORING, in case 
of RunVmCommand after the VM got suspended.
+                // In addition, as the boolean return value of 
HandleHIbernateVm is ignored here, it is safe to set the
+                // status to up.
+                getVm().setStatus(VMStatus.Up);
+                getVm().setHibernationVolHandle(null);
+                Backend.getInstance()
+                .getResourceManager()
+                .RunVdsCommand(VDSCommandType.UpdateVmDynamicData,
+                        new 
UpdateVmDynamicDataVDSCommandParameters(getCurrentVdsId(), 
getVm().getDynamicData()));
+            }
         }
-
-        if (StringUtils.isNotEmpty(getVm().getHibernationVolHandle())) {
-            removeVmHibernationVolumes();
-
-            // In order to prevent a race where VdsUpdateRuntimeInfo saves the 
Vm Dynamic as UP prior to execution of
-            // this method (which is a part of the cached VM command,
-            // so the state this method is aware to is RESTORING, in case of 
RunVmCommand after the VM got suspended.
-            // In addition, as the boolean return value of HandleHIbernateVm 
is ignored here, it is safe to set the
-            // status to up.
-            getVm().setStatus(VMStatus.Up);
-            getVm().setHibernationVolHandle(null);
-            Backend.getInstance()
-                    .getResourceManager()
-                    .RunVdsCommand(VDSCommandType.UpdateVmDynamicData,
-                            new 
UpdateVmDynamicDataVDSCommandParameters(getCurrentVdsId(), 
getVm().getDynamicData()));
+        finally {
+            freeLock();
         }
     }
 
@@ -290,14 +295,12 @@
         decreasePendingVms(vdsId, vm.getNumOfCpus(), vm.getMinAllocatedMem(), 
vm.getName());
     }
 
-    protected void decreasePendingVms(Guid vdsId, int numOfCpus, int 
minAllocatedMem, String vmName) {
+    private void decreasePendingVms(Guid vdsId, int numOfCpus, int 
minAllocatedMem, String vmName) {
         getVdsDynamicDao().updatePartialVdsDynamicCalc(vdsId, 0, -numOfCpus, 
-minAllocatedMem, 0, 0);
         getBlockingQueue(vdsId).offer(Boolean.TRUE);
 
-        if (log.isDebugEnabled()) {
-            log.debugFormat("Decreasing vds {0} pending vcpu count by {1} and 
vmem size by {2} (Vm: {3})",
-                    vdsId, numOfCpus, minAllocatedMem, vmName);
-        }
+        log.debugFormat("Decreasing vds {0} pending vcpu count by {1} and vmem 
size by {2} (Vm: {3})",
+                vdsId, numOfCpus, minAllocatedMem, vmName);
     }
 
     protected VdsDynamicDAO getVdsDynamicDao() {


-- 
To view, visit http://gerrit.ovirt.org/23644
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8a3a10864d64e67a36942e01869b8f41c67f032a
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Arik Hadas <aha...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to