@@ -479,11 +479,17 @@ public boolean deleteVMSnapshotFromDB(VMSnapshot vmSnapshot, boolean unmanage) {
479479 @ Override
480480 public StrategyPriority canHandle (Long vmId , Long rootPoolId , boolean snapshotMemory ) {
481481 UserVmVO vm = userVmDao .findById (vmId );
482- if (State .Running .equals (vm .getState ()) && ( !snapshotMemory || vmHasKvmDiskOnlySnapshot ( vm )) ) {
482+ if (State .Running .equals (vm .getState ()) && !snapshotMemory ) {
483483 logger .debug ("Default VM snapshot cannot handle VM snapshot for [{}] as it is running and its memory will not be affected." , vm );
484484 return StrategyPriority .CANT_HANDLE ;
485485 }
486486
487+ if (vmHasKvmDiskOnlySnapshot (vm )) {
488+ logger .debug ("Default VM snapshot cannot handle VM snapshot for [{}] as it has a disk-only VM snapshot using kvmFileBasedStorageSnapshot strategy." +
489+ "These two strategies are not compatible, as reverting a disk-only VM snapshot will erase newer disk-and-memory VM snapshots." , vm );
490+ return StrategyPriority .CANT_HANDLE ;
491+ }
492+
487493 List <VolumeVO > volumes = volumeDao .findByInstance (vmId );
488494 for (VolumeVO volume : volumes ) {
489495 if (volume .getFormat () != ImageFormat .QCOW2 ) {
@@ -501,9 +507,7 @@ private boolean vmHasKvmDiskOnlySnapshot(UserVm vm) {
501507
502508 for (VMSnapshotVO vmSnapshotVO : vmSnapshotDao .findByVmAndByType (vm .getId (), VMSnapshot .Type .Disk )) {
503509 List <VMSnapshotDetailsVO > vmSnapshotDetails = vmSnapshotDetailsDao .listDetails (vmSnapshotVO .getId ());
504- if (vmSnapshotDetails .stream ().
505- anyMatch (vmSnapshotDetailsVO -> vmSnapshotDetailsVO .getName ().equals (KVM_FILE_BASED_STORAGE_SNAPSHOT ) ||
506- vmSnapshotDetailsVO .getName ().equals (STORAGE_SNAPSHOT ))) {
510+ if (vmSnapshotDetails .stream ().anyMatch (vmSnapshotDetailsVO -> vmSnapshotDetailsVO .getName ().equals (KVM_FILE_BASED_STORAGE_SNAPSHOT ))) {
507511 return true ;
508512 }
509513 }
0 commit comments