[pve-devel] [PATCH v2 guest-common 06/28] Add snapshot_foreach_unused_volume

Fabian Ebner f.ebner at proxmox.com
Mon Feb 24 13:43:56 CET 2020


Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
 PVE/AbstractConfig.pm | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/PVE/AbstractConfig.pm b/PVE/AbstractConfig.pm
index bd43cbe..5c449f6 100644
--- a/PVE/AbstractConfig.pm
+++ b/PVE/AbstractConfig.pm
@@ -508,6 +508,19 @@ sub __snapshot_foreach_volume {
     die "abstract method - implement me\n";
 }
 
+# Iterate over all unused volumes, calling $func for each key/value pair
+# with additional parameters @param.
+sub snapshot_foreach_unused_volume {
+    my ($class, $conf, $func, @param) = @_;
+
+    foreach my $key (keys %{$conf}) {
+	if ($key =~ m/^unused\d+$/) {
+	    my $volume = $class->parse_volume($key, $conf->{$key});
+	    $func->($key, $volume, @param);
+	}
+    }
+}
+
 # Copy the current config $source to the snapshot config $dest
 sub __snapshot_copy_config {
     my ($class, $source, $dest) = @_;
-- 
2.20.1





More information about the pve-devel mailing list