From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 0FFCC1FF16F for ; Thu, 19 Dec 2024 17:04:30 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1037FC132; Thu, 19 Dec 2024 17:04:30 +0100 (CET) From: Daniel Kral To: f.gruenbichler@proxmox.com Date: Thu, 19 Dec 2024 17:04:23 +0100 Message-Id: <20241219160423.184777-1-d.kral@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20240416122054.733817-9-f.gruenbichler@proxmox.com> References: <20240416122054.733817-9-f.gruenbichler@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.004 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pve-devel] [PATCH v2 container 7/7] update: handle pool limits X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Cc: pve-devel@lists.proxmox.com Content-Type: multipart/mixed; boundary="===============7712067949606578823==" Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" --===============7712067949606578823== Content-Transfer-Encoding: quoted-printable On 16/04/2024 14:20, Fabian Gr=C3=BCnbichler wrote:=0D > Signed-off-by: Fabian Gr=C3=BCnbichler =0D > ---=0D > =0D > Notes:=0D > v2:=0D > - don't multiply mem+swap, but add them up (thanks Dominik)=0D > =0D > src/PVE/API2/LXC/Config.pm | 21 +++++++++++++++++++++=0D > 1 file changed, 21 insertions(+)=0D > =0D > diff --git a/src/PVE/API2/LXC/Config.pm b/src/PVE/API2/LXC/Config.pm=0D > index e6c0980..15fab61 100644=0D > --- a/src/PVE/API2/LXC/Config.pm=0D > +++ b/src/PVE/API2/LXC/Config.pm=0D > @@ -208,6 +208,27 @@ __PACKAGE__->register_method({=0D > =0D > my $running =3D PVE::LXC::check_running($vmid);=0D > =0D > + my $usage =3D PVE::LXC::Config->get_pool_usage($conf);=0D > + if (defined($param->{memory}) || defined($param->{swap})) {=0D > + my $old =3D $usage->{mem};=0D > + my $new =3D $param->{memory} || $usage->{memory};=0D > + $new +=3D ($param->{swap} || $usage->{swap});=0D > +=0D > + if ($new > $old) {=0D > + my $change =3D { mem =3D> ($new - $old) * 1024 * 1024 };=0D =0D I haven't tested this exactly, but aren't $new and $old in different=0D magnitudes, i.e. bytes and MiB?=0D =0D > + PVE::GuestHelpers::check_guest_pool_limit($vmid, $change);=0D > + }=0D > + }=0D > + if (defined($param->{cores})) {=0D > + my $old =3D $usage->{cpu};=0D > + my $new =3D $param->{cores};=0D > +=0D > + if ($new > $old) {=0D > + my $change =3D { cpu =3D> ($new - $old) };=0D > + PVE::GuestHelpers::check_guest_pool_limit($vmid, $change);=0D > + }=0D > + }=0D > +=0D > my $errors =3D PVE::LXC::Config->update_pct_config($vmid, $conf, $r= unning, $param, \@delete, \@revert);=0D > PVE::LXC::Config->write_config($vmid, $conf);=0D > $conf =3D PVE::LXC::Config->load_config($vmid);=0D > -- =0D > 2.39.2=0D =0D =0D =0D =0D =0D --===============7712067949606578823== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel --===============7712067949606578823==--