machine: get current: add flag if current machine is deprecated in list context

Will be used for a warning.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fiona Ebner 2023-11-10 14:24:49 +01:00 committed by Thomas Lamprecht
parent be690b7a91
commit da84155405

View 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) = @_;