like discussed off-list, this should lose the 'snapshot_' prefix if it is to be used as a general method.
alternatively, we could also generalize PVE::LXC::Config::mountpoint_names and PVE::QemuServer::Drive::valid_drive_names into a single method returning a list of config keys where volumes are found in correct order. then foreach_volume could entirely be defined as iteration over that, a call to parse_volume, and a call to the passed function. this new method could take the $opts defining any extras like include unused or include vmstate, or foreach_volume could add them. note that pve-container needs an option to reverse iterate, but that could also be handled in either method. On February 24, 2020 1:43 pm, Fabian Ebner wrote: > Signed-off-by: Fabian Ebner <f.eb...@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 > > > _______________________________________________ > pve-devel mailing list > pve-devel@pve.proxmox.com > https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel > > _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel