winterhazel commented on code in PR #12885:
URL: https://github.com/apache/cloudstack/pull/12885#discussion_r2992107434


##########
server/src/main/java/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java:
##########
@@ -754,11 +754,17 @@ public UserVm revertToSnapshot(Long vmSnapshotId) throws 
InsufficientCapacityExc
                     "Instance Snapshot reverting failed because the Instance 
is not in Running or Stopped state.");
         }
 
-        if (userVm.getState() == VirtualMachine.State.Running && 
vmSnapshotVo.getType() == VMSnapshot.Type.Disk || userVm.getState() == 
VirtualMachine.State.Stopped
-                && vmSnapshotVo.getType() == VMSnapshot.Type.DiskAndMemory) {
+        if (userVm.getState() == VirtualMachine.State.Running && 
vmSnapshotVo.getType() == VMSnapshot.Type.Disk) {
             throw new InvalidParameterValueException(
-                    "Reverting to the Instance Snapshot is not allowed for 
running Instances as this would result in a Instance state change. For running 
Instances only Snapshots with memory can be reverted. In order to revert to a 
Snapshot without memory you need to first stop the Instance."
-                            + " Snapshot");
+                    "Reverting to the Instance Snapshot is not allowed for 
running Instances as this would result in an Instance state change. " +
+                            "For running Instances only Snapshots with memory 
can be reverted. " +
+                            "In order to revert to a Snapshot without memory 
you need to first stop the Instance.");
+        }
+
+        if ( userVm.getState() == VirtualMachine.State.Stopped && 
vmSnapshotVo.getType() == VMSnapshot.Type.DiskAndMemory) {
+            throw new InvalidParameterValueException(
+                    "Reverting to the Instance Snapshot is not allowed for 
stopped Instances if the Snapshot contains memory. " +
+                            "In order to revert to a Snapshot with memory you 
need to first start the Instance.");

Review Comment:
   ```suggestion
           if (userVm.getState() == VirtualMachine.State.Stopped && 
vmSnapshotVo.getType() == VMSnapshot.Type.DiskAndMemory) {
               throw new InvalidParameterValueException(
                       "Reverting to the Instance Snapshot is not allowed for 
stopped Instances when the Snapshot contains memory as this would result in an 
Instance state change. " +
                               "In order to revert to a Snapshot with memory 
you need to first start the Instance.");
   ```



-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to