From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 98A661FF0B7 for ; Mon, 30 Nov 2026 19:10:54 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 3BF1C21312; Mon, 30 Nov 2026 19:10:51 +0100 (CET) From: Jonas Theisen To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server v3 03/18] cpu flags: normalize underscores in all CPU flag names Date: Mon, 30 Nov 2026 19:09:35 +0100 Message-ID: <20261130181007.596064-4-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: 1796062222456 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.064 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: BOR3AYYPLUR6QHBTPH3CENWJTZLWZ7T3 X-Message-ID-Hash: BOR3AYYPLUR6QHBTPH3CENWJTZLWZ7T3 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: QEMU replaces underscores with dashes in all CPU flags of the '-cpu' option, see feat2prop() in target/i386/cpu.c. The alias map only covers the flags QEMU additionally registers with underscores, so normalizing other flags, for example the Hyper-V enlightenments that qemu-server passes as 'hv_stimer', kept the underscores, while QEMU reports them as 'hv-stimer'. Replace underscores in general, so that flags from a QEMU command line can be compared with the flags QEMU reports. The aliases that only replace dashes with underscores are now redundant and dropped. Signed-off-by: Jonas Theisen --- src/PVE/QemuServer/CPUFlags.pm | 37 ++++++++-------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/src/PVE/QemuServer/CPUFlags.pm b/src/PVE/QemuServer/CPUFlags.pm index 0d3206b2..d3b4bf1a 100644 --- a/src/PVE/QemuServer/CPUFlags.pm +++ b/src/PVE/QemuServer/CPUFlags.pm @@ -93,7 +93,8 @@ for my $arch (keys $supported_vm_specific_cpu_flags_by_arch->%*) { my @supported_cpu_flags_name_sorted = sort keys $all_supported_vm_specific_cpu_flags->%*; -# qemu/target/i386/cpu.c, x86_cpu_initfn() +# qemu/target/i386/cpu.c, x86_cpu_initfn(), without the aliases that only replace dashes by +# underscores, as normalize_cpu_flag() handles these my $qemu_cpu_flag_alias_map = { sse3 => 'pni', pclmuldq => 'pclmulqdq', @@ -102,46 +103,24 @@ my $qemu_cpu_flag_alias_map = { xd => 'nx', ffxsr => 'fxsr-opt', i64 => 'lm', - ds_cpl => 'ds-cpl', - tsc_adjust => 'tsc-adjust', - fxsr_opt => 'fxsr-opt', - lahf_lm => 'lahf-lm', - cmp_legacy => 'cmp-legacy', - nodeid_msr => 'nodeid-msr', - perfctr_core => 'perfctr-core', - perfctr_nb => 'perfctr-nb', - kvm_nopiodelay => 'kvm-nopiodelay', - kvm_mmu => 'kvm-mmu', - kvm_asyncpf => 'kvm-asyncpf', - kvm_asyncpf_int => 'kvm-asyncpf-int', - kvm_steal_time => 'kvm-steal-time', - kvm_pv_eoi => 'kvm-pv-eoi', - kvm_pv_unhalt => 'kvm-pv-unhalt', - kvm_poll_control => 'kvm-poll-control', - svm_lock => 'svm-lock', - nrip_save => 'nrip-save', - tsc_scale => 'tsc-scale', - vmcb_clean => 'vmcb-clean', - pause_filter => 'pause-filter', - sse4_1 => 'sse4.1', - sse4_2 => 'sse4.2', 'hv-apicv' => 'hv-avic', - lbr_fmt => 'lbr-fmt', }; =head3 normalize_cpu_flag($flag) Normalize a CPU flag to its QEMU form. -QEMU defines aliases for some CPU flags (see C in -C). For example, C and C are both aliases for -C. +QEMU accepts underscores instead of dashes in all CPU flags (see C in +C), and defines aliases for some CPU flags (see C). For +example, C and C are both aliases for C, and C is the same as +C. -If C<$flag> has a known alias, return that, otherwise return C<$flag> unchanged. +Return C<$flag> with underscores replaced by dashes, or the flag it is an alias for. =cut sub normalize_cpu_flag($flag) { + $flag =~ s/_/-/g; return $qemu_cpu_flag_alias_map->{$flag} // $flag; } -- 2.47.3