# check storage access, activate storage
my $delayed_mp_param = {};
- PVE::LXC::Config->foreach_mountpoint($mp_param, sub {
+ PVE::LXC::Config->foreach_volume($mp_param, sub {
my ($ms, $mountpoint) = @_;
my $volid = $mountpoint->{volume};
$mp_param = $orig_mp_param;
die "rootfs configuration could not be recovered, please check and specify manually!\n"
if !defined($mp_param->{rootfs});
- PVE::LXC::Config->foreach_mountpoint($mp_param, sub {
+ PVE::LXC::Config->foreach_volume($mp_param, sub {
my ($ms, $mountpoint) = @_;
my $type = $mountpoint->{type};
if ($type eq 'volume') {
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_volume($param, sub {
my ($opt, $mountpoint) = @_;
my $volid = $mountpoint->{volume};
return if !$volid || !($mountpoint->{replicate}//1);
}
if ($conf->{unprivileged}) {
- PVE::LXC::Config->foreach_mountpoint($conf, sub {
+ PVE::LXC::Config->foreach_volume($conf, sub {
my ($ms, $mountpoint) = @_;
die "Quotas are not supported by unprivileged containers.\n" if $mountpoint->{quota};
});
my @len = map { length($_) } @{$list[0]};
eval {
- PVE::LXC::Config->foreach_mountpoint($conf, sub {
+ PVE::LXC::Config->foreach_volume($conf, sub {
my ($name, $mp) = @_;
my $path = $mp->{mp};
eval {
my $path = "";
PVE::LXC::mount_all($vmid, $storecfg, $conf);
- PVE::LXC::Config->foreach_mountpoint($conf, sub {
+ PVE::LXC::Config->foreach_volume($conf, sub {
my ($name, $mp) = @_;
$path = $mp->{mp};
my $cmd = ["fstrim", "-v", "$rootdir$path"];
sub destroy_lxc_container {
my ($storage_cfg, $vmid, $conf, $replacement_conf) = @_;
- PVE::LXC::Config->foreach_mountpoint($conf, sub {
+ PVE::LXC::Config->foreach_volume($conf, sub {
my ($ms, $mountpoint) = @_;
delete_mountpoint_volume($storage_cfg, $vmid, $mountpoint->{volume});
});
my $storecfg = PVE::Storage::config();
- PVE::LXC::Config->foreach_mountpoint($conf, sub {
+ PVE::LXC::Config->foreach_volume($conf, sub {
my ($ms, $mountpoint) = @_;
my $volid = $mountpoint->{volume};
if !PVE::Storage::volume_has_feature($storecfg, 'template', $volid);
});
- PVE::LXC::Config->foreach_mountpoint($conf, sub {
+ PVE::LXC::Config->foreach_volume($conf, sub {
my ($ms, $mountpoint) = @_;
my $volid = $mountpoint->{volume};
my $res = 1;
- PVE::LXC::Config->foreach_mountpoint_reverse($conf, sub {
+ PVE::LXC::Config->foreach_volume_full($conf, {'reverse' => 1}, sub {
my ($ms, $mountpoint) = @_;
my $volid = $mountpoint->{volume};
my (undef, $rootuid, $rootgid) = parse_id_maps($conf);
eval {
- PVE::LXC::Config->foreach_mountpoint($conf, sub {
+ PVE::LXC::Config->foreach_volume($conf, sub {
my ($ms, $mountpoint) = @_;
$mountpoint->{ro} = 0 if $ignore_ro;
my (undef, $rootuid, $rootgid) = PVE::LXC::parse_id_maps($conf);
my $chown_vollist = [];
- PVE::LXC::Config->foreach_mountpoint($settings, sub {
+ PVE::LXC::Config->foreach_volume($settings, sub {
my ($ms, $mountpoint) = @_;
my $volid = $mountpoint->{volume};
}
};
- PVE::LXC::Config->foreach_mountpoint($conf, $update_mp);
+ PVE::LXC::Config->foreach_volume($conf, $update_mp);
return $changes;
}
$opts = {'valid_target_formats' => ['raw', 'subvol']};
}
- $class->foreach_mountpoint($conf, sub {
+ $class->foreach_volume($conf, sub {
my ($ms, $mountpoint) = @_;
return if $err; # skip further test
my ($class, $config, $volid) = @_;
my $used = 0;
- $class->foreach_mountpoint($config, sub {
+ $class->foreach_volume($config, sub {
my ($ms, $mountpoint) = @_;
return if $used;
$used = $mountpoint->{type} eq 'volume' && $mountpoint->{volume} eq $volid;
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);
-}
-
-sub foreach_mountpoint_reverse {
- my ($class, $conf, $func, @param) = @_;
-
- $class->foreach_mountpoint_full($conf, 1, $func, @param);
-}
-
sub get_vm_volumes {
my ($class, $conf, $excludes) = @_;
my $vollist = [];
- $class->foreach_mountpoint($conf, sub {
+ $class->foreach_volume($conf, sub {
my ($ms, $mountpoint) = @_;
return if $excludes && $ms eq $excludes;
$volhash->{$volid} = 1;
};
- $class->foreach_mountpoint($conf, sub {
+ $class->foreach_volume($conf, sub {
my ($ms, $mountpoint) = @_;
$test_volid->($mountpoint->{volume}, $mountpoint);
});
foreach my $snapname (keys %{$conf->{snapshots}}) {
my $snap = $conf->{snapshots}->{$snapname};
- $class->foreach_mountpoint($snap, sub {
+ $class->foreach_volume($snap, sub {
my ($ms, $mountpoint) = @_;
$test_volid->($mountpoint->{volume}, $mountpoint);
});
delete $conf->{snapshots};
my $mp_param = {};
- PVE::LXC::Config->foreach_mountpoint($conf, sub {
+ PVE::LXC::Config->foreach_volume($conf, sub {
my ($ms, $mountpoint) = @_;
$mp_param->{$ms} = $conf->{$ms};
});
delete $conf->{snapshots};
- PVE::LXC::Config->foreach_mountpoint($conf, sub {
+ PVE::LXC::Config->foreach_volume($conf, sub {
my ($ms, $mountpoint) = @_;
$mp_param->{$ms} = $conf->{$ms};
});
my $force = $self->{opts}->{force} // 0;
my $need_activate = [];
- PVE::LXC::Config->foreach_mountpoint($conf, sub {
+ PVE::LXC::Config->foreach_volume($conf, sub {
my ($ms, $mountpoint) = @_;
my $volid = $mountpoint->{volume};
foreach my $snapname (keys %{$conf->{snapshots}}) {
&$test_volid($conf->{snapshots}->{$snapname}->{'vmstate'}, 0, undef)
if defined($conf->{snapshots}->{$snapname}->{'vmstate'});
- PVE::LXC::Config->foreach_mountpoint($conf->{snapshots}->{$snapname}, $test_mp, $snapname);
+ PVE::LXC::Config->foreach_volume($conf->{snapshots}->{$snapname}, $test_mp, $snapname);
}
# finally all currently used volumes
- PVE::LXC::Config->foreach_mountpoint($conf, $test_mp);
+ PVE::LXC::Config->foreach_volume($conf, $test_mp);
# additional checks for local storage
$task->{rootgid} = $rootgid;
my $volids = $task->{volids} = [];
- PVE::LXC::Config->foreach_mountpoint($conf, sub {
+ PVE::LXC::Config->foreach_volume($conf, sub {
my ($name, $data) = @_;
my $volid = $data->{volume};
my $mount = $data->{mp};
};
}
- PVE::LXC::Config->foreach_mountpoint($conf, $setup_mountpoint);
+ PVE::LXC::Config->foreach_volume($conf, $setup_mountpoint);
my $lxc_setup = PVE::LXC::Setup->new($conf, $rootdir);
$lxc_setup->pre_start_hook();