Maor Lipchuk has uploaded a new change for review.

Change subject: core: Fix NPE when committing a snapshot.
......................................................................

core: Fix NPE when committing a snapshot.

A regression caused by commit 268152abf19fbd64fd867bc5e5e40a57996aedc7
made the commit snapshot to throw NPE when commiting a snapshot, since
the new snapshot id has been created twice, once for the snapshots table
and once for the vm_snapshot_id of the image.

The fix set the parameter only once.

Change-Id: If423dd90739cd14a66a7a62399f56465a2e30021
Bug-Url: https://bugzilla.redhat.com/981367
Signed-off-by: Maor Lipchuk <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java
1 file changed, 6 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/57/16457/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 b56b1e1..6b7b317 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
@@ -70,6 +70,7 @@
     /** flag that indicates whether memory snapshot is about to be created */
     private boolean prepareForMemorySnapshot;
     private String cachedSnapshotIsBeingTakenMessage;
+    private Guid newActiveSnapshotId = Guid.newGuid();
 
     protected CreateAllSnapshotsFromVmCommand(Guid commandId) {
         super(commandId);
@@ -110,17 +111,15 @@
 
     @Override
     protected void buildChildCommandInfos() {
-        Guid vmSnapshotId = Guid.newGuid();
         for (DiskImage image : getDisksList()) {
             addChildCommandInfo(image.getImageId(),
                     VdcActionType.CreateSnapshot,
-                    buildCreateSnapshotParameters(image, vmSnapshotId));
+                    buildCreateSnapshotParameters(image));
         }
     }
 
     @Override
     protected void executeVmCommand() {
-        Guid newActiveSnapshotId = Guid.newGuid();
         Guid createdSnapshotId = getSnapshotDao().getId(getVmId(), 
SnapshotType.ACTIVE);
         getParameters().setSnapshotType(determineSnapshotType());
         getParameters().setInitialVmStatus(getVm().getStatus());
@@ -131,7 +130,7 @@
 
         MemoryImageBuilder memoryImageBuilder = createMemoryImageBuilder();
         addSnapshotToDB(createdSnapshotId, memoryImageBuilder);
-        createSnapshotsForDisks(newActiveSnapshotId);
+        createSnapshotsForDisks();
         memoryImageBuilder.build();
 
         if (getTaskIdList().isEmpty()) {
@@ -186,9 +185,8 @@
                 getCompensationContext());
     }
 
-    private void createSnapshotsForDisks(Guid vmSnapshotId) {
+    private void createSnapshotsForDisks() {
         for (DiskImage image : getDisksList()) {
-
             VdcReturnValueBase vdcReturnValue = 
executeChildCommand(image.getImageId());
 
             if (vdcReturnValue.getSucceeded()) {
@@ -200,7 +198,7 @@
         }
     }
 
-    private ImagesActionsParametersBase 
buildCreateSnapshotParameters(DiskImage image, Guid snapshotId) {
+    private ImagesActionsParametersBase 
buildCreateSnapshotParameters(DiskImage image) {
         VdcActionType parentCommand = getParameters().getParentCommand() != 
VdcActionType.Unknown ?
                 getParameters().getParentCommand() : 
VdcActionType.CreateAllSnapshotsFromVm;
 
@@ -208,7 +206,7 @@
         result.setDescription(getParameters().getDescription());
         result.setSessionId(getParameters().getSessionId());
         result.setQuotaId(image.getQuotaId());
-        result.setVmSnapshotId(snapshotId);
+        result.setVmSnapshotId(newActiveSnapshotId);
         result.setEntityInfo(getParameters().getEntityInfo());
         result.setParentCommand(parentCommand);
         result.setParentParameters(getParametersForTask(parentCommand, 
getParameters()));


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

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

Reply via email to