From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 26E0F1FF187 for ; Mon, 20 Oct 2025 18:45:28 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 202B0D9FA; Mon, 20 Oct 2025 18:45:49 +0200 (CEST) From: Daniel Kral To: pve-devel@lists.proxmox.com Date: Mon, 20 Oct 2025 18:45:27 +0200 Message-ID: <20251020164540.517231-2-d.kral@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251020164540.517231-1-d.kral@proxmox.com> References: <20251020164540.517231-1-d.kral@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1760978738201 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.013 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH qemu-server v2 1/1] config: only fetch necessary default values in get_derived_property 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" get_derived_property(...) is called in the semi-hot path of the HA Manager's static load scheduler to retrieve the static stats of each VM. As the defaults are only needed in certain cases and for a very small subset of properties in the VM config, get those separately when needed. Signed-off-by: Daniel Kral --- changes since v1: - none src/PVE/QemuConfig.pm | 8 +++----- src/PVE/QemuServer.pm | 6 ++++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/PVE/QemuConfig.pm b/src/PVE/QemuConfig.pm index bb469197..ad6ce6b0 100644 --- a/src/PVE/QemuConfig.pm +++ b/src/PVE/QemuConfig.pm @@ -582,12 +582,10 @@ sub load_current_config { sub get_derived_property { my ($class, $conf, $name) = @_; - my $defaults = PVE::QemuServer::load_defaults(); - if ($name eq 'max-cpu') { - my $cpus = - ($conf->{sockets} || $defaults->{sockets}) * ($conf->{cores} || $defaults->{cores}); - return $conf->{vcpus} || $cpus; + my $sockets = $conf->{sockets} || PVE::QemuServer::get_default_property_value('sockets'); + my $cores = $conf->{cores} || PVE::QemuServer::get_default_property_value('cores'); + return $conf->{vcpus} || ($sockets * $cores); } elsif ($name eq 'max-memory') { # current usage maximum, not maximum hotpluggable return get_current_memory($conf->{memory}) * 1024 * 1024; } else { diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm index df2476aa..8b8e8338 100644 --- a/src/PVE/QemuServer.pm +++ b/src/PVE/QemuServer.pm @@ -2126,6 +2126,12 @@ sub write_vm_config { return $raw; } +sub get_default_property_value { + my ($name) = @_; + + return $confdesc->{$name}->{default}; +} + sub load_defaults { my $res = {}; -- 2.47.3 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel