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 3DDD81FF0C0 for ; Wed, 18 Nov 2026 16:42:54 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id CCCCD2183B; Wed, 18 Nov 2026 16:42:42 +0100 (CET) From: Jonas Theisen To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server 04/15] cpu flags: factor out parsing the broadcast CPU flags of a node Date: Wed, 18 Nov 2026 16:40:35 +0100 Message-ID: <20261118154207.424260-5-j.theisen@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261118154207.424260-1-j.theisen@proxmox.com> References: <20261118154207.424260-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: 1795016546924 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.089 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: HP6NW2J4V47QFN77N72XVPKNSLXNE6PP X-Message-ID-Hash: HP6NW2J4V47QFN77N72XVPKNSLXNE6PP 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: The CPU flags that pvestatd broadcasts need to be normalized, as nodes running an older version also broadcast aliases of some flags, for example 'sse4_2' and 'sse4-2' in addition to 'sse4.2'. Factor this out, so that other users of the broadcast flags cannot forget about it. Signed-off-by: Jonas Theisen --- src/PVE/QemuServer/CPUFlags.pm | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/PVE/QemuServer/CPUFlags.pm b/src/PVE/QemuServer/CPUFlags.pm index 0d3206b2..0ba2e115 100644 --- a/src/PVE/QemuServer/CPUFlags.pm +++ b/src/PVE/QemuServer/CPUFlags.pm @@ -145,6 +145,20 @@ sub normalize_cpu_flag($flag) { return $qemu_cpu_flag_alias_map->{$flag} // $flag; } +=head3 parse_node_cpu_flags($raw) + +Parse the CPU flags of a node, as C broadcasts them in the C node +key-value entries, and return them normalized with C. + +The broadcast format may differ from the current one, for example if the node runs an older +version, which also broadcast the aliases of some flags. + +=cut + +sub parse_node_cpu_flags($raw) { + return map { normalize_cpu_flag($_) } split(' ', $raw); +} + # Understood CPU flags are written to a file at 'pve-qemu' compile time and # shipped below this directory by the pve-qemu-kvm package. my $understood_cpu_flag_dir = "/usr/share/kvm"; @@ -295,12 +309,7 @@ sub query_available_cpu_flags($accel, $vm_specific, $arch) { }; for my $node (keys %$flags) { - # This depends on `pvestatd` storing the flags in space-separated format, which - # is the case at the time of this commit. - for (split(' ', $flags->{$node})) { - # normalize as pvestatd's stored format may drift relative to the recognized - # flag list, e.g. across upgrades or between QEMU CPUID-flag aliases. - my $flag = normalize_cpu_flag($_); + for my $flag (parse_node_cpu_flags($flags->{$node})) { my $pve_alias = undef; $pve_alias = 'nested-virt' if $flag eq 'svm' || $flag eq 'vmx'; next if $vm_specific && !flag_is_vm_specific($flag) && !$pve_alias; -- 2.47.3