* [pve-devel] [PATCH qemu-server 1/2] destroy VM: always remove (referenced) VM state volumes
@ 2021-04-19 8:46 Fabian Ebner
2021-04-19 8:46 ` [pve-devel] [PATCH qemu-server 2/2] destroy VM: also check if unused volumes are base images Fabian Ebner
2021-05-28 11:50 ` [pve-devel] applied-series: [PATCH qemu-server 1/2] destroy VM: always remove (referenced) VM state volumes Thomas Lamprecht
0 siblings, 2 replies; 3+ messages in thread
From: Fabian Ebner @ 2021-04-19 8:46 UTC (permalink / raw)
To: pve-devel
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>
---
PVE/QemuServer.pm | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 1a46732..1af2b53 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2140,8 +2140,7 @@ sub destroy_vm {
});
}
- # only remove disks owned by this VM (referenced in the config)
- PVE::QemuConfig->foreach_volume_full($conf, { include_unused => 1 }, sub {
+ my $remove_owned_drive = sub {
my ($ds, $drive) = @_;
return if drive_is_cdrom($drive, 1);
@@ -2153,7 +2152,21 @@ sub destroy_vm {
eval { PVE::Storage::vdisk_free($storecfg, $volid) };
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
my $vmdisks = PVE::Storage::vdisk_list($storecfg, undef, $vmid, undef, 'images');
--
2.20.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pve-devel] [PATCH qemu-server 2/2] destroy VM: also check if unused volumes are base images
2021-04-19 8:46 [pve-devel] [PATCH qemu-server 1/2] destroy VM: always remove (referenced) VM state volumes Fabian Ebner
@ 2021-04-19 8:46 ` Fabian Ebner
2021-05-28 11:50 ` [pve-devel] applied-series: [PATCH qemu-server 1/2] destroy VM: always remove (referenced) VM state volumes Thomas Lamprecht
1 sibling, 0 replies; 3+ messages in thread
From: Fabian Ebner @ 2021-04-19 8:46 UTC (permalink / raw)
To: pve-devel
It's arguably not likely in practice that only an unused volume is still in use
as a base image, but do it for completeness sake.
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
PVE/QemuServer.pm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 1af2b53..dce1193 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2127,7 +2127,7 @@ sub destroy_vm {
if ($conf->{template}) {
# check if any base image is still used by a linked clone
- PVE::QemuConfig->foreach_volume($conf, sub {
+ PVE::QemuConfig->foreach_volume_full($conf, { include_unused => 1 }, sub {
my ($ds, $drive) = @_;
return if drive_is_cdrom($drive);
--
2.20.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pve-devel] applied-series: [PATCH qemu-server 1/2] destroy VM: always remove (referenced) VM state volumes
2021-04-19 8:46 [pve-devel] [PATCH qemu-server 1/2] destroy VM: always remove (referenced) VM state volumes Fabian Ebner
2021-04-19 8:46 ` [pve-devel] [PATCH qemu-server 2/2] destroy VM: also check if unused volumes are base images Fabian Ebner
@ 2021-05-28 11:50 ` Thomas Lamprecht
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Lamprecht @ 2021-05-28 11:50 UTC (permalink / raw)
To: Proxmox VE development discussion, Fabian Ebner
On 19.04.21 10:46, Fabian Ebner wrote:
> 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>
> ---
> PVE/QemuServer.pm | 19 ++++++++++++++++---
> 1 file changed, 16 insertions(+), 3 deletions(-)
>
>
applied both patches, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-05-28 11:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-19 8:46 [pve-devel] [PATCH qemu-server 1/2] destroy VM: always remove (referenced) VM state volumes Fabian Ebner
2021-04-19 8:46 ` [pve-devel] [PATCH qemu-server 2/2] destroy VM: also check if unused volumes are base images Fabian Ebner
2021-05-28 11:50 ` [pve-devel] applied-series: [PATCH qemu-server 1/2] destroy VM: always remove (referenced) VM state volumes Thomas Lamprecht
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal