From 381b8fae81cd0d4c594efc7d7c5a474d5ea0c26d Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Tue, 16 Feb 2016 10:05:41 +0100 Subject: [PATCH] delete ram state files when restoring a backup currently we leave orphaned vmstate files when we restore a backup over a vm, which has snapshots with saved ram state. this patch deletes those files on a restore. Signed-off-by: Dominik Csapak --- PVE/QemuServer.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 223c2b7..7bf3e4d 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -5562,6 +5562,18 @@ sub restore_vma_archive { PVE::Storage::vdisk_free($cfg, $volid); } }); + + # delete vmstate files + # since after the restore we have no snapshots anymore + foreach my $snapname (keys %{$oldconf->{snapshots}}) { + my $snap = $oldconf->{snapshots}->{$snapname}; + if ($snap->{vmstate}) { + eval { PVE::Storage::vdisk_free($cfg, $snap->{vmstate}); }; + if (my $err = $@) { + warn $err; + } + } + } } my $map = {}; -- 2.39.2