Source:
protected void executeRevertSnapshot(SnapshotInfo snapshotInfo, VolumeInfo volumeInfo) { Long hostId = null; boolean success = false; SnapshotVO snapshotVO = snapshotDao.acquireInLockTable(snapshotInfo.getId()); if (snapshotVO == null) { String errMsg = "Failed to acquire lock on the following snapshot: " + snapshotInfo.getId(); s_logger.error(errMsg); throw new CloudRuntimeException(errMsg); } try { volumeInfo.stateTransit(Volume.Event.RevertSnapshotRequested); if (getHypervisorRequiresResignature(volumeInfo)) { hostId = getHostId(volumeInfo); if (hostId != null) { HostVO hostVO = hostDao.findById(hostId); DataStore dataStore = dataStoreMgr.getDataStore(volumeInfo.getPoolId(), DataStoreRole.Primary); volService.revokeAccess(volumeInfo, hostVO, dataStore); modifyTarget(false, volumeInfo, hostId); } } success = snapshotSvr.revertSnapshot(snapshotInfo); if (!success) { String errMsg = "Failed to revert a volume to a snapshot state"; s_logger.error(errMsg); throw new CloudRuntimeException("Failed to revert a volume to a snapshot state"); } } finally { if (getHypervisorRequiresResignature(volumeInfo)) { if (hostId != null) { HostVO hostVO = hostDao.findById(hostId); DataStore dataStore = dataStoreMgr.getDataStore(volumeInfo.getPoolId(), DataStoreRole.Primary); volService.grantAccess(volumeInfo, hostVO, dataStore); modifyTarget(true, volumeInfo, hostId); } } if (success) { volumeInfo.stateTransit(Volume.Event.OperationSucceeded); } else { volumeInfo.stateTransit(Volume.Event.OperationFailed); } snapshotDao.releaseFromLockTable(snapshotInfo.getId()); } }

Target:
protected void executeRevertSnapshot(SnapshotInfo snapshotInfo, VolumeInfo volumeInfo) { Long hostId = null; boolean success = false; SnapshotVO snapshotVO = snapshotDao.acquireInLockTable(snapshotInfo.getId()); if (snapshotVO == null) { String errMsg = "Failed to acquire lock on the following snapshot: " + snapshotInfo.getId(); s_logger.error(errMsg); throw new CloudRuntimeException(errMsg); } try { volumeInfo.stateTransit(Volume.Event.RevertSnapshotRequested); if (getHypervisorRequiresResignature(volumeInfo)) { hostId = getHostId(volumeInfo); if (hostId != null) { HostVO hostVO = hostDao.findById(hostId); DataStore dataStore = dataStoreMgr.getDataStore(volumeInfo.getPoolId(), DataStoreRole.Primary); volService.revokeAccess(volumeInfo, hostVO, dataStore); modifyTarget(false, volumeInfo, hostId); } } success = snapshotSvr.revertSnapshot(snapshotInfo); if (!success) { String errMsg = String.format("Failed to revert volume [name:%s, format:%s] to snapshot [id:%s] state", volumeInfo.getName(), volumeInfo.getFormat(), snapshotInfo.getSnapshotId()); s_logger.error(errMsg); throw new CloudRuntimeException(errMsg); } } finally { if (getHypervisorRequiresResignature(volumeInfo)) { if (hostId != null) { HostVO hostVO = hostDao.findById(hostId); DataStore dataStore = dataStoreMgr.getDataStore(volumeInfo.getPoolId(), DataStoreRole.Primary); volService.grantAccess(volumeInfo, hostVO, dataStore); modifyTarget(true, volumeInfo, hostId); } } if (success) { volumeInfo.stateTransit(Volume.Event.OperationSucceeded); } else { volumeInfo.stateTransit(Volume.Event.OperationFailed); } snapshotDao.releaseFromLockTable(snapshotInfo.getId()); } }