machine: improve code style in get_pve_version

This makes it a bit more obvious what happens and having an actual
error for bogus $PVE_MACHINE_VERSION entries.

Note that there was no auto-vivification before, as we never directly
accessed $PVE_MACHINE_VERSION->{$verstr}->{highest} but used
get_machine_pve_revisions to query a specific QEMU machine version's
PVE revisions and then operated on the return value, and that method
returns undef if there is no entry at all.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2025-04-07 17:10:36 +02:00
parent a9a5d37bc6
commit cbe9de99c5

View File

@ -191,9 +191,11 @@ sub get_machine_pve_revisions {
sub get_pve_version {
my ($verstr) = @_;
my $pve_machine = get_machine_pve_revisions($verstr);
if (my $pve_machine = get_machine_pve_revisions($verstr)) {
return $pve_machine->{highest} || die "internal error - machine version '$verstr' missing 'highest'";
}
return $pve_machine->{highest} // 0;
return 0;
}
sub can_run_pve_machine_version {