]> git.proxmox.com Git - qemu-server.git/commitdiff
machine: get current: make it clear that pve-version only exists for the current...
authorFiona Ebner <f.ebner@proxmox.com>
Fri, 10 Nov 2023 13:24:47 +0000 (14:24 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sun, 12 Nov 2023 17:48:01 +0000 (18:48 +0100)
by adding a comment and grouping the code better. See the PVE QEMU
patch "PVE: Allow version code in machine type" for reference. The way
the code was written previously made it look like a bug where
$pve_version might be overwritten multiple times.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
PVE/QemuServer/Machine.pm

index a4bc24a5bbf9de5c60a585edfcdf91c79b60b811..85cfb89cc8168e3a8388c73756f11c3fc0916cfd 100644 (file)
@@ -21,14 +21,16 @@ sub machine_type_is_q35 {
 sub current_from_query_machines {
     my ($machines) = @_;
 
-    my ($current, $pve_version, $default);
+    my ($current, $default);
     for my $machine ($machines->@*) {
        $default = $machine->{name} if $machine->{'is-default'};
-       $current = $machine->{name} if $machine->{'is-current'};
-       $pve_version = $machine->{'pve-version'} if $machine->{'pve-version'};
-    }
 
-    $current .= "+$pve_version" if $current && $pve_version;
+       if ($machine->{'is-current'}) {
+           $current = $machine->{name};
+           # pve-version only exists for the current machine
+           $current .= "+$machine->{'pve-version'}" if $machine->{'pve-version'};
+       }
+    }
 
     # fallback to the default machine if current is not supported by qemu
     return $current || $default || 'pc';