]> git.proxmox.com Git - qemu-server.git/commitdiff
machine: get current: add flag if current machine is deprecated in list context
authorFiona Ebner <f.ebner@proxmox.com>
Fri, 10 Nov 2023 13:24:49 +0000 (14:24 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sun, 12 Nov 2023 17:48:01 +0000 (18:48 +0100)
Will be used for a warning.

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

index c9fc9a3d66cbddc8df5c500fa08375259691264b..13721ae8a51779c96a4ad86e995f1c1b059baa76 100644 (file)
@@ -18,6 +18,7 @@ sub machine_type_is_q35 {
     return $conf->{machine} && ($conf->{machine} =~ m/q35/) ? 1 : 0;
 }
 
+# In list context, also returns whether the current machine is deprecated or not.
 sub current_from_query_machines {
     my ($machines) = @_;
 
@@ -29,15 +30,17 @@ sub current_from_query_machines {
            $current = $machine->{name};
            # pve-version only exists for the current machine
            $current .= "+$machine->{'pve-version'}" if $machine->{'pve-version'};
-           return $current;
+           return wantarray ? ($current, $machine->{deprecated} ? 1 : 0) : $current;
        }
     }
 
-    # fallback to the default machine if current is not supported by qemu
-    return $default || 'pc';
+    # fallback to the default machine if current is not supported by qemu - assume never deprecated
+    my $fallback = $default || 'pc';
+    return wantarray ? ($fallback, 0) : $fallback;
 }
 
-# this only works if VM is running
+# This only works if VM is running.
+# In list context, also returns whether the current machine is deprecated or not.
 sub get_current_qemu_machine {
     my ($vmid) = @_;