[pve-devel] [PATCH v3 container 22/22] Use foreach_volume instead of foreach_mountpoint_full to avoid duplication

Fabian Ebner f.ebner at proxmox.com
Thu Mar 12 13:08:32 CET 2020


Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
 src/PVE/API2/LXC/Config.pm |  2 +-
 src/PVE/LXC/Config.pm      | 17 ++---------------
 2 files changed, 3 insertions(+), 16 deletions(-)

diff --git a/src/PVE/API2/LXC/Config.pm b/src/PVE/API2/LXC/Config.pm
index 0879172..ca0203c 100644
--- a/src/PVE/API2/LXC/Config.pm
+++ b/src/PVE/API2/LXC/Config.pm
@@ -173,7 +173,7 @@ __PACKAGE__->register_method({
 	my $repl_conf = PVE::ReplicationConfig->new();
 	my $is_replicated = $repl_conf->check_for_existing_jobs($vmid, 1);
 	if ($is_replicated) {
-	    PVE::LXC::Config->foreach_mountpoint_full($param, 0, sub {
+	    PVE::LXC::Config->foreach_mountpoint($param, sub {
 		my ($opt, $mountpoint) = @_;
 		my $volid = $mountpoint->{volume};
 		return if !$volid || !($mountpoint->{replicate}//1);
diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
index ee74984..007375f 100644
--- a/src/PVE/LXC/Config.pm
+++ b/src/PVE/LXC/Config.pm
@@ -1473,29 +1473,16 @@ sub valid_volume_keys {
     return $reverse ? reverse @names : @names;
 }
 
-sub foreach_mountpoint_full {
-    my ($class, $conf, $reverse, $func, @param) = @_;
-
-    my $mps = [ grep { defined($conf->{$_}) } $class->valid_volume_keys($reverse) ];
-    foreach my $key (@$mps) {
-	my $value = $conf->{$key};
-	my $mountpoint = $key eq 'rootfs' ? $class->parse_ct_rootfs($value, 1) : $class->parse_ct_mountpoint($value, 1);
-	next if !defined($mountpoint);
-
-	&$func($key, $mountpoint, @param);
-    }
-}
-
 sub foreach_mountpoint {
     my ($class, $conf, $func, @param) = @_;
 
-    $class->foreach_mountpoint_full($conf, 0, $func, @param);
+    $class->foreach_volume($conf, undef, $func, @param);
 }
 
 sub foreach_mountpoint_reverse {
     my ($class, $conf, $func, @param) = @_;
 
-    $class->foreach_mountpoint_full($conf, 1, $func, @param);
+    $class->foreach_volume($conf, {reverse => '1'}, $func, @param);
 }
 
 sub get_vm_volumes {
-- 
2.20.1





More information about the pve-devel mailing list