[pve-devel] [PATCH qemu-server v2 7/8] api: qemu machine capabilities: add custom pveX versions too

Fiona Ebner f.ebner at proxmox.com
Fri Apr 4 14:02:00 CEST 2025


Am 07.03.25 um 15:44 schrieb Dominik Csapak:
> Add the pveX variants (where X > 0) to the list too, so one knows they
> exits. Also this allows them to be shown and chosen in the UI.
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
> new in v2
>  PVE/API2/Qemu/Machine.pm | 24 +++++++++++++++++++++++-
>  1 file changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/PVE/API2/Qemu/Machine.pm b/PVE/API2/Qemu/Machine.pm
> index afb535c2..11eba34b 100644
> --- a/PVE/API2/Qemu/Machine.pm
> +++ b/PVE/API2/Qemu/Machine.pm
> @@ -6,6 +6,7 @@ use warnings;
>  use JSON;
>  
>  use PVE::JSONSchema qw(get_standard_option);
> +use PVE::QemuServer::Machine;
>  use PVE::RESTHandler;
>  use PVE::Tools qw(file_get_contents);
>  
> @@ -51,7 +52,28 @@ __PACKAGE__->register_method({
>      code => sub {
>  	my $machines = eval {

I'd rename the outer variable to $result to avoid the name re-use.

>  	    my $raw = file_get_contents('/usr/share/kvm/machine-versions-x86_64.json');
> -	    return from_json($raw, { utf8 => 1 });
> +	    my $machines = from_json($raw, { utf8 => 1 });
> +
> +	    my $to_add = [];
> +
> +	    for my $machine ($machines->@*) {
> +		my $base_version = $machine->{version};
> +		my $pvever = PVE::QemuServer::Machine::get_pve_version($base_version);
> +		for (my $i = 1; $i <= $pvever; $i++) {
> +		    my $version = $base_version . "+pve$i";
> +		    my $entry = {
> +			id => $machine->{id} . "+pve$i",
> +			type => $machine->{type},
> +			version => $version,
> +		    };
> +
> +		    push $to_add->@*, $entry;
> +		}
> +	    }
> +
> +	    push $machines->@*, $to_add->@*;
> +
> +	    return [sort { $b->{id} cmp $a->{id} } $machines->@*];

Orthogonal to the series, but if you find the time: we should sort
numerically here. It's already broken for 2.10, 2.11, 2.12 and while
those will be gone soon, QEMU 10 will be here soon ;)

>  	};
>  	die "could not load supported machine versions - $@\n" if $@;
>  	return $machines;





More information about the pve-devel mailing list