mirror of
https://github.com/GNS3/gns3-server.git
synced 2025-04-29 15:29:47 +00:00
Try to delete saved VM state only if a snapshot has been saved.
This commit is contained in:
parent
bb284d082a
commit
c6afea49da
@ -1832,13 +1832,19 @@ class QemuVM(BaseNode):
|
|||||||
disk = disk_image
|
disk = disk_image
|
||||||
if not os.path.exists(disk):
|
if not os.path.exists(disk):
|
||||||
continue
|
continue
|
||||||
command = [qemu_img_path, "snapshot", "-d", snapshot_name, disk]
|
output = await subprocess_check_output(qemu_img_path, "info", "--output=json", disk)
|
||||||
retcode = await self._qemu_img_exec(command)
|
json_data = json.loads(output)
|
||||||
if retcode:
|
if "snapshots" in json_data:
|
||||||
stdout = self.read_qemu_img_stdout()
|
for snapshot in json_data["snapshots"]:
|
||||||
log.warning("Could not delete saved VM state from disk {}: {}".format(disk, stdout))
|
if snapshot["name"] == snapshot_name:
|
||||||
else:
|
# delete the snapshot
|
||||||
log.info("Deleted saved VM state from disk {}".format(disk))
|
command = [qemu_img_path, "snapshot", "-d", snapshot_name, disk]
|
||||||
|
retcode = await self._qemu_img_exec(command)
|
||||||
|
if retcode:
|
||||||
|
stdout = self.read_qemu_img_stdout()
|
||||||
|
log.warning("Could not delete saved VM state from disk {}: {}".format(disk, stdout))
|
||||||
|
else:
|
||||||
|
log.info("Deleted saved VM state from disk {}".format(disk))
|
||||||
except subprocess.SubprocessError as e:
|
except subprocess.SubprocessError as e:
|
||||||
raise QemuError("Error while looking for the Qemu VM saved state snapshot: {}".format(e))
|
raise QemuError("Error while looking for the Qemu VM saved state snapshot: {}".format(e))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user