1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-18 06:18:08 +00:00

Try to delete saved VM state only if a snapshot has been saved.

This commit is contained in:
grossmj 2019-01-12 17:04:37 +07:00
parent bb284d082a
commit c6afea49da

View File

@ -1832,6 +1832,12 @@ class QemuVM(BaseNode):
disk = disk_image disk = disk_image
if not os.path.exists(disk): if not os.path.exists(disk):
continue continue
output = await subprocess_check_output(qemu_img_path, "info", "--output=json", disk)
json_data = json.loads(output)
if "snapshots" in json_data:
for snapshot in json_data["snapshots"]:
if snapshot["name"] == snapshot_name:
# delete the snapshot
command = [qemu_img_path, "snapshot", "-d", snapshot_name, disk] command = [qemu_img_path, "snapshot", "-d", snapshot_name, disk]
retcode = await self._qemu_img_exec(command) retcode = await self._qemu_img_exec(command)
if retcode: if retcode: