Daniel Erez has uploaded a new change for review. Change subject: core: clearing snapshot_id on disk detach ......................................................................
core: clearing snapshot_id on disk detach When detaching a DiskImage, the snapshot [1] ID should be cleared. Otherwise, 'DiskImageDAO -> getAllSnapshotsForVmSnapshot' returns floating DiskImages (which shouldn't be taken into account in any flow since they're not relevant with regards to snapshots). Note: when attaching a DiskImage, the snapshot ID is already updated properly according to the VM. [1] only an active snapshot since detaching a disk with snapshots is blocked at canDo phase. Change-Id: Iad60d2a6500f4bd738095949c7e36a4ec34122c3 Bug-Url: https://bugzilla.redhat.com/1015170 Signed-off-by: Daniel Erez <de...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/DetachDiskFromVmCommand.java 1 file changed, 7 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/95/19895/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/DetachDiskFromVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/DetachDiskFromVmCommand.java index 165a854..9927645 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/DetachDiskFromVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/DetachDiskFromVmCommand.java @@ -6,6 +6,7 @@ import org.ovirt.engine.core.common.action.AttachDettachVmDiskParameters; import org.ovirt.engine.core.common.businessentities.Disk; import org.ovirt.engine.core.common.businessentities.Disk.DiskStorageType; +import org.ovirt.engine.core.common.businessentities.DiskImage; import org.ovirt.engine.core.common.businessentities.VMStatus; import org.ovirt.engine.core.common.businessentities.VmDevice; import org.ovirt.engine.core.common.businessentities.VmDeviceId; @@ -77,6 +78,12 @@ performPlugCommand(VDSCommandType.HotUnPlugDisk, disk, vmDevice); } getVmDeviceDao().remove(vmDevice.getId()); + + if (disk.getDiskStorageType() == DiskStorageType.IMAGE) { + // clears snapshot ID + getImageDao().updateImageVmSnapshotId(((DiskImage) disk).getImageId(), Guid.Empty); + } + // update cached image VmHandler.updateDisksFromDb(getVm()); // update vm device boot order -- To view, visit http://gerrit.ovirt.org/19895 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iad60d2a6500f4bd738095949c7e36a4ec34122c3 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Daniel Erez <de...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches