[PATCH qemu-server 1/4] cpu config: split resolve_cpu_flags() function

Fiona Ebner
2026-03-23T13:29:12Z

In preparation to re-use the resolved flags for a check.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
src/PVE/QemuServer/CPUConfig.pm | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/PVE/QemuServer/CPUConfig.pm b/src/PVE/QemuServer/CPUConfig.pm
index 1a4f2510..c689efad 100644
--- a/src/PVE/QemuServer/CPUConfig.pm
+++ b/src/PVE/QemuServer/CPUConfig.pm
@@ -778,7 +778,7 @@ sub is_abstracted {
# },
# ...
# }
-sub resolve_cpu_flags {
+my sub resolve_cpu_flags {
my @flag_hashes = @_;

my $flags = {};
@@ -836,6 +836,12 @@ sub resolve_cpu_flags {
}
}

+ return $flags;
+}
+
+my sub print_cpu_flags {
+ my ($flags) = @_;
+
my $flag_str = '';
# sort for command line stability
for my $flag_name (sort keys %$flags) {
@@ -957,7 +963,7 @@ sub get_cpu_options {
my $cpu_str = $cputype;

# will be resolved in parameter order
- $cpu_str .= resolve_cpu_flags(
+ my $resolved_flags = resolve_cpu_flags(
$pve_flags,
$hv_flags,
$builtin_cputype_flags,
@@ -965,6 +971,7 @@ sub get_cpu_options {
$vm_flags,
$pve_forced_flags,
);
+ $cpu_str .= print_cpu_flags($resolved_flags);