From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 2C9481FF142 for ; Fri, 22 May 2026 15:21:33 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2B2E2BA3A; Fri, 22 May 2026 15:21:26 +0200 (CEST) From: Arthur Bied-Charreton To: pve-devel@lists.proxmox.com Subject: [PATCH pve-qemu 2/3] build: query Hyper-V enlightenment flags for CPU flags list Date: Fri, 22 May 2026 15:21:21 +0200 Message-ID: <20260522132122.712794-3-a.bied-charreton@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260522132122.712794-1-a.bied-charreton@proxmox.com> References: <20260522132122.712794-1-a.bied-charreton@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.133 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 KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Message-ID-Hash: ID4EIL4HELNONLUXMDIOBUHOXNIJ3QOQ X-Message-ID-Hash: ID4EIL4HELNONLUXMDIOBUHOXNIJ3QOQ X-MailFrom: abied-charreton@jett.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 recognized CPU flags list shipped with pve-qemu-kvm must include Hyper-V enlightenment flags so the custom CPU models API can offer them. Query them from the 'host-x86_64-cpu' type via QMP (qom-list-properties) in parse-cpu-flags.pl, filtering for properties with the 'hv-' prefix, and include them in the recognized flags list. Filter out non-boolean enlightenments, since the custom CPU model config only supports enable/disable. Suggested-by: Fiona Ebner Signed-off-by: Arthur Bied-Charreton --- debian/parse-cpu-flags.pl | 42 +++++++++++++++++++++++++++++++++++++++ debian/rules | 2 +- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/debian/parse-cpu-flags.pl b/debian/parse-cpu-flags.pl index 1847b3e..2b5d32a 100755 --- a/debian/parse-cpu-flags.pl +++ b/debian/parse-cpu-flags.pl @@ -2,7 +2,10 @@ use warnings; use strict; +use IPC::Open2; +use JSON; +my ($qemu_bin) = @ARGV; my @flags = (); my $got_flags_section; @@ -20,4 +23,43 @@ while () { die "no QEMU/KVM CPU flags detected from STDIN input" if scalar (@flags) <= 0; +my $pid = open2( + my $out, + my $in, + $qemu_bin, + '-machine', + 'none', + '-display', + 'none', + '-S', + '-qmp', + 'stdio', +); + +sub qmp { + my ($cmd, %args) = @_; + print $in encode_json({ execute => $cmd, %args ? (arguments => \%args) : () }), "\n"; + while (my $line = <$out>) { + my $msg = decode_json($line); + next if $msg->{event}; + return $msg->{return} if exists $msg->{return}; + die "QMP error: " . encode_json($msg->{error}) if $msg->{error}; + } +} + +<$out>; +qmp('qmp_capabilities'); +my $props = qmp('qom-list-properties', typename => 'host-x86_64-cpu'); +for my $qo ($props->@*) { + # Filter out non-boolean flags, our custom CPU model config only supports + # enable/disable. + if (index($qo->{name}, 'hv-') == 0 && $qo->{type} eq 'bool') { + push @flags, $qo->{name}; + } +} +qmp('quit'); +waitpid($pid, 0); + +@flags = sort @flags; + print join("\n", @flags) or die "$!\n"; diff --git a/debian/rules b/debian/rules index c90db29..e3eebe8 100755 --- a/debian/rules +++ b/debian/rules @@ -123,7 +123,7 @@ install: build rm -f $(destdir)/usr/lib/kvm/virtfs-proxy-helper # CPU flags are static for QEMU version, allows avoiding more costly checks - $(destdir)/usr/bin/qemu-system-x86_64 -cpu help | ./debian/parse-cpu-flags.pl > $(flagfile) + $(destdir)/usr/bin/qemu-system-x86_64 -cpu help | ./debian/parse-cpu-flags.pl $(destdir)/usr/bin/qemu-system-x86_64 > $(flagfile) # Supported machine versions are static for a given QEMU binary. $(destdir)/usr/bin/qemu-system-x86_64 -machine help | ./debian/parse-machines.pl > $(machine_file_x86_64) -- 2.47.3