[pve-devel] [PATCH qemu-server 3/6] machine: get current: return early from loop if possible

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


No point iterating through the rest if we already got the current
machine.

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

diff --git a/PVE/QemuServer/Machine.pm b/PVE/QemuServer/Machine.pm
index 85cfb89c..c9fc9a3d 100644
--- a/PVE/QemuServer/Machine.pm
+++ b/PVE/QemuServer/Machine.pm
@@ -29,11 +29,12 @@ 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;
 	}
     }
 
     # fallback to the default machine if current is not supported by qemu
-    return $current || $default || 'pc';
+    return $default || 'pc';
 }
 
 # this only works if VM is running
-- 
2.39.2






More information about the pve-devel mailing list