api: qemu machine capabilities: add custom pveX versions

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@proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Reviewed-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Tested-By: Stoiko Ivanov <s.ivanov@proxmox.com>
Link: https://lore.proxmox.com/20250404125345.3244659-8-d.csapak@proxmox.com
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Dominik Csapak 2025-04-04 14:53:43 +02:00 committed by Thomas Lamprecht
parent 57db7085b8
commit 71f2307eaf

View File

@ -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);
@ -49,12 +50,33 @@ __PACKAGE__->register_method({
},
},
code => sub {
my $machines = eval {
my $supported_machine_list = eval {
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->@*];
};
die "could not load supported machine versions - $@\n" if $@;
return $machines;
return $supported_machine_list;
}
});