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 23EC895091 for ; Tue, 28 Feb 2023 11:54:46 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 088CF5A76 for ; Tue, 28 Feb 2023 11:54:16 +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) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Tue, 28 Feb 2023 11:54:15 +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 E1E72482F4 for ; Tue, 28 Feb 2023 11:54:14 +0100 (CET) From: Fiona Ebner To: pve-devel@lists.proxmox.com Date: Tue, 28 Feb 2023 11:54:10 +0100 Message-Id: <20230228105410.51078-5-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230228105410.51078-1-f.ebner@proxmox.com> References: <20230228105410.51078-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.003 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 SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [pvevm.pm, pvect.pm] Subject: [pve-devel] [PATCH ha-manager 1/1] resources: pve: avoid relying on internal configuration details 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: Tue, 28 Feb 2023 10:54:46 -0000 Instead, use the new get_derived_property() method to get the same information in a way that is robust regarding changes in the configuration structure. Signed-off-by: Fiona Ebner --- src/PVE/HA/Resources/PVECT.pm | 4 ++-- src/PVE/HA/Resources/PVEVM.pm | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/PVE/HA/Resources/PVECT.pm b/src/PVE/HA/Resources/PVECT.pm index e77d98c..6e14692 100644 --- a/src/PVE/HA/Resources/PVECT.pm +++ b/src/PVE/HA/Resources/PVECT.pm @@ -158,8 +158,8 @@ sub get_static_stats { my $conf = PVE::LXC::Config->load_config($id, $service_node); return { - maxcpu => $conf->{cpulimit} || $conf->{cores} || 0, - maxmem => ($conf->{memory} || 512) * 1024 * 1024, + maxcpu => PVE::LXC::Config->get_derived_property($conf, 'max-cpu'), + maxmem => PVE::LXC::Config->get_derived_property($conf, 'max-memory'), }; } diff --git a/src/PVE/HA/Resources/PVEVM.pm b/src/PVE/HA/Resources/PVEVM.pm index f405d86..1543a2d 100644 --- a/src/PVE/HA/Resources/PVEVM.pm +++ b/src/PVE/HA/Resources/PVEVM.pm @@ -179,13 +179,10 @@ sub get_static_stats { my ($class, $haenv, $id, $service_node) = @_; my $conf = PVE::QemuConfig->load_config($id, $service_node); - my $defaults = PVE::QemuServer::load_defaults(); - - my $cpus = ($conf->{sockets} || $defaults->{sockets}) * ($conf->{cores} || $defaults->{cores}); return { - maxcpu => $conf->{vcpus} || $cpus, - maxmem => ($conf->{memory} || $defaults->{memory}) * 1024 * 1024, + maxcpu => PVE::QemuConfig->get_derived_property($conf, 'max-cpu'), + maxmem => PVE::QemuConfig->get_derived_property($conf, 'max-memory'), }; } -- 2.30.2