From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH qemu-server 2/2] cpu flags: introduce get_cpu_model_expansions() helper
Date: Thu, 30 Jul 2026 16:15:10 +0200 [thread overview]
Message-ID: <20260730141522.203966-3-f.ebner@proxmox.com> (raw)
In-Reply-To: <20260730141522.203966-1-f.ebner@proxmox.com>
Make the static list of CPU model expansions, which is newly shipped
by pve-qemu-kvm, accessible in qemu-server.
Note that some CPU flags in the expansions are gated behind others and
thus cannot be queried via the static expansions. Most prominently,
this is the case for the flags for nested virtualization. For example,
'Skylake-Server' will not support any vmx-* flags, but
'Skylake-Server,+vmx' would.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
src/PVE/QemuServer/CPUFlags.pm | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/src/PVE/QemuServer/CPUFlags.pm b/src/PVE/QemuServer/CPUFlags.pm
index 0d3206b2..60683486 100644
--- a/src/PVE/QemuServer/CPUFlags.pm
+++ b/src/PVE/QemuServer/CPUFlags.pm
@@ -3,6 +3,7 @@ package PVE::QemuServer::CPUFlags;
use v5.36;
use Exporter qw(import);
+use JSON qw();
use PVE::Cluster;
use PVE::File;
@@ -129,6 +130,32 @@ my $qemu_cpu_flag_alias_map = {
lbr_fmt => 'lbr-fmt',
};
+my $cpu_model_expansions;
+
+=head3 get_cpu_model_expansions($arch)
+
+Get the CPU model expansions for the given architecture C<$arch>. Will return C<undef> for QEMU
+package versions that don't yet ship the static model expansions. Note that some CPU flags in the
+expansions are gated behind others and thus cannot be queried via the static expansions. Most
+prominently, this is the case for the flags for nested virtualization. For example,
+C<Skylake-Server> will not support any C<vmx-*> flags, but C<Skylake-Server,+vmx> would. The latter
+cannot be queried here.
+
+=cut
+
+my sub get_cpu_model_expansions($arch) {
+ if (!defined($cpu_model_expansions->{$arch})) {
+ my $cpu_models_file = "/usr/share/kvm/cpu-model-expansions-${arch}.json";
+ return if !PVE::File::file_exists($cpu_models_file);
+
+ my $data = PVE::File::file_get_contents($cpu_models_file, 10 * 1024 * 1024);
+
+ $cpu_model_expansions->{$arch} = JSON::decode_json($data);
+ }
+
+ return $cpu_model_expansions->{$arch};
+}
+
=head3 normalize_cpu_flag($flag)
Normalize a CPU flag to its QEMU form.
--
2.47.3
next prev parent reply other threads:[~2026-07-30 14:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-30 14:15 [RFC qemu/qemu-server 0/2] qemu: dump and ship CPU model expansions Fiona Ebner
2026-07-30 14:15 ` Fiona Ebner [this message]
2026-07-31 8:09 ` Arthur Bied-Charreton
2026-07-31 9:12 ` Fiona Ebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260730141522.203966-3-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.