Daniel Erez has uploaded a new change for review.

Change subject: core: register RemoveSnapshotCommandCallback only for a running 
VM
......................................................................

core: register RemoveSnapshotCommandCallback only for a running VM

RemoveSnapshotCommand - registering RemoveSnapshotCommandCallback
for a non running VM is redundant and lead to an exception as described
in the bug. Hence, adding the callback only for a running VM.

Change-Id: I1f2440a6860dbdd5ece5c3979c710e90ccaa3929
Bug-Url: https://bugzilla.redhat.com/1148710
Signed-off-by: Daniel Erez <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveSnapshotCommand.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VMStatus.java
3 files changed, 18 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/19/33919/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveSnapshotCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveSnapshotCommand.java
index 9b9ff16..eab311a 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveSnapshotCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveSnapshotCommand.java
@@ -424,7 +424,7 @@
     }
 
     private VdcActionType getSnapshotActionType() {
-        return getVm().isDown() ? VdcActionType.RemoveSnapshotSingleDisk : 
VdcActionType.RemoveSnapshotSingleDiskLive;
+        return getVm().isQualifiedForLiveSnapshotMerge() ? 
VdcActionType.RemoveSnapshotSingleDiskLive : 
VdcActionType.RemoveSnapshotSingleDisk;
     }
 
     @Override
@@ -445,6 +445,6 @@
 
     @Override
     public CommandCallBack getCallBack() {
-        return new RemoveSnapshotCommandCallback();
+        return getVm().isQualifiedForLiveSnapshotMerge() ? new 
RemoveSnapshotCommandCallback() : null;
     }
 }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java
index 00ee3cf..2faacc4 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java
@@ -1616,6 +1616,10 @@
         return getStatus().isQualifiedForSnapshotMerge();
     }
 
+    public boolean isQualifiedForLiveSnapshotMerge() {
+        return getStatus().isQualifiedForLiveSnapshotMerge();
+    }
+
     public boolean isRunningAndQualifyForDisksMigration() {
         return getStatus().isUpOrPaused() && getRunOnVds() != null && 
!getRunOnVds().equals(Guid.Empty);
     }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VMStatus.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VMStatus.java
index dd19052..5f66d70 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VMStatus.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VMStatus.java
@@ -73,7 +73,18 @@
      * may be possible, otherwise false
      */
     public boolean isQualifiedForSnapshotMerge() {
-        return this == Up || this == PoweringUp || this == Paused || this == 
RebootInProgress || this == Down;
+        return isQualifiedForLiveSnapshotMerge() || this == Down;
+    }
+
+    /**
+     * This method reflects whether the VM is qualified to have its snapshots 
live merged.
+     * For this to be true, the VM must up with qemu in a non-transient state.
+     *
+     * @return true if this status indicates that the VM status indicates that 
snapshot live merge
+     * may be possible, otherwise false
+     */
+    public boolean isQualifiedForLiveSnapshotMerge() {
+        return this == Up || this == PoweringUp || this == Paused || this == 
RebootInProgress;
     }
 
     /**


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

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

Reply via email to