sureshanaparti commented on a change in pull request #4304:
URL: https://github.com/apache/cloudstack/pull/4304#discussion_r579090278



##########
File path: server/src/main/java/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
##########
@@ -358,9 +363,33 @@ public VMSnapshot allocVMSnapshot(Long vmId, String 
vsDisplayName, String vsDesc
             throw new InvalidParameterValueException("Can not snapshot memory 
when VM is not in Running state");
         }
 
+        List<VolumeVO> rootVolumes = 
_volumeDao.findReadyRootVolumesByInstance(userVmVo.getId());
+        if (rootVolumes == null || rootVolumes.isEmpty()) {
+            throw new CloudRuntimeException("Unable to find root volume for 
the user vm:" + userVmVo.getUuid());
+        }
+
+        VolumeVO rootVolume = rootVolumes.get(0);
+        StoragePoolVO rootVolumePool = 
_storagePoolDao.findById(rootVolume.getPoolId());
+        if (rootVolumePool == null) {
+            throw new CloudRuntimeException("Unable to find root volume 
storage pool for the user vm:" + userVmVo.getUuid());
+        }
+
         // for KVM, only allow snapshot with memory when VM is in running state
-        if (userVmVo.getHypervisorType() == HypervisorType.KVM && 
userVmVo.getState() == State.Running && !snapshotMemory) {
-            throw new InvalidParameterValueException("KVM VM does not allow to 
take a disk-only snapshot when VM is in running state");
+        if (userVmVo.getHypervisorType() == HypervisorType.KVM) {
+            if (rootVolumePool.getPoolType() != 
Storage.StoragePoolType.PowerFlex) {

Review comment:
       @slavkap Thanks for the review and suggestions. Can not get the 
VMSnapshotStrategy to use here, as VMSnapshot object is not yet created. The 
check here is a pre-creation phase check, and  VMSnapshot object is not created 
when it is not supported. VMSnapshotStrategy is currently being used to check 
(_canHandle(VMSnapshot)_) and perform the operations (take VM snapshot, revert 
VM snapshots, delete VM snapshot) allowed, on the VMSnapshot object.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to