mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-07-03 07:09:08 +00:00
move windows_get_pinned_machine_version() function to machine module
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
parent
85d47ae2fe
commit
5c8407b0dc
@ -1246,7 +1246,8 @@ __PACKAGE__->register_method({
|
|||||||
if (!$machine || $machine =~ m/^(?:pc|q35|virt)$/) {
|
if (!$machine || $machine =~ m/^(?:pc|q35|virt)$/) {
|
||||||
# always pin Windows' machine version on create, they get to easily confused
|
# always pin Windows' machine version on create, they get to easily confused
|
||||||
if (PVE::QemuServer::Helpers::windows_version($conf->{ostype})) {
|
if (PVE::QemuServer::Helpers::windows_version($conf->{ostype})) {
|
||||||
$machine_conf->{type} = PVE::QemuServer::windows_get_pinned_machine_version($machine);
|
$machine_conf->{type} =
|
||||||
|
PVE::QemuServer::Machine::windows_get_pinned_machine_version($machine);
|
||||||
$conf->{machine} = PVE::QemuServer::Machine::print_machine($machine_conf);
|
$conf->{machine} = PVE::QemuServer::Machine::print_machine($machine_conf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3271,28 +3271,6 @@ sub vga_conf_has_spice {
|
|||||||
return $1 || 1;
|
return $1 || 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub windows_get_pinned_machine_version {
|
|
||||||
my ($machine, $base_version, $kvmversion) = @_;
|
|
||||||
|
|
||||||
my $pin_version = $base_version;
|
|
||||||
if (!defined($base_version) ||
|
|
||||||
!PVE::QemuServer::Machine::can_run_pve_machine_version($base_version, $kvmversion)
|
|
||||||
) {
|
|
||||||
$pin_version = PVE::QemuServer::Machine::get_installed_machine_version($kvmversion);
|
|
||||||
}
|
|
||||||
if (!$machine || $machine eq 'pc') {
|
|
||||||
$machine = "pc-i440fx-$pin_version";
|
|
||||||
} elsif ($machine eq 'q35') {
|
|
||||||
$machine = "pc-q35-$pin_version";
|
|
||||||
} elsif ($machine eq 'virt') {
|
|
||||||
$machine = "virt-$pin_version";
|
|
||||||
} else {
|
|
||||||
warn "unknown machine type '$machine', not touching that!\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
return $machine;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub get_vm_machine {
|
sub get_vm_machine {
|
||||||
my ($conf, $forcemachine, $arch) = @_;
|
my ($conf, $forcemachine, $arch) = @_;
|
||||||
|
|
||||||
@ -3305,7 +3283,7 @@ sub get_vm_machine {
|
|||||||
# layout which confuses windows quite a bit and may result in various regressions..
|
# layout which confuses windows quite a bit and may result in various regressions..
|
||||||
# see: https://lists.gnu.org/archive/html/qemu-devel/2021-02/msg08484.html
|
# see: https://lists.gnu.org/archive/html/qemu-devel/2021-02/msg08484.html
|
||||||
if (windows_version($conf->{ostype})) {
|
if (windows_version($conf->{ostype})) {
|
||||||
$machine = windows_get_pinned_machine_version($machine, '5.1', $kvmversion);
|
$machine = PVE::QemuServer::Machine::windows_get_pinned_machine_version($machine, '5.1', $kvmversion);
|
||||||
}
|
}
|
||||||
$arch //= 'x86_64';
|
$arch //= 'x86_64';
|
||||||
$machine ||= PVE::QemuServer::Machine::default_machine_for_arch($arch);
|
$machine ||= PVE::QemuServer::Machine::default_machine_for_arch($arch);
|
||||||
|
@ -193,4 +193,24 @@ sub get_installed_machine_version {
|
|||||||
return $1;
|
return $1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub windows_get_pinned_machine_version {
|
||||||
|
my ($machine, $base_version, $kvmversion) = @_;
|
||||||
|
|
||||||
|
my $pin_version = $base_version;
|
||||||
|
if (!defined($base_version) || !can_run_pve_machine_version($base_version, $kvmversion)) {
|
||||||
|
$pin_version = get_installed_machine_version($kvmversion);
|
||||||
|
}
|
||||||
|
if (!$machine || $machine eq 'pc') {
|
||||||
|
$machine = "pc-i440fx-$pin_version";
|
||||||
|
} elsif ($machine eq 'q35') {
|
||||||
|
$machine = "pc-q35-$pin_version";
|
||||||
|
} elsif ($machine eq 'virt') {
|
||||||
|
$machine = "virt-$pin_version";
|
||||||
|
} else {
|
||||||
|
warn "unknown machine type '$machine', not touching that!\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $machine;
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
Reference in New Issue
Block a user