The name is rather vague. The variable is set if and only if there are no mp params specified via the API, so explicitly check for that instead. This also makes it visible that in the non-restore case, the result of create_ct_determine_mp_param() does not depend upon $api_mp_param.
Signed-off-by: Fiona Ebner <[email protected]> --- New in v3. src/PVE/API2/LXC.pm | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm index f7d5de4..fc278a7 100644 --- a/src/PVE/API2/LXC.pm +++ b/src/PVE/API2/LXC.pm @@ -137,28 +137,20 @@ __PACKAGE__->register_method({ my sub create_ct_determine_mp_param { my ( - $storage_cfg, - $vmid, - $archive, - $api_mp_param, - $orig_mp_param, - $restore, - $storage, - $storage_only_mode, + $storage_cfg, $vmid, $archive, $api_mp_param, $orig_mp_param, $restore, $storage, $is_root, ) = @_; my $mp_param; my $delayed_mp_param = {}; - if (!$storage_only_mode) { + if (scalar(keys $api_mp_param->%*)) { $mp_param = $api_mp_param; return ($mp_param, $delayed_mp_param); } if (!$restore) { - $mp_param = $api_mp_param; - $mp_param->{rootfs} = "$storage:4"; # defaults to 4GB + $mp_param = { rootfs => "$storage:4" }; # defaults to 4GB return ($mp_param, $delayed_mp_param); } @@ -437,7 +429,6 @@ __PACKAGE__->register_method({ my $no_disk_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+$/) { @@ -447,7 +438,6 @@ __PACKAGE__->register_method({ } else { $api_mp_param->{$opt} = $value; } - $storage_only_mode = 0; } elsif ($opt =~ m/^unused\d+$/) { warn "ignoring '$opt', cannot create/restore with unused volume\n"; delete $param->{$opt}; @@ -457,7 +447,7 @@ __PACKAGE__->register_method({ } die "mount points configured, but 'rootfs' not set - aborting\n" - if !$storage_only_mode && !defined($api_mp_param->{rootfs}); + if scalar(keys $api_mp_param->%*) && !defined($api_mp_param->{rootfs}); # check storage access, activate storage PVE::LXC::Config->foreach_volume( @@ -549,7 +539,6 @@ __PACKAGE__->register_method({ $orig_mp_param, $restore, $storage, - $storage_only_mode, $is_root, ); -- 2.47.3 _______________________________________________ pve-devel mailing list [email protected] https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
