move 'windows_version' to Helpers

to avoid a cyclic dependency when we want to use that in PVE::QemuServer::USB

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2022-11-10 15:35:53 +01:00 committed by Thomas Lamprecht
parent 2b938c7d88
commit 238af88edc
4 changed files with 23 additions and 21 deletions

View File

@ -978,7 +978,7 @@ __PACKAGE__->register_method({
my $machine = $conf->{machine}; my $machine = $conf->{machine};
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::windows_version($conf->{ostype})) { if (PVE::QemuServer::Helpers::windows_version($conf->{ostype})) {
$conf->{machine} = PVE::QemuServer::windows_get_pinned_machine_version($machine); $conf->{machine} = PVE::QemuServer::windows_get_pinned_machine_version($machine);
} }
} }

View File

@ -46,7 +46,7 @@ use PVE::Tools qw(run_command file_read_firstline file_get_contents dir_glob_for
use PVE::QMPClient; use PVE::QMPClient;
use PVE::QemuConfig; use PVE::QemuConfig;
use PVE::QemuServer::Helpers qw(min_version config_aware_timeout); use PVE::QemuServer::Helpers qw(min_version config_aware_timeout windows_version);
use PVE::QemuServer::Cloudinit; use PVE::QemuServer::Cloudinit;
use PVE::QemuServer::CGroup; use PVE::QemuServer::CGroup;
use PVE::QemuServer::CPUConfig qw(print_cpu_device get_cpu_options); use PVE::QemuServer::CPUConfig qw(print_cpu_device get_cpu_options);
@ -7960,24 +7960,6 @@ sub scsihw_infos {
return ($maxdev, $controller, $controller_prefix); return ($maxdev, $controller, $controller_prefix);
} }
sub windows_version {
my ($ostype) = @_;
return 0 if !$ostype;
my $winversion = 0;
if($ostype eq 'wxp' || $ostype eq 'w2k3' || $ostype eq 'w2k') {
$winversion = 5;
} elsif($ostype eq 'w2k8' || $ostype eq 'wvista') {
$winversion = 6;
} elsif ($ostype =~ m/^win(\d+)$/) {
$winversion = $1;
}
return $winversion;
}
sub resolve_dst_disk_format { sub resolve_dst_disk_format {
my ($storecfg, $storeid, $src_volname, $format) = @_; my ($storecfg, $storeid, $src_volname, $format) = @_;
my ($defFormat, $validFormats) = PVE::Storage::storage_default_format($storecfg, $storeid); my ($defFormat, $validFormats) = PVE::Storage::storage_default_format($storecfg, $storeid);

View File

@ -12,6 +12,7 @@ use Storable qw(dclone);
use PVE::Tools qw(run_command file_set_contents); use PVE::Tools qw(run_command file_set_contents);
use PVE::Storage; use PVE::Storage;
use PVE::QemuServer; use PVE::QemuServer;
use PVE::QemuServer::Helpers;
use constant CLOUDINIT_DISK_SIZE => 4 * 1024 * 1024; # 4MiB in bytes use constant CLOUDINIT_DISK_SIZE => 4 * 1024 * 1024; # 4MiB in bytes
@ -71,7 +72,7 @@ sub get_cloudinit_format {
# the new predicatble network device naming scheme. # the new predicatble network device naming scheme.
if (defined(my $ostype = $conf->{ostype})) { if (defined(my $ostype = $conf->{ostype})) {
return 'configdrive2' return 'configdrive2'
if PVE::QemuServer::windows_version($ostype); if PVE::QemuServer::Helpers::windows_version($ostype);
} }
return 'nocloud'; return 'nocloud';

View File

@ -13,6 +13,7 @@ use base 'Exporter';
our @EXPORT_OK = qw( our @EXPORT_OK = qw(
min_version min_version
config_aware_timeout config_aware_timeout
windows_version
); );
my $nodename = PVE::INotify::nodename(); my $nodename = PVE::INotify::nodename();
@ -185,4 +186,22 @@ sub pvecfg_min_version {
die "internal error: cannot check version of invalid string '$verstr'"; die "internal error: cannot check version of invalid string '$verstr'";
} }
sub windows_version {
my ($ostype) = @_;
return 0 if !$ostype;
my $winversion = 0;
if($ostype eq 'wxp' || $ostype eq 'w2k3' || $ostype eq 'w2k') {
$winversion = 5;
} elsif($ostype eq 'w2k8' || $ostype eq 'wvista') {
$winversion = 6;
} elsif ($ostype =~ m/^win(\d+)$/) {
$winversion = $1;
}
return $winversion;
}
1; 1;