Yair Zaslavsky has uploaded a new change for review.

Change subject: core: Fixing NPE in case of endCommand failure
......................................................................

core: Fixing NPE in case of endCommand failure

This is a suggestion on how to fix an NPE in
CreateAllSnapshotFromVmCommand that is caused by network error at
CreateSnapshotCommand (the child command).
The network error causes transaction rollback and removal of the
new snapshot entity (and making the old one non active).
I had to create this patch in order to verify previous patches in
this patchset.

Bug-Url: https://bugzilla.redhat.com/982003

Change-Id: I78a617f43bd297db13b7dc9ad6649b67c773c144
Signed-off-by: Yair Zaslavsky <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java
1 file changed, 14 insertions(+), 10 deletions(-)


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

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java
index 6b7b317..0cdeb5d 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java
@@ -250,17 +250,21 @@
                         }
                     }
                 } else {
-                    revertToActiveSnapshot(createdSnapshot.getId());
-                    // If the removed snapshot contained memory, remove the 
memory volumes
-                    // Note that the memory volumes might not have been created
-                    String memoryVolume = createdSnapshot.getMemoryVolume();
-                    if (!memoryVolume.isEmpty() &&
-                            
getSnapshotDao().getNumOfSnapshotsByMemory(memoryVolume) == 1) {
-                        boolean succeed = removeMemoryVolumes(memoryVolume, 
getActionType(), false);
-                        if (!succeed) {
-                            log.warnFormat("Failed to remove memory {0} of 
snapshot {1}",
-                                    memoryVolume, createdSnapshot.getId());
+                    if (createdSnapshot != null) {
+                        revertToActiveSnapshot(createdSnapshot.getId());
+                        // If the removed snapshot contained memory, remove 
the memory volumes
+                        // Note that the memory volumes might not have been 
created
+                        String memoryVolume = 
createdSnapshot.getMemoryVolume();
+                        if (!memoryVolume.isEmpty() &&
+                                
getSnapshotDao().getNumOfSnapshotsByMemory(memoryVolume) == 1) {
+                            boolean succeed = 
removeMemoryVolumes(memoryVolume, getActionType(), false);
+                            if (!succeed) {
+                                log.warnFormat("Failed to remove memory {0} of 
snapshot {1}",
+                                        memoryVolume, createdSnapshot.getId());
+                            }
                         }
+                    } else {
+                        log.infoFormat("No snapshot was created for VM {0} 
which is in LOCKED status", getVmId());
                     }
                 }
 


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

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

Reply via email to