Skip to content

Commit df6672d

Browse files
committed
Return error when kvm vm snapshot is taken withoutsnapshot memory
1 parent b6ae5fa commit df6672d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

server/src/main/java/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import javax.inject.Inject;
2828
import javax.naming.ConfigurationException;
2929

30+
import com.cloud.storage.snapshot.SnapshotManager;
3031
import org.apache.cloudstack.annotation.AnnotationService;
3132
import org.apache.cloudstack.annotation.dao.AnnotationDao;
3233
import org.apache.cloudstack.api.ApiConstants;
@@ -380,9 +381,14 @@ public VMSnapshot allocVMSnapshot(Long vmId, String vsDisplayName, String vsDesc
380381
//StorageVMSnapshotStrategy - allows volume snapshots without memory; VM has to be in Running state; No limitation of the image format if the storage plugin supports volume snapshots; "kvm.vmstoragesnapshot.enabled" has to be enabled
381382
//Other Storage volume plugins could integrate this with their own functionality for group snapshots
382383
VMSnapshotStrategy snapshotStrategy = storageStrategyFactory.getVmSnapshotStrategy(userVmVo.getId(), rootVolumePool.getId(), snapshotMemory);
383-
384384
if (snapshotStrategy == null) {
385-
String message = "KVM does not support the type of snapshot requested";
385+
String message;
386+
if (!SnapshotManager.VmStorageSnapshotKvm.value() && !snapshotMemory) {
387+
message = "KVM does not support instance snapshot without snapshot memory";
388+
} else {
389+
message = "KVM does not support the type of snapshot requested";
390+
}
391+
386392
logger.debug(message);
387393
throw new CloudRuntimeException(message);
388394
}

0 commit comments

Comments
 (0)