Source:
private void handleBackwardLiveMerge(DiskImage topImage, DiskImage baseImage, DiskImage imageFromVdsm) { List<DiskImage> children = DbFacade.getInstance().getDiskImageDao() .getAllSnapshotsForParent(topImage.getImageId()); if (!children.isEmpty()) { DiskImage childImage = children.get(0); childImage.setParentId(baseImage.getImageId()); getImageDao().update(childImage.getImage()); } Image oldTopImage = topImage.getImage(); topImage.setImage(baseImage.getImage()); baseImage.setImage(oldTopImage); Guid oldTopSnapshotId = topImage.getImage().getSnapshotId(); topImage.getImage().setSnapshotId(baseImage.getImage().getSnapshotId()); baseImage.getImage().setSnapshotId(oldTopSnapshotId); boolean oldTopIsActive = topImage.getImage().isActive(); topImage.getImage().setActive(baseImage.getImage().isActive()); VolumeClassification baseImageVolumeClassification = VolumeClassification.getVolumeClassificationByActiveFlag(baseImage.getImage().isActive()); topImage.getImage().setVolumeClassification(baseImageVolumeClassification); baseImage.getImage().setActive(oldTopIsActive); VolumeClassification oldTopVolumeClassification = VolumeClassification.getVolumeClassificationByActiveFlag(oldTopIsActive); topImage.getImage().setVolumeClassification(oldTopVolumeClassification); topImage.setActualSizeInBytes(imageFromVdsm.getActualSizeInBytes()); topImage.setImageStatus(ImageStatus.OK); getBaseDiskDao().update(topImage); getImageDao().update(topImage.getImage()); updateDiskImageDynamic(imageFromVdsm, topImage); getBaseDiskDao().update(baseImage); getImageDao().update(baseImage.getImage()); updateVmConfigurationForImageChange(topImage.getImage().getSnapshotId(), baseImage.getImageId(), topImage); updateVmConfigurationForImageRemoval(baseImage.getImage().getSnapshotId(), topImage.getImageId()); }

Target:
private void handleBackwardLiveMerge(DiskImage topImage, DiskImage baseImage, DiskImage imageFromVdsm) { List<DiskImage> children = DbFacade.getInstance().getDiskImageDao() .getAllSnapshotsForParent(topImage.getImageId()); if (!children.isEmpty()) { DiskImage childImage = children.get(0); childImage.setParentId(baseImage.getImageId()); getImageDao().update(childImage.getImage()); } Image oldTopImage = topImage.getImage(); topImage.setImage(baseImage.getImage()); baseImage.setImage(oldTopImage); Guid oldTopSnapshotId = topImage.getImage().getSnapshotId(); topImage.getImage().setSnapshotId(baseImage.getImage().getSnapshotId()); baseImage.getImage().setSnapshotId(oldTopSnapshotId); boolean oldTopIsActive = topImage.getImage().isActive(); topImage.getImage().setActive(baseImage.getImage().isActive()); VolumeClassification baseImageVolumeClassification = VolumeClassification.getVolumeClassificationByActiveFlag(baseImage.getImage().isActive()); topImage.getImage().setVolumeClassification(baseImageVolumeClassification); baseImage.getImage().setActive(oldTopIsActive); VolumeClassification oldTopVolumeClassification = VolumeClassification.getVolumeClassificationByActiveFlag(oldTopIsActive); topImage.getImage().setVolumeClassification(oldTopVolumeClassification); topImage.setSize(baseImage.getSize()); topImage.setActualSizeInBytes(imageFromVdsm.getActualSizeInBytes()); topImage.setImageStatus(ImageStatus.OK); getBaseDiskDao().update(topImage); getImageDao().update(topImage.getImage()); updateDiskImageDynamic(imageFromVdsm, topImage); getBaseDiskDao().update(baseImage); getImageDao().update(baseImage.getImage()); updateVmConfigurationForImageChange(topImage.getImage().getSnapshotId(), baseImage.getImageId(), topImage); updateVmConfigurationForImageRemoval(baseImage.getImage().getSnapshotId(), topImage.getImageId()); }