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 AE96E1FF13F for ; Thu, 07 May 2026 13:15:24 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 55AFA14867; Thu, 7 May 2026 13:15:22 +0200 (CEST) Message-ID: <5134446a-b30e-4aa6-a2b3-d7e5256746da@proxmox.com> Date: Thu, 7 May 2026 13:15:14 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH qemu-server v4 03/17] cpu flags: move cpu flags-related utilities to their own module To: Arthur Bied-Charreton , pve-devel@lists.proxmox.com References: <20260430160109.565536-1-a.bied-charreton@proxmox.com> <20260430160109.565536-4-a.bied-charreton@proxmox.com> Content-Language: en-US From: Fiona Ebner In-Reply-To: <20260430160109.565536-4-a.bied-charreton@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1778152406828 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.009 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 SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [cpuflags.pm] Message-ID-Hash: 73MBBXFZBTDPD2ZIYD5ES6VG3RX5IOZU X-Message-ID-Hash: 73MBBXFZBTDPD2ZIYD5ES6VG3RX5IOZU X-MailFrom: f.ebner@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: Am 30.04.26 um 6:01 PM schrieb Arthur Bied-Charreton: > -sub get_supported_cpu_flags { The caller in src/PVE/API2/Qemu/CPUFlags.pm still does: PVE::QemuServer::CPUConfig::get_supported_cpu_flags($arch) and should be updated as part of this patch. > - my ($arch) = @_; > - $arch = get_host_arch() if !defined($arch); You changed the logic in the moved function and make $arch required. Again, the caller in src/PVE/API2/Qemu/CPUFlags.pm would need to be updated for this. ---snip 8<--- > +my $all_supported_vm_specific_cpu_flags = {}; > +for my $arch ($supported_vm_specific_cpu_flags_by_arch->%*) { > + for my $flag ($supported_vm_specific_cpu_flags_by_arch->{$arch}->@*) { > + $all_supported_vm_specific_cpu_flags->{ $flag->{name} } = 1; > + } > +} > + > +# Understood CPU flags are written to a file at 'pve-qemu' compile time Nit: pre-existing, but maybe add "and shipped below this directory by the pve-qemu-kvm package" > +my $understood_cpu_flag_dir = "/usr/share/kvm"; > + > +sub supported_cpu_flags_names() { > + return sort keys $all_supported_vm_specific_cpu_flags->%*; Nit: perlcritic complains here: "return" statement followed by "sort" at line 98, column 5. Behavior is undefined if called in scalar context. (Severity: 5) Also, you can do the sort once upon module load and then just return that result. > +} > + > +sub cpu_flag_supported_re() { > + return qr/([+-])(@{[join('|', supported_cpu_flags_names())]})/; > +} > + > +sub cpu_flag_any_re() { > + return qr/([+-])([a-zA-Z0-9\-_\.]+)/; > +} > + > +# Return supported VM-specific CPU flags. > +sub get_supported_cpu_flags($arch) { > + return $supported_vm_specific_cpu_flags_by_arch->{$arch}; > +} > + > +sub query_understood_cpu_flags($arch) { > + my $filepath = "$understood_cpu_flag_dir/recognized-CPUID-flags-$arch"; > + > + die "Cannot query understood QEMU CPU flags for architecture: $arch (file not found)\n" > + if !-e $filepath; > + > + my $raw = PVE::Tools::file_get_contents($filepath); Nit: please use PVE::File instead > + $raw =~ s/^\s+|\s+$//g; > + my @flags = split(/\s+/, $raw); > + > + return \@flags; > +} Nit: please insert a blank here > +1;