From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9])
	by lore.proxmox.com (Postfix) with ESMTPS id DB28F1FF16F
	for <inbox@lore.proxmox.com>; Thu, 19 Dec 2024 17:10:06 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 72B30C67A;
	Thu, 19 Dec 2024 17:10:06 +0100 (CET)
From: Daniel Kral <d.kral@proxmox.com>
To: f.gruenbichler@proxmox.com
Date: Thu, 19 Dec 2024 17:09:28 +0100
Message-Id: <20241219160928.187737-1-d.kral@proxmox.com>
X-Mailer: git-send-email 2.39.5
In-Reply-To: <20240416122054.733817-19-f.gruenbichler@proxmox.com>
References: <20240416122054.733817-19-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 5/6] start: handle pool limits
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Cc: pve-devel@lists.proxmox.com
Content-Type: multipart/mixed; boundary="===============8527652372099638858=="
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com>

--===============8527652372099638858==
Content-Transfer-Encoding: quoted-printable

On 16/04/2024 14:20, Fabian Gr=C3=BCnbichler wrote:=0D
> if the start is not part of an incoming migration, check the VM against i=
ts=0D
> pool's run limit.=0D
> =0D
> Signed-off-by: Fabian Gr=C3=BCnbichler <f.gruenbichler@proxmox.com>=0D
> ---=0D
>  PVE/QemuServer.pm | 13 +++++++++++++=0D
>  1 file changed, 13 insertions(+)=0D
> =0D
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm=0D
> index be937ec1..78b6ff96 100644=0D
> --- a/PVE/QemuServer.pm=0D
> +++ b/PVE/QemuServer.pm=0D
> @@ -5704,6 +5704,19 @@ sub vm_start_nolock {=0D
>  	    # But we do it above, so for now let's be consistent.=0D
>  	    $conf =3D PVE::QemuConfig->load_config($vmid); # update/reload=0D
>  	}=0D
> +=0D
> +	my $cpu_count =3D 1;=0D
> +	$cpu_count =3D $conf->{sockets} if $conf->{sockets};=0D
> +	$cpu_count *=3D ($conf->{cores} || 1);=0D
> +	$cpu_count =3D $conf->{vcpus} if $conf->{vcpus} && $conf->{vcpus} < $cp=
u_count;=0D
> +=0D
> +	my $changes =3D {=0D
> +	    absolute =3D> 1,=0D
> +	    running =3D> 1,=0D
> +	    mem =3D> get_current_memory($conf->{memory}),=0D
=0D
Bug: The memory value here should be converted from MiB to bytes, else=0D
the pool limit will not be enforced as `check_guest_pool_limit` expects=0D
the value to be in bytes, i.e. `get_current_memory(...) * 1024 * 1024`.=0D
=0D
Spotted it by starting a second VM (which would've raised the memory=0D
usage over the limit) and wondered why it didn't fail. For the third VM=0D
I got:=0D
=0D
```=0D
pool limits exhausted: (run) mem: 4096 + 0.001953125 over 3072=0D
```=0D
=0D
> +	    cpu =3D> $cpu_count,=0D
> +	};=0D
> +	PVE::GuestHelpers::check_guest_pool_limit($vmid, $changes);=0D
>      }=0D
>  =0D
>      # override offline migrated volumes, conf is out of date still=0D
> -- =0D
> 2.39.2=0D
=0D
=0D
=0D
=0D
=0D



--===============8527652372099638858==
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

--===============8527652372099638858==--