]> git.proxmox.com Git - qemu-server.git/commitdiff
delete ram state files when restoring a backup
authorDominik Csapak <d.csapak@proxmox.com>
Tue, 16 Feb 2016 09:05:41 +0000 (10:05 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 18 Feb 2016 10:53:46 +0000 (11:53 +0100)
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 <d.csapak@proxmox.com>
PVE/QemuServer.pm

index 223c2b7dd909aa9899a19cc9e15f0ddd47b73e14..7bf3e4d5e7487f94fdd4ddb048af3374db40f630 100644 (file)
@@ -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 = {};