[pve-devel] [PATCH container 1/3] Check volume usage in snapshots before deleting
Fabian Grünbichler
f.gruenbichler at proxmox.com
Wed Feb 24 12:28:33 CET 2016
---
src/PVE/LXC.pm | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index 4ba9125..6046c46 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1199,7 +1199,7 @@ sub verify_searchdomain_list {
}
sub is_volume_in_use {
- my ($config, $volid) = @_;
+ my ($config, $volid, $include_snapshots) = @_;
my $used = 0;
foreach_mountpoint($config, sub {
@@ -1210,6 +1210,13 @@ sub is_volume_in_use {
}
});
+ my $snapshots = $config->{snapshots};
+ if ($include_snapshots && $snapshots) {
+ foreach my $snap (keys %$snapshots) {
+ $used ||= is_volume_in_use($snapshots->{$snap}, $volid);
+ }
+ }
+
return $used;
}
@@ -1425,6 +1432,8 @@ sub update_pct_config {
my $storage_cfg = PVE::Storage::config();
foreach my $volume (@deleted_volumes) {
next if $used_volids->{$volume}; # could have been re-added, too
+ # also check for references in snapshots
+ next if is_volume_in_use($conf, $volume, 1);
delete_mountpoint_volume($storage_cfg, $vmid, $volume);
}
}
--
2.1.4
More information about the pve-devel
mailing list