[pve-devel] [PATCH container v3 2/8] api: create: reduce scope for $mp_param variable
Fiona Ebner
f.ebner at proxmox.com
Fri Jan 23 15:34:22 CET 2026
Introduce an $api_mp_param variable for better separation to prepare
for factoring out a helper.
Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---
New in v3.
src/PVE/API2/LXC.pm | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 204e1c8..4370c57 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -360,16 +360,16 @@ __PACKAGE__->register_method({
my $is_root = $authuser eq 'root at pam';
my $no_disk_param = {};
- my $mp_param = {};
+ my $api_mp_param = {};
my $storage_only_mode = 1;
foreach my $opt (keys %$param) {
my $value = $param->{$opt};
if ($opt eq 'rootfs' || $opt =~ m/^mp\d+$/) {
# allow to use simple numbers (add default storage in that case)
if ($value =~ m/^\d+(\.\d+)?$/) {
- $mp_param->{$opt} = "$storage:$value";
+ $api_mp_param->{$opt} = "$storage:$value";
} else {
- $mp_param->{$opt} = $value;
+ $api_mp_param->{$opt} = $value;
}
$storage_only_mode = 0;
} elsif ($opt =~ m/^unused\d+$/) {
@@ -381,11 +381,11 @@ __PACKAGE__->register_method({
}
die "mount points configured, but 'rootfs' not set - aborting\n"
- if !$storage_only_mode && !defined($mp_param->{rootfs});
+ if !$storage_only_mode && !defined($api_mp_param->{rootfs});
# check storage access, activate storage
PVE::LXC::Config->foreach_volume(
- $mp_param,
+ $api_mp_param,
sub {
my ($ms, $mountpoint) = @_;
@@ -403,7 +403,7 @@ __PACKAGE__->register_method({
);
# check/activate default storage
- &$check_and_activate_storage($storage) if !defined($mp_param->{rootfs});
+ &$check_and_activate_storage($storage) if !defined($api_mp_param->{rootfs});
PVE::LXC::Config->update_pct_config($vmid, $conf, 0, $no_disk_param);
@@ -465,6 +465,7 @@ __PACKAGE__->register_method({
}
}
+ my $mp_param;
my $delayed_mp_param = {};
if ($storage_only_mode) {
if ($restore) {
@@ -521,8 +522,11 @@ __PACKAGE__->register_method({
},
);
} else {
+ $mp_param = $api_mp_param;
$mp_param->{rootfs} = "$storage:4"; # defaults to 4GB
}
+ } else {
+ $mp_param = $api_mp_param;
}
# up until here we did not modify the container, besides the lock
--
2.47.3
More information about the pve-devel
mailing list