[pve-devel] [PATCH container 7/7] update: handle pool limits

Fabian Grünbichler f.gruenbichler at proxmox.com
Thu Apr 11 09:23:53 CEST 2024


On April 10, 2024 3:13 pm, Fabian Grünbichler wrote:
> Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
> ---
>  src/PVE/API2/LXC/Config.pm | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/src/PVE/API2/LXC/Config.pm b/src/PVE/API2/LXC/Config.pm
> index e6c0980..3fb3885 100644
> --- a/src/PVE/API2/LXC/Config.pm
> +++ b/src/PVE/API2/LXC/Config.pm
> @@ -208,6 +208,27 @@ __PACKAGE__->register_method({
>  
>  	    my $running = PVE::LXC::check_running($vmid);
>  
> +	    my $usage = PVE::LXC::Config->get_pool_usage($conf);
> +	    if (defined($param->{memory}) || defined($param->{swap})) {
> +		my $old = $usage->{mem};
> +		my $new = $param->{memory} || $usage->{memory};
> +		$new *= ($param->{swap} || $usage->{swap});

as Dominik pointed out off-list, this should be an addition, not a
multiplication..

> +
> +		if ($new > $old) {
> +		    my $change = { mem => ($new - $old) * 1024 * 1024 };
> +		    PVE::GuestHelpers::check_guest_pool_limit($vmid, $change);
> +		}
> +	    }
> +	    if (defined($param->{cores})) {
> +		my $old = $usage->{cpu};
> +		my $new = $param->{cores};
> +
> +		if ($new > $old) {
> +		    my $change = { cpu => ($new - $old) };
> +		    PVE::GuestHelpers::check_guest_pool_limit($vmid, $change);
> +		}
> +	    }
> +
>  	    my $errors = PVE::LXC::Config->update_pct_config($vmid, $conf, $running, $param, \@delete, \@revert);
>  	    PVE::LXC::Config->write_config($vmid, $conf);
>  	    $conf = PVE::LXC::Config->load_config($vmid);
> -- 
> 2.39.2
> 
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 




More information about the pve-devel mailing list