Liron Aravot has uploaded a new change for review.

Change subject: core: exception while removing floating disk (#828192)
......................................................................

core: exception while removing floating disk (#828192)

related to bug https://bugzilla.redhat.com/828192

when trying to remove a floating disk NPE was encountered, because of an
attempt to acquire lock on the disk's vm id. as the disk wasn't a part
of vm there was a NPE.

Change-Id: I5e9ea9599dccbf0ab18609d579c03fd342266378
Signed-off-by: Liron Aravot <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveImageCommand.java
1 file changed, 8 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/05/7705/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveImageCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveImageCommand.java
index 1992be8..cfcbff7 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveImageCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveImageCommand.java
@@ -104,17 +104,19 @@
 
     private void removeImageFromDB(boolean isLockOnSnapshotsNeeded) {
         final DiskImage diskImage = getDiskImage();
-        final List<Snapshot> updatedSnapshots;
         final boolean shouldPerformOpOnVmSnapshots = isLockOnSnapshotsNeeded 
&& !diskImage.isShareable();
 
         try {
+            List<Snapshot> snapshotsForProcessing = Collections.emptyList();
             if (shouldPerformOpOnVmSnapshots) {
                 VM vm = getVmForNonShareableDiskImage(diskImage);
-                lockVmSnapshotsWithWait(vm);
-                updatedSnapshots = 
prepareSnapshotConfigWithoutImage(diskImage.getId());
-            } else {
-                updatedSnapshots = Collections.emptyList();
+                if (vm != null) {
+                    lockVmSnapshotsWithWait(vm);
+                    snapshotsForProcessing = 
prepareSnapshotConfigWithoutImage(diskImage.getId());
+                }
             }
+
+            final List<Snapshot> snapshotsForNewTransaction = 
snapshotsForProcessing;
 
             TransactionSupport.executeInScope(TransactionScopeOption.Required,
                     new TransactionMethod<Object>() {
@@ -145,7 +147,7 @@
                             getBaseDiskDao().remove(diskImage.getId());
                             getVmDeviceDAO().remove(new 
VmDeviceId(diskImage.getId(), null));
 
-                            for (Snapshot s : updatedSnapshots) {
+                            for (Snapshot s : snapshotsForNewTransaction) {
                                 getSnapshotDao().update(s);
                             }
 


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

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

Reply via email to