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 082D51FF16F for ; Thu, 19 Dec 2024 17:09:15 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2D235C5DD; Thu, 19 Dec 2024 17:09:15 +0100 (CET) From: Daniel Kral To: f.gruenbichler@proxmox.com Date: Thu, 19 Dec 2024 17:09:07 +0100 Message-Id: <20241219160907.187494-1-d.kral@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20240416122054.733817-18-f.gruenbichler@proxmox.com> References: <20240416122054.733817-18-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 4/6] update/hotplug: 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="===============6784693673322249836==" Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" --===============6784693673322249836== Content-Transfer-Encoding: quoted-printable On 16/04/2024 14:20, Fabian Gr=C3=BCnbichler wrote:=0D > if the new value is higher than the old one, check against limits. if the= old=0D > one is higher, then the change is always okay, to support reducing the us= age in=0D > steps spread over multiple guests..=0D > =0D > Signed-off-by: Fabian Gr=C3=BCnbichler =0D > ---=0D > PVE/API2/Qemu.pm | 22 ++++++++++++++++++++++=0D > PVE/QemuServer.pm | 7 +++++++=0D > PVE/QemuServer/Memory.pm | 6 ++++++=0D > 3 files changed, 35 insertions(+)=0D > =0D > diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm=0D > index f0ff785c..adbc6557 100644=0D > --- a/PVE/API2/Qemu.pm=0D > +++ b/PVE/API2/Qemu.pm=0D > @@ -1863,6 +1863,28 @@ my $update_vm_api =3D sub {=0D > }=0D > };=0D > =0D > + # check pool limits, but only if values increase, ignoring=0D > + # deletions and pending values=0D > + my $usage =3D PVE::QemuConfig->get_pool_usage($conf);=0D > + if (defined($param->{sockets}) || defined($param->{cores})) {=0D > + my $old =3D $usage->{cpu};=0D =0D Git complained about this line:=0D =0D Applying: update/hotplug: handle pool limits=0D .git/rebase-apply/patch:19: space before tab in indent.=0D my $old =3D $usage->{cpu};=0D warning: 1 line adds whitespace errors.=0D =0D > + my $new =3D $param->{sockets} || $usage->{sockets};=0D > + $new *=3D ($param->{cores} || $usage->{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 > + } elsif (defined($param->{memory})) {=0D > + my $old =3D $usage->{mem};=0D > + my $new =3D PVE::QemuServer::Memory::get_current_memory($param->{memor= y})*1024*1024;=0D > +=0D > + if ($new > $old) {=0D > + my $change =3D { mem =3D> $new - $old };=0D > + PVE::GuestHelpers::check_guest_pool_limit($vmid, $change);=0D > + }=0D > + }=0D > +=0D > foreach my $opt (@delete) {=0D > $modified->{$opt} =3D 1;=0D > $conf =3D PVE::QemuConfig->load_config($vmid); # update/reload=0D > diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm=0D > index 93eaaec5..be937ec1 100644=0D > --- a/PVE/QemuServer.pm=0D > +++ b/PVE/QemuServer.pm=0D > @@ -4617,6 +4617,13 @@ sub qemu_cpu_hotplug {=0D > }=0D > =0D > return;=0D > + } else {=0D > + my $changes =3D {=0D > + absolute =3D> 1,=0D > + running =3D> 1,=0D > + cpu =3D> $vcpus,=0D > + };=0D > + PVE::GuestHelpers::check_guest_pool_limit($vmid, $changes);=0D > }=0D > =0D > my $currentrunningvcpus =3D mon_cmd($vmid, "query-cpus-fast");=0D > diff --git a/PVE/QemuServer/Memory.pm b/PVE/QemuServer/Memory.pm=0D > index f365f2d1..b27b8b2b 100644=0D > --- a/PVE/QemuServer/Memory.pm=0D > +++ b/PVE/QemuServer/Memory.pm=0D > @@ -234,6 +234,12 @@ sub qemu_memory_hotplug {=0D > die "you cannot add more memory than max mem $MAX_MEM MB!\n" if $val= ue > $MAX_MEM;=0D > =0D > if ($value > $memory) {=0D > + my $changes =3D {=0D > + absolute =3D> 1,=0D =0D Shouldn't this be relative as the memory value is calculated as...=0D =0D > + running =3D> 1,=0D > + mem =3D> $memory - $value,=0D =0D the difference between the old and new value?=0D =0D Also, I can only guess from the context that these values are in MiB,=0D which would mean that this should be converted to bytes, but I could be=0D totally wrong here.=0D =0D Unfortunately, I'm unsure how to trigger this hotplug (as it only seems=0D to be called by `vmconfig_hotplug_pending`, which is called in=0D `do_import` and after another pool limit check in `update_vm_api`, so=0D the first call will always die first) without changing the code too=0D much. I'd be happy to know when this code gets executed.=0D =0D > + };=0D > + PVE::GuestHelpers::check_guest_pool_limit($vmid, $changes);=0D > =0D > my $numa_hostmap;=0D > =0D > -- =0D > 2.39.2=0D =0D =0D =0D =0D =0D --===============6784693673322249836== 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 --===============6784693673322249836==--