Skip to content

Commit 36cfd76

Browse files
KVM: fix delete vm snapshot if it does not exist with a Stopped vm (#11687)
* KVM: fix delete vm snapshot if it does not exist with a Stopped vm * update 11687
1 parent c24d2b8 commit 36cfd76

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtDeleteVMSnapshotCommandWrapper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import com.cloud.resource.ResourceWrapper;
4141
import com.cloud.storage.Storage.ImageFormat;
4242
import com.cloud.storage.Volume;
43+
import com.cloud.utils.StringUtils;
4344
import com.cloud.utils.script.Script;
4445

4546
@ResourceWrapper(handles = DeleteVMSnapshotCommand.class)
@@ -104,7 +105,7 @@ public Answer execute(final DeleteVMSnapshotCommand cmd, final LibvirtComputingR
104105
commands.add(new String[]{Script.getExecutableAbsolutePath("awk"), "-F", " ", "{print $2}"});
105106
commands.add(new String[]{Script.getExecutableAbsolutePath("grep"), "^" + sanitizeBashCommandArgument(cmd.getTarget().getSnapshotName()) + "$"});
106107
String qemu_img_snapshot = Script.executePipedCommands(commands, 0).second();
107-
if (qemu_img_snapshot == null) {
108+
if (StringUtils.isEmpty(qemu_img_snapshot)) {
108109
logger.info("Cannot find snapshot " + cmd.getTarget().getSnapshotName() + " in file " + rootDisk.getPath() + ", return true");
109110
return new DeleteVMSnapshotAnswer(cmd, cmd.getVolumeTOs());
110111
}

0 commit comments

Comments
 (0)