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 CC8721FF16F for ; Thu, 19 Dec 2024 17:08:14 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D8061C539; Thu, 19 Dec 2024 17:08:14 +0100 (CET) From: Daniel Kral To: f.gruenbichler@proxmox.com Date: Thu, 19 Dec 2024 17:08:07 +0100 Message-Id: <20241219160807.186862-1-d.kral@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20240416122054.733817-15-f.gruenbichler@proxmox.com> References: <20240416122054.733817-15-f.gruenbichler@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.005 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 qemu-server 1/6] config: add pool usage helper 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="===============6471602663248882704==" Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" --===============6471602663248882704== Content-Transfer-Encoding: quoted-printable On 16/04/2024 14:20, Fabian Gr=C3=BCnbichler wrote:=0D > determining the usage values for the current config. pending values are t= aken=0D > into account if they are higher than the current value only, else it woul= d be=0D > possible to easily circumvent config limits by setting non-hotpluggable p= ending=0D > values.=0D > =0D > Signed-off-by: Fabian Gr=C3=BCnbichler =0D > ---=0D > PVE/QemuConfig.pm | 30 ++++++++++++++++++++++++++++++=0D > 1 file changed, 30 insertions(+)=0D > =0D > diff --git a/PVE/QemuConfig.pm b/PVE/QemuConfig.pm=0D > index 8e8a7828..1410bf14 100644=0D > --- a/PVE/QemuConfig.pm=0D > +++ b/PVE/QemuConfig.pm=0D > @@ -573,4 +573,34 @@ sub has_cloudinit {=0D > return $found;=0D > }=0D > =0D > +# for determining pool usage vs limits=0D > +#=0D > +# this gives the higher of pending or currently configured=0D > +sub get_pool_usage {=0D =0D similar comment as for the pve-container: would it make sense to rename=0D this sub to `get_configured_vm_usage`?=0D =0D > + my ($class, $conf) =3D @_;=0D > +=0D > + my $usage =3D {};=0D > +=0D > + my $get_max =3D sub {=0D > + my $max =3D 0;=0D > +=0D > + for my $curr (@_) {=0D > + $max =3D $curr if defined($curr) && $curr > $max;=0D > + }=0D > +=0D > + return $max;=0D > + };=0D > +=0D > + $usage->{sockets} =3D $get_max->($conf->{pending}->{sockets}, $conf-= >{sockets}, 1);=0D > + $usage->{cores} =3D $get_max->($conf->{pending}->{cores}, $conf->{co= res}, 1);=0D > + $usage->{cpu} =3D $usage->{sockets} * $usage->{cores};=0D =0D nit: same as for pve-container, we could name this 'cpus' just for=0D consistency's sake (as 'cpu' holds the cpu usage % and 'cpus' the=0D amount of cores).=0D =0D > + $usage->{mem} =3D $get_max->(=0D > + get_current_memory($conf->{pending}->{memory}),=0D > + get_current_memory($conf->{memory})=0D > + );=0D > + $usage->{mem} *=3D 1024*1024;=0D > +=0D > + return $usage;=0D > +}=0D > +=0D > 1;=0D > -- =0D > 2.39.2=0D =0D =0D =0D =0D =0D --===============6471602663248882704== 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 --===============6471602663248882704==--