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

2024-04-15 Thread Fabian Grünbichler
On April 11, 2024 12:03 pm, Wolfgang Bumiller wrote:
> On Thu, Apr 11, 2024 at 09:23:53AM +0200, Fabian Grünbichler wrote:
>> On April 10, 2024 3:13 pm, Fabian Grünbichler wrote:
>> > Signed-off-by: Fabian Grünbichler 
>> > ---
>> >  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..
> 
> Do we even want to mix mem & swap? Feels cgroupv1-y... (as in bad)

well, we want a single value (because both VMs and CTs count against the
pool limit, so counting swap separately doesn't make much sense..). I
guess we could either ignore swap altogether (assuming v2), or
conditionalize based on current cgroup mode?


___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


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

2024-04-11 Thread Wolfgang Bumiller
On Thu, Apr 11, 2024 at 09:23:53AM +0200, Fabian Grünbichler wrote:
> On April 10, 2024 3:13 pm, Fabian Grünbichler wrote:
> > Signed-off-by: Fabian Grünbichler 
> > ---
> >  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..

Do we even want to mix mem & swap? Feels cgroupv1-y... (as in bad)


___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel



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

2024-04-11 Thread Fabian Grünbichler
On April 10, 2024 3:13 pm, Fabian Grünbichler wrote:
> Signed-off-by: Fabian Grünbichler 
> ---
>  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@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 


___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


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

2024-04-10 Thread Fabian Grünbichler
Signed-off-by: Fabian Grünbichler 
---
 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});
+
+   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@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel