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 6AF1E1FF0BC for ; Wed, 02 Dec 2026 16:19:20 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 6D7AF21849; Wed, 02 Dec 2026 16:18:54 +0100 (CET) From: Jonas Theisen To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server v4 03/21] cpu flags: normalize underscores in all CPU flag names Date: Wed, 2 Dec 2026 16:17:59 +0100 Message-ID: <20261202151831.414110-4-j.theisen@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261202151831.414110-1-j.theisen@proxmox.com> References: <20261202151831.414110-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: 1796224724416 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.058 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: JZA3PA2HSO3VBUPMD7UOIVAGOANDDD7T X-Message-ID-Hash: JZA3PA2HSO3VBUPMD7UOIVAGOANDDD7T 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 the flags of the '-cpu' option that are not prefixed with '+' or '-', see feat2prop() in target/i386/cpu.c. For some flags, it also registers aliases with underscores, which work with these prefixes as well. The alias map only covers the latter, so other flags kept underscores, for example the Hyper-V enlightenments that qemu-server passes as 'hv_stimer', while QEMU reports 'hv-stimer'. Replace underscores in general, as every spelling QEMU accepts refers to the flag with dashes, so that flags from a QEMU command line can be compared with the flags QEMU reports, and drop the now redundant aliases. 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..57fdabcf 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 replaces underscores with dashes in CPU flags given without C<+> or C<-> (see C +in C), and defines aliases for some CPU flags (see C), which +include underscore spellings that also work with these prefixes. 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