From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 0C71F93D47 for ; Wed, 22 Feb 2023 16:19:33 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id DF88A1A7AE for ; Wed, 22 Feb 2023 16:19:02 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 22 Feb 2023 16:19:02 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 2880D4815C; Wed, 22 Feb 2023 16:19:02 +0100 (CET) Message-ID: <150672a8-5b21-e9ee-ee65-427d6459f81f@proxmox.com> Date: Wed, 22 Feb 2023 16:19:01 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 From: Fiona Ebner To: Proxmox VE development discussion , Alexandre Derumier References: <20230213120021.3783742-1-aderumier@odiso.com> <20230213120021.3783742-10-aderumier@odiso.com> Content-Language: en-US In-Reply-To: <20230213120021.3783742-10-aderumier@odiso.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.044 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -0.095 Looks like a legit reply (A) 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 v4 qemu-server 09/16] memory: get_max_mem: use config memory max 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: , X-List-Received-Date: Wed, 22 Feb 2023 15:19:33 -0000 Am 13.02.23 um 13:00 schrieb Alexandre Derumier: > diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm > index 9b80da1..6627910 100644 > --- a/PVE/API2/Qemu.pm > +++ b/PVE/API2/Qemu.pm > @@ -32,7 +32,7 @@ use PVE::QemuServer::Drive; > use PVE::QemuServer::ImportDisk; > use PVE::QemuServer::Monitor qw(mon_cmd); > use PVE::QemuServer::Machine; > -use PVE::QemuServer::Memory qw(get_current_memory); > +use PVE::QemuServer::Memory qw(get_current_memory parse_memory get_host_max_mem); > use PVE::QemuMigrate; > use PVE::RPCEnvironment; > use PVE::AccessControl; > @@ -476,6 +476,26 @@ my $create_disks = sub { > return ($vollist, $res); > }; > > +my $check_memory_param = sub { > + my ($conf, $param) = @_; > + Nit: Could also die if current > max. > + my $mem = parse_memory($param->{memory}); > + my $host_max_mem = get_host_max_mem($conf); > + > + die "memory max can't be bigger than supported cpu architecture $host_max_mem MiB\n" > + if $mem->{max} && $mem->{max} > $host_max_mem; > + > + if ($param->{memory} || defined($param->{balloon})) { > + > + my $memory = $param->{memory} || $conf->{pending}->{memory} || $conf->{memory}; > + my $maxmem = get_current_memory($memory); > + my $balloon = defined($param->{balloon}) ? $param->{balloon} : $conf->{pending}->{balloon} || $conf->{balloon}; > + > + die "balloon value too large (must be smaller than assigned memory)\n" > + if $balloon && $balloon > $maxmem; > + } > +}; > + > my $check_cpu_model_access = sub { > my ($rpcenv, $authuser, $new, $existing) = @_; >