[pve-devel] [PATCH qemu-server 3/7] api: add endpoint for querying available cpu flags
Thomas Lamprecht
t.lamprecht at proxmox.com
Thu Nov 6 19:02:12 CET 2025
Am 31.10.25 um 13:28 schrieb Fiona Ebner:
> Descriptions and ordering are taken from pve-manager's
> VMCPUFlagSelector.js. The double quotes in the descriptions were
> replaced with single quotes to have nicer JSON output.
>
> Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
> ---
> src/PVE/API2/Qemu/CPUFlags.pm | 45 +++++++++++++++++++
> src/PVE/API2/Qemu/Makefile | 2 +-
> src/PVE/QemuServer/CPUConfig.pm | 76 +++++++++++++++++++++++++--------
> 3 files changed, 105 insertions(+), 18 deletions(-)
> create mode 100644 src/PVE/API2/Qemu/CPUFlags.pm
>
> diff --git a/src/PVE/API2/Qemu/CPUFlags.pm b/src/PVE/API2/Qemu/CPUFlags.pm
> new file mode 100644
> index 00000000..cc06a1d6
> --- /dev/null
> +++ b/src/PVE/API2/Qemu/CPUFlags.pm
> @@ -0,0 +1,45 @@
> +__PACKAGE__->register_method({
> + links => [{ rel => 'child', href => '{flag}' }],
We do not have any routes below this, is there any benefit of
declaring the links upfront? OTOH, there's also no real downside
either IIRC so probably can stay.
> diff --git a/src/PVE/QemuServer/CPUConfig.pm b/src/PVE/QemuServer/CPUConfig.pm
> index e72bdf2f..20e26ee2 100644
> --- a/src/PVE/QemuServer/CPUConfig.pm
> +++ b/src/PVE/QemuServer/CPUConfig.pm
> @@ -161,21 +161,62 @@ my $cpu_vendor_list = {
> max => 'default',
> };
>
> -my @supported_cpu_flags = (
> - 'pcid',
> - 'spec-ctrl',
> - 'ibpb',
> - 'ssbd',
> - 'virt-ssbd',
> - 'amd-ssbd',
> - 'amd-no-ssb',
> - 'pdpe1gb',
> - 'md-clear',
> - 'hv-tlbflush',
> - 'hv-evmcs',
> - 'aes',
> -);
> -my $cpu_flag_supported_re = qr/([+-])(@{[join('|', @supported_cpu_flags)]})/;
> +our $supported_cpu_flags = [
I'd slightly prefer keeping this private to the module here and instead add a
getter method. Doing so reduces the impact for side-effect when some usage side
would modify this array-ref by accident.
More information about the pve-devel
mailing list