From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 8E0801FF0B7 for ; Mon, 30 Nov 2026 19:11:30 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id C9D74217A5; Mon, 30 Nov 2026 19:10:52 +0100 (CET) From: Jonas Theisen To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server v3 07/18] cpu flags: factor out the flags of a CPU model expansion Date: Mon, 30 Nov 2026 19:09:39 +0100 Message-ID: <20261130181007.596064-8-j.theisen@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261130181007.596064-1-j.theisen@proxmox.com> References: <20261130181007.596064-1-j.theisen@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1796062230802 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.063 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: XTFLRFULA6L526BE27TQG3HXORDMXU65 X-Message-ID-Hash: XTFLRFULA6L526BE27TQG3HXORDMXU65 X-MailFrom: j.theisen@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Move collecting the flags that a result of 'query-cpu-model-expansion' enables into a helper, so that checks of the virtual CPU of a running VM can read the flags of its CPU model the same way as the flags supported by a node. No functional change intended. Signed-off-by: Jonas Theisen --- src/PVE/QemuServer.pm | 9 ++------- src/PVE/QemuServer/CPUFlags.pm | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm index 1d665877..f8b3094f 100644 --- a/src/PVE/QemuServer.pm +++ b/src/PVE/QemuServer.pm @@ -3038,13 +3038,8 @@ sub query_supported_cpu_flags { model => $model, ); - my $props = $cmd_result->{model}->{props}; - foreach my $prop (keys %$props) { - next if $props->{$prop} ne JSON::true; - $prop = PVE::QemuServer::CPUFlags::normalize_cpu_flag($prop); - - $flags->{$prop} = 1; - } + $flags->{$_} = 1 + for PVE::QemuServer::CPUFlags::get_cpu_expansion_flags($cmd_result); }; my $err = $@; diff --git a/src/PVE/QemuServer/CPUFlags.pm b/src/PVE/QemuServer/CPUFlags.pm index f35ce1a5..c188c30a 100644 --- a/src/PVE/QemuServer/CPUFlags.pm +++ b/src/PVE/QemuServer/CPUFlags.pm @@ -3,6 +3,7 @@ package PVE::QemuServer::CPUFlags; use v5.36; use Exporter qw(import); +use JSON (); use PVE::Cluster; use PVE::File; @@ -124,6 +125,19 @@ sub normalize_cpu_flag($flag) { return $qemu_cpu_flag_alias_map->{$flag} // $flag; } +=head3 get_cpu_expansion_flags($expansion) + +Return the CPU flags that a result of the QMP command C enables, +normalized with C. As the expansion also includes CPU properties that are no +flags, the result can contain these as well. + +=cut + +sub get_cpu_expansion_flags($expansion) { + my $props = $expansion->{model}->{props} // {}; + return map { normalize_cpu_flag($_) } grep { ($props->{$_} // '') eq JSON::true } keys %$props; +} + =head3 parse_node_cpu_flags($raw) Parse the CPU flags of a node, as C broadcasts them in the C node -- 2.47.3