Liron Ar has uploaded a new change for review.

Change subject: core: fix of export without tasks and snapshot collapse
......................................................................

core: fix of export without tasks and snapshot collapse

The following patch handles the following issues:
*The loop should be performed for disks relevant to the snapshot only.

*The populated image id's list should contain only exported images.

*When exporting a vm with no created tasks and collapse, the collapse
operations should be done - otherwise we will never have the snapshots 
collapsed when there are no created tasks.

*The unlock of the vm should be the last step, as otherwise the vm
configuration might change during the run and yield to inconsistent
results.

Change-Id: I1bfc2761a5483d6f0b274d064cbc7e155562573f
Signed-off-by: Liron Aravot <lara...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ExportVmCommand.java
1 file changed, 3 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/11/21111/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ExportVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ExportVmCommand.java
index 46f2775..bb55337 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ExportVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ExportVmCommand.java
@@ -27,7 +27,6 @@
 import org.ovirt.engine.core.common.asynctasks.EntityInfo;
 import org.ovirt.engine.core.common.businessentities.CopyVolumeType;
 import org.ovirt.engine.core.common.businessentities.Disk;
-import org.ovirt.engine.core.common.businessentities.Disk.DiskStorageType;
 import org.ovirt.engine.core.common.businessentities.DiskImage;
 import org.ovirt.engine.core.common.businessentities.Snapshot;
 import org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotType;
@@ -213,7 +212,7 @@
         // Means that there are no asynchronous tasks to execute - so we can 
end the command
         // immediately after the execution of the previous steps
         if (!hasSnappableDisks() && snapshotsWithMemory.isEmpty()) {
-            endSuccessfullySynchronous();
+            endSuccessfully();
         } else {
             TransactionSupport.executeInNewTransaction(new 
TransactionMethod<Void>() {
 
@@ -248,8 +247,7 @@
         }
 
         List<Guid> imageGroupIds = new ArrayList<>();
-        for (Disk disk : vm.getDiskMap().values()) {
-            if (DiskStorageType.IMAGE == disk.getDiskStorageType() && 
!disk.isShareable()) {
+        for (Disk disk : getDisksBasedOnImage()) {
                 DiskImage diskImage = (DiskImage) disk;
                 diskImage.setParentId(VmTemplateHandler.BlankVmTemplateId);
                 
diskImage.setImageTemplateId(VmTemplateHandler.BlankVmTemplateId);
@@ -270,7 +268,6 @@
                 }
                 AllVmImages.add(diskImage);
                 imageGroupIds.add(disk.getId());
-            }
         }
 
         if (StringUtils.isEmpty(vm.getVmtName())) {
@@ -507,13 +504,13 @@
     protected void endSuccessfully() {
         endActionOnAllImageGroups();
         VM vm = getVm();
-        VmHandler.unLockVm(vm);
         populateVmData(vm);
         if (getParameters().getCopyCollapse()) {
             endCopyCollapseOperations(vm);
         } else {
             updateSnapshotOvf(vm);
         }
+        VmHandler.unLockVm(vm);
         setSucceeded(true);
     }
 
@@ -536,14 +533,6 @@
     private void updateSnapshotOvf(VM vm) {
         
vm.setSnapshots(getDbFacade().getSnapshotDao().getAllWithConfiguration(getVm().getId()));
         updateVmImSpm();
-    }
-
-    protected void endSuccessfullySynchronous() {
-        VM vm = getVm();
-        VmHandler.unLockVm(vm);
-        VmDeviceUtils.setVmDevices(vm.getStaticData());
-        this.updateSnapshotOvf(vm);
-        setSucceeded(true);
     }
 
     @Override


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1bfc2761a5483d6f0b274d064cbc7e155562573f
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.3
Gerrit-Owner: Liron Ar <lara...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to