mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-05-01 15:18:29 +00:00
destroy VM: always remove (referenced) VM state volumes
With --destroy-unreferenced-disks 0 they were not removed yet, but no use in keeping them around. Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
parent
2dc0eb61e8
commit
ba1a198481
@ -2140,8 +2140,7 @@ sub destroy_vm {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
# only remove disks owned by this VM (referenced in the config)
|
my $remove_owned_drive = sub {
|
||||||
PVE::QemuConfig->foreach_volume_full($conf, { include_unused => 1 }, sub {
|
|
||||||
my ($ds, $drive) = @_;
|
my ($ds, $drive) = @_;
|
||||||
return if drive_is_cdrom($drive, 1);
|
return if drive_is_cdrom($drive, 1);
|
||||||
|
|
||||||
@ -2153,7 +2152,21 @@ sub destroy_vm {
|
|||||||
|
|
||||||
eval { PVE::Storage::vdisk_free($storecfg, $volid) };
|
eval { PVE::Storage::vdisk_free($storecfg, $volid) };
|
||||||
warn "Could not remove disk '$volid', check manually: $@" if $@;
|
warn "Could not remove disk '$volid', check manually: $@" if $@;
|
||||||
});
|
};
|
||||||
|
|
||||||
|
# only remove disks owned by this VM (referenced in the config)
|
||||||
|
my $include_opts = {
|
||||||
|
include_unused => 1,
|
||||||
|
extra_keys => ['vmstate'],
|
||||||
|
};
|
||||||
|
PVE::QemuConfig->foreach_volume_full($conf, $include_opts, $remove_owned_drive);
|
||||||
|
|
||||||
|
for my $snap (values %{$conf->{snapshots}}) {
|
||||||
|
next if !defined($snap->{vmstate});
|
||||||
|
my $drive = PVE::QemuConfig->parse_volume('vmstate', $snap->{vmstate}, 1);
|
||||||
|
next if !defined($drive);
|
||||||
|
$remove_owned_drive->('vmstate', $drive);
|
||||||
|
}
|
||||||
|
|
||||||
if ($purge_unreferenced) { # also remove unreferenced disk
|
if ($purge_unreferenced) { # also remove unreferenced disk
|
||||||
my $vmdisks = PVE::Storage::vdisk_list($storecfg, undef, $vmid, undef, 'images');
|
my $vmdisks = PVE::Storage::vdisk_list($storecfg, undef, $vmid, undef, 'images');
|
||||||
|
Loading…
Reference in New Issue
Block a user