Daniel Erez has uploaded a new change for review.

Change subject: core: prevent illegal disk on custom preview active snapshot
......................................................................

core: prevent illegal disk on custom preview active snapshot

* SnapshotVmConfigurationHelper:
  avoid marking disks as illegal for a 'PREVIEW' snapshot
  as it represents previous 'Active VM' state.
* SnapshotsManager -> attempToRestoreVmConfigurationFromSnapshot:
  updating images according the specified list when VmConfiguration
  is not available (i.e. custom snapshoting to active VM).

Change-Id: I1561107e05de155f9483e1f8a00d2dba3a4ab342
Bug-Url: https://bugzilla.redhat.com/1064067
Signed-off-by: Daniel Erez <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/snapshots/SnapshotVmConfigurationHelper.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/snapshots/SnapshotsManager.java
2 files changed, 11 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/04/24804/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/snapshots/SnapshotVmConfigurationHelper.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/snapshots/SnapshotVmConfigurationHelper.java
index 8de63e2..e71b663 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/snapshots/SnapshotVmConfigurationHelper.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/snapshots/SnapshotVmConfigurationHelper.java
@@ -9,6 +9,7 @@
 import org.ovirt.engine.core.common.businessentities.Disk;
 import org.ovirt.engine.core.common.businessentities.DiskImage;
 import org.ovirt.engine.core.common.businessentities.ImageStatus;
+import org.ovirt.engine.core.common.businessentities.Snapshot;
 import org.ovirt.engine.core.common.businessentities.VM;
 import 
org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface;
 import org.ovirt.engine.core.compat.Guid;
@@ -38,7 +39,12 @@
         VM vm;
         if (configuration != null) {
             vm = getVmWithConfiguration(configuration, vmId);
-            markImagesIllegalIfNotInDb(vm, snapshotId);
+            Snapshot snapshot = getSnapshotDao().get(snapshotId);
+            if (snapshot != null && snapshot.getType() != 
Snapshot.SnapshotType.PREVIEW) {
+                // No need to mark disks of 'PREVIEW' snapshot as illegal
+                // as it represents previous 'Active VM' state.
+                markImagesIllegalIfNotInDb(vm, snapshotId);
+            }
         } else {
             vm = getVmWithoutConfiguration(vmId, snapshotId);
         }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/snapshots/SnapshotsManager.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/snapshots/SnapshotsManager.java
index 69f695e..a775086 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/snapshots/SnapshotsManager.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/snapshots/SnapshotsManager.java
@@ -416,7 +416,10 @@
         }
 
         if (!vmUpdatedFromConfiguration) {
-            vm.setImages(new 
ArrayList<DiskImage>(getDiskImageDao().getAllSnapshotsForVmSnapshot(snapshot.getId())));
+            if (images == null) {
+                images = 
getDiskImageDao().getAllSnapshotsForVmSnapshot(snapshot.getId());
+            }
+            vm.setImages(new ArrayList<>(images));
         }
 
         vm.setAppList(snapshot.getAppList());


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1561107e05de155f9483e1f8a00d2dba3a4ab342
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Daniel Erez <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to