[pve-devel] [PATCH qemu-server 4/6] machine: get current: add flag if current machine is deprecated in list context

Fiona Ebner f.ebner at proxmox.com
Fri Nov 10 14:24:49 CET 2023


Will be used for a warning.

Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---
 PVE/QemuServer/Machine.pm | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/PVE/QemuServer/Machine.pm b/PVE/QemuServer/Machine.pm
index c9fc9a3d..13721ae8 100644
--- a/PVE/QemuServer/Machine.pm
+++ b/PVE/QemuServer/Machine.pm
@@ -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) = @_;
 
-- 
2.39.2






More information about the pve-devel mailing list