Source:
<code>public UserVm destroyVm(DestroyVMCmd cmd) throws ResourceUnavailableException, ConcurrentOperationException { CallContext ctx = CallContext.current(); long vmId = cmd.getId(); boolean expunge = cmd.getExpunge(); if (expunge && !_accountMgr.isAdmin(ctx.getCallingAccount().getId()) && !AllowUserExpungeRecoverVm.valueIn(cmd.getEntityOwnerId())) { throw new PermissionDeniedException("Parameter " + ApiConstants.EXPUNGE + " can be passed by Admin only. Or when the allow.user.expunge.recover.vm key is set."); } UserVmVO vm = _vmDao.findById(vmId); if (vm == null || vm.getRemoved() != null) { throw new InvalidParameterValueException("unable to find a virtual machine with id " + vmId); } if (vm.getState() == State.Destroyed || vm.getState() == State.Expunging) { s_logger.trace("Vm id=" + vmId + " is already destroyed"); <START> return vm; <END> } s_logger.debug("Checking if there are any ongoing snapshots on the ROOT volumes associated with VM with ID " + vmId); if (checkStatusOfVolumeSnapshots(vmId, Volume.Type.ROOT)) { throw new CloudRuntimeException("There is/are unbacked up snapshot(s) on ROOT volume, vm destroy is not permitted, please try again later."); } s_logger.debug("Found no ongoing snapshots on volume of type ROOT, for the vm with id " + vmId); List<VolumeVO> volumes = getVolumesFromIds(cmd); checkForUnattachedVolumes(vmId, volumes); validateVolumes(volumes); detachVolumesFromVm(volumes); UserVm destroyedVm = destroyVm(vmId, expunge); if (expunge) { if (!expunge(vm, ctx.getCallingUserId(), ctx.getCallingAccount())) { throw new CloudRuntimeException("Failed to expunge vm " + destroyedVm); } } deleteVolumesFromVm(volumes); return destroyedVm; }</code><technical_language>Add a s_logger.isTraceEnabled, a debug is</technical_language>

Target:
public UserVm destroyVm(DestroyVMCmd cmd) throws ResourceUnavailableException, ConcurrentOperationException { CallContext ctx = CallContext.current(); long vmId = cmd.getId(); boolean expunge = cmd.getExpunge(); if (expunge && !_accountMgr.isAdmin(ctx.getCallingAccount().getId()) && !AllowUserExpungeRecoverVm.valueIn(cmd.getEntityOwnerId())) { throw new PermissionDeniedException("Parameter " + ApiConstants.EXPUNGE + " can be passed by Admin only. Or when the allow.user.expunge.recover.vm key is set."); } UserVmVO vm = _vmDao.findById(vmId); if (vm == null || vm.getRemoved() != null) { throw new InvalidParameterValueException("unable to find a virtual machine with id " + vmId); } if (vm.getState() == State.Destroyed || vm.getState() == State.Expunging) { s_logger.debug("Vm id=" + vmId + " is already destroyed"); return vm; } s_logger.debug("Checking if there are any ongoing snapshots on the ROOT volumes associated with VM with ID " + vmId); if (checkStatusOfVolumeSnapshots(vmId, Volume.Type.ROOT)) { throw new CloudRuntimeException("There is/are unbacked up snapshot(s) on ROOT volume, vm destroy is not permitted, please try again later."); } s_logger.debug("Found no ongoing snapshots on volume of type ROOT, for the vm with id " + vmId); List<VolumeVO> volumes = getVolumesFromIds(cmd); checkForUnattachedVolumes(vmId, volumes); validateVolumes(volumes); stopVirtualMachine(vmId, VmDestroyForcestop.value()); detachVolumesFromVm(volumes); UserVm destroyedVm = destroyVm(vmId, expunge); if (expunge) { if (!expunge(vm, ctx.getCallingUserId(), ctx.getCallingAccount())) { throw new CloudRuntimeException("Failed to expunge vm " + destroyedVm); } } deleteVolumesFromVm(volumes); return destroyedVm; }