Arik Hadas has uploaded a new change for review.

Change subject: core: refactor RunVmCommand#initCreateVmParams
......................................................................

core: refactor RunVmCommand#initCreateVmParams

Change-Id: I08b3fe66cb6205afbda9499b5b02e653f17d4b3a
Signed-off-by: Arik Hadas <aha...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
1 file changed, 10 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/29/21229/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
index 7ae6401..dbd7c3c 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
@@ -487,26 +487,25 @@
         VM vmToBeCreated = getVm();
         vmToBeCreated.setRunOnce(false);
         vmToBeCreated.setCpuName(getVdsGroup().getcpu_name());
+
         if (!vmToBeCreated.getInterfaces().isEmpty()) {
             initParametersForExternalNetworks();
         }
 
-        if (vmToBeCreated.getStatus() == VMStatus.Suspended) {
-            return new CreateVmVDSCommandParameters(getVdsId(), vmToBeCreated);
+        boolean useMemoryFromSnapshot = memorySnapshotSupported && 
!memoryFromSnapshotIrrelevant;
+
+        // if the VM is suspended then it already contains hibernation volumes,
+        // otherwise, we set it according to the memory from the active 
snapshot
+        if (vmToBeCreated.getStatus() != VMStatus.Suspended) {
+            vmToBeCreated.setHibernationVolHandle(useMemoryFromSnapshot ? 
memoryVolumeFromSnapshot : StringUtils.EMPTY);
         }
 
-        if (!memorySnapshotSupported || memoryFromSnapshotIrrelevant) {
-            vmToBeCreated.setHibernationVolHandle(StringUtils.EMPTY);
-            return new CreateVmVDSCommandParameters(getVdsId(), vmToBeCreated);
-        }
-
-        // otherwise, use the memory that is saved on the active snapshot 
(might be empty)
-        vmToBeCreated.setHibernationVolHandle(memoryVolumeFromSnapshot);
         CreateVmVDSCommandParameters parameters =
                 new CreateVmVDSCommandParameters(getVdsId(), vmToBeCreated);
         // Mark that the hibernation volume should be cleared from the VM 
right after the sync part of
-        // the create verb is finished (unlike hibernation volume that is 
created by hibernate command)
-        parameters.setClearHibernationVolumes(true);
+        // the create verb is finished if we are using memory from snapshot
+        parameters.setClearHibernationVolumes(useMemoryFromSnapshot);
+
         return parameters;
     }
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I08b3fe66cb6205afbda9499b5b02e653f17d4b3a
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