From ea37d757d3a4efbf36fe648ce2de8ad235269140 Mon Sep 17 00:00:00 2001 From: Nicolas Vazquez Date: Fri, 13 May 2022 08:19:54 -0300 Subject: [PATCH] Reword KVM snapshot without memory error message (#6387) --- .../api/command/user/vmsnapshot/CreateVMSnapshotCmd.java | 9 ++++++++- .../com/cloud/vm/snapshot/VMSnapshotManagerImpl.java | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/vmsnapshot/CreateVMSnapshotCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/vmsnapshot/CreateVMSnapshotCmd.java index fc78edbe87b..a59b2f67e61 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/vmsnapshot/CreateVMSnapshotCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/vmsnapshot/CreateVMSnapshotCmd.java @@ -17,6 +17,7 @@ package org.apache.cloudstack.api.command.user.vmsnapshot; +import com.cloud.utils.exception.CloudRuntimeException; import org.apache.cloudstack.acl.SecurityChecker.AccessType; import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; @@ -90,7 +91,13 @@ public class CreateVMSnapshotCmd extends BaseAsyncCreateCmd { @Override public void create() throws ResourceAllocationException { - VMSnapshot vmsnapshot = _vmSnapshotService.allocVMSnapshot(getVmId(), getDisplayName(), getDescription(), snapshotMemory()); + VMSnapshot vmsnapshot; + try { + vmsnapshot = _vmSnapshotService.allocVMSnapshot(getVmId(), getDisplayName(), getDescription(), snapshotMemory()); + } catch (CloudRuntimeException e) { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create vm snapshot: " + e.getMessage(), e); + } + if (vmsnapshot != null) { setEntityId(vmsnapshot.getId()); } else { diff --git a/server/src/main/java/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java b/server/src/main/java/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java index aea16523d9f..5ebb1f27d00 100644 --- a/server/src/main/java/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java +++ b/server/src/main/java/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java @@ -384,7 +384,9 @@ public class VMSnapshotManagerImpl extends MutualExclusiveIdsManagerBase impleme VMSnapshotStrategy snapshotStrategy = storageStrategyFactory.getVmSnapshotStrategy(userVmVo.getId(), rootVolumePool.getId(), snapshotMemory); if (snapshotStrategy == null) { - throw new CloudRuntimeException("Could not find snapshot strategy for VM snapshot"); + String message = "KVM does not support the type of snapshot requested"; + s_logger.debug(message); + throw new CloudRuntimeException(message); } }