diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java index 1b6dec7956c..69e87488867 100755 --- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java +++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java @@ -365,7 +365,7 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma UserVmVO userVm = _vmDao.findById(v.getInstanceId()); if(userVm != null) { if(userVm.getState().equals(State.Destroyed) || userVm.getState().equals(State.Expunging)) { - throw new CloudRuntimeException("Creating snapshot failed due to volume:" + volumeId + " is associated with vm:"+userVm.getInstanceName()+" which is in "+userVm.getState().toString()+" state"); + throw new CloudRuntimeException("Creating snapshot failed due to volume:" + volumeId + " is associated with vm:"+userVm.getInstanceName()+" is in "+userVm.getState().toString()+" state"); } } } diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index bfcb9857310..7f7b98f6263 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -1488,6 +1488,15 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager if(vm != null){ if(vm.getState().equals(State.Stopped)){ _itMgr.stateTransitTo(vm, VirtualMachine.Event.OperationFailed, null); + //destroy associated volumes for vm in error state + List volumesForThisVm = _volsDao.findByInstance(vm.getId()); + for(VolumeVO volume : volumesForThisVm) { + try { + _storageMgr.destroyVolume(volume); + } catch (ConcurrentOperationException e) { + s_logger.warn("Unable to delete volume:"+volume.getId()+" for vm:"+vmId+" whilsts transitioning to error state"); + } + } } } }