From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server v2 3/8] cpu config: introduce is_abstracted() helper
Date: Fri, 7 Nov 2025 15:43:41 +0100 [thread overview]
Message-ID: <20251107144429.126790-4-f.ebner@proxmox.com> (raw)
In-Reply-To: <20251107144429.126790-1-f.ebner@proxmox.com>
The helper reports whether the CPU configuration cannot be determined
from the configuration alone. Currently, this means using a custom
model, because that depends on the contents of the custom model
configuration. The next commit will add an abstract flag that depends
on the host.
Note that parse_property_string() returns a hash reference or fails,
so there is no need to check its return value for evaluating to true
in boolean context. Even if the check were necessary, having no result
should be treated as a failure, not quietly ignored.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
New in v2.
src/PVE/QemuMigrate.pm | 11 +++--------
src/PVE/QemuServer/CPUConfig.pm | 25 +++++++++++++++++++++++++
2 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/src/PVE/QemuMigrate.pm b/src/PVE/QemuMigrate.pm
index 78954c20..063fd6f2 100644
--- a/src/PVE/QemuMigrate.pm
+++ b/src/PVE/QemuMigrate.pm
@@ -226,14 +226,9 @@ sub prepare {
$self->{forcemachine} = PVE::QemuServer::Machine::qemu_machine_pxe($vmid, $conf);
- # To support custom CPU types, we keep QEMU's "-cpu" parameter intact.
- # Since the parameter itself contains no reference to a custom model,
- # this makes migration independent of changes to "cpu-models.conf".
- if ($conf->{cpu}) {
- my $cpuconf = PVE::JSONSchema::parse_property_string('pve-cpu-conf', $conf->{cpu});
- if ($cpuconf && PVE::QemuServer::CPUConfig::is_custom_model($cpuconf->{cputype})) {
- $self->{forcecpu} = PVE::QemuServer::CPUConfig::get_cpu_from_running_vm($pid);
- }
+ # To support abstracted CPU configurations, keep QEMU's "-cpu" parameter intact.
+ if ($conf->{cpu} && PVE::QemuServer::CPUConfig::is_abstracted($conf->{cpu})) {
+ $self->{forcecpu} = PVE::QemuServer::CPUConfig::get_cpu_from_running_vm($pid);
}
# Do not treat a suspended VM as paused, as it might wake up
diff --git a/src/PVE/QemuServer/CPUConfig.pm b/src/PVE/QemuServer/CPUConfig.pm
index ebec42d5..4cbd7b48 100644
--- a/src/PVE/QemuServer/CPUConfig.pm
+++ b/src/PVE/QemuServer/CPUConfig.pm
@@ -567,6 +567,31 @@ sub print_cpu_device {
return "$cpu-x86_64-cpu,id=cpu$id,socket-id=$current_socket,core-id=$current_core,thread-id=0";
}
+=head3 is_abstracted
+
+ if (is_abstracted($conf->{cpu})) {
+ # better check running CPU of QEMU instance
+ }
+
+Check if the configured CPU is abstracted in any way, meaning that the actual CPU model cannot be
+determined from the configuration alone. Possible abstractions:
+
+=over
+
+=item custom model: can change with updates to the custom model configuration
+
+=back
+
+=cut
+
+sub is_abstracted {
+ my ($cpu_property_string) = @_;
+
+ my $cpu_conf = PVE::JSONSchema::parse_property_string('pve-cpu-conf', $cpu_property_string);
+
+ return is_custom_model($cpu_conf->{cputype});
+}
+
# Resolves multiple arrays of hashes representing CPU flags with metadata to a
# single string in QEMU "-cpu" compatible format. Later arrays have higher
# priority.
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2025-11-07 14:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-07 14:43 [pve-devel] [PATCH-SERIES qemu-server/manager v2 0/8] VM CPU flags: introduce vendor-agnostic 'nested-virt' CPU flag Fiona Ebner
2025-11-07 14:43 ` [pve-devel] [PATCH qemu-server v2 1/8] critic: code style: cpu config: unpack @_ first in resolve_cpu_flags() Fiona Ebner
2025-11-07 14:43 ` [pve-devel] [PATCH qemu-server v2 2/8] api: add endpoint for querying available cpu flags Fiona Ebner
2025-11-07 14:43 ` Fiona Ebner [this message]
2025-11-07 14:43 ` [pve-devel] [PATCH qemu-server v2 4/8] cpu config: introduce vendor-agnostic 'nested-virt' CPU flag Fiona Ebner
2025-11-07 14:43 ` [pve-devel] [PATCH manager v2 5/8] api: capabilities: register module for VM CPU flags Fiona Ebner
2025-11-07 14:43 ` [pve-devel] [PATCH manager v2 6/8] ui: cpu flag selector: code style: use 'let' for declarations Fiona Ebner
2025-11-07 14:43 ` [pve-devel] [PATCH manager v2 7/8] ui: cpu flag selector: use simpler method to get all records of the store Fiona Ebner
2025-11-07 14:43 ` [pve-devel] [PATCH manager v2 8/8] ui: cpu flag selector: query CPU flag list via API 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=20251107144429.126790-4-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.