Arik Hadas has uploaded a new change for review. Change subject: core: remove memory volumes without tasks on import vm failure ......................................................................
core: remove memory volumes without tasks on import vm failure On failure to import vm with snapshots that contain memory state, we remove the imported memory volumes. This patch fix a bug which is relevant for the memory volumes removal in this scenario, that was caused by not adding the tasks properly (not override the getTaskType method in CommandBase). The solution is to remove those imported memory volumes without tasks, in a similar way to the solution done for I3830992f46b2c3fbea47e69f21a6711718408e95. Change-Id: I596ea3164c70b6c2a4e2c161737421259457a179 Signed-off-by: Arik Hadas <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java 1 file changed, 23 insertions(+), 6 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/69/19769/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java index 56562ac..7af0f15 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java @@ -13,7 +13,6 @@ import org.apache.commons.lang.StringUtils; import org.ovirt.engine.core.bll.job.ExecutionContext; import org.ovirt.engine.core.bll.job.ExecutionHandler; -import org.ovirt.engine.core.bll.memory.MemoryImageRemoverOnDataDomain; import org.ovirt.engine.core.bll.memory.MemoryUtils; import org.ovirt.engine.core.bll.network.MacPoolManager; import org.ovirt.engine.core.bll.network.VmInterfaceManager; @@ -32,6 +31,7 @@ import org.ovirt.engine.core.common.VdcObjectType; import org.ovirt.engine.core.common.action.ImportVmParameters; import org.ovirt.engine.core.common.action.MoveOrCopyImageGroupParameters; +import org.ovirt.engine.core.common.action.RemoveMemoryVolumesParameters; import org.ovirt.engine.core.common.action.VdcActionParametersBase; import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.action.VdcReturnValueBase; @@ -1109,7 +1109,7 @@ setVm(null); if (getVm() != null) { - removeVmSnapshots(getVm()); + removeVmSnapshots(); endActionOnAllImageGroups(); removeVmNetworkInterfaces(); getVmDynamicDAO().remove(getVmId()); @@ -1123,10 +1123,27 @@ } } - private void removeVmSnapshots(VM vm) { - Set<String> memoryStates = snapshotsManager.removeSnapshots(vm.getId()); - if (!memoryStates.isEmpty()) { - new MemoryImageRemoverOnDataDomain(vm, this).remove(memoryStates); + private void removeVmSnapshots() { + Guid vmId = getVmId(); + Set<String> memoryStates = snapshotsManager.removeSnapshots(vmId); + for (String memoryState : memoryStates) { + removeMemoryVolumes(memoryState, vmId); + } + } + + private void removeMemoryVolumes(String memoryVolume, Guid vmId) { + RemoveMemoryVolumesParameters parameters = new RemoveMemoryVolumesParameters(memoryVolume, vmId); + parameters.setParentCommand(getActionType()); + parameters.setEntityInfo(getParameters().getEntityInfo()); + parameters.setParentParameters(getParameters()); + + VdcReturnValueBase retVal = getBackend().runInternalAction( + VdcActionType.RemoveMemoryVolumes, + parameters, + ExecutionHandler.createDefaultContexForTasks(getExecutionContext())); + + if (!retVal.getSucceeded()) { + log.errorFormat("Failed to remove memory volumes: {0}", memoryVolume); } } -- To view, visit http://gerrit.ovirt.org/19769 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I596ea3164c70b6c2a4e2c161737421259457a179 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Arik Hadas <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
