From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 72D1B8E044 for ; Thu, 10 Nov 2022 15:36:13 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2D5C72844B for ; Thu, 10 Nov 2022 15:36:12 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 10 Nov 2022 15:36:07 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 43FCA444AF for ; Thu, 10 Nov 2022 15:36:01 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Thu, 10 Nov 2022 15:35:53 +0100 Message-Id: <20221110143600.258897-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221110143600.258897-1-d.csapak@proxmox.com> References: <20221110143600.258897-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.065 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH qemu-server 2/7] move 'windows_version' to Helpers X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Nov 2022 14:36:13 -0000 to avoid a cyclic dependency when we want to use that in PVE::QemuServer::USB Signed-off-by: Dominik Csapak --- PVE/API2/Qemu.pm | 2 +- PVE/QemuServer.pm | 20 +------------------- PVE/QemuServer/Cloudinit.pm | 3 ++- PVE/QemuServer/Helpers.pm | 19 +++++++++++++++++++ 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index a539b5c..30348e6 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -978,7 +978,7 @@ __PACKAGE__->register_method({ my $machine = $conf->{machine}; if (!$machine || $machine =~ m/^(?:pc|q35|virt)$/) { # 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); } } diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 642c302..06ffead 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -46,7 +46,7 @@ use PVE::Tools qw(run_command file_read_firstline file_get_contents dir_glob_for use PVE::QMPClient; 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::CGroup; use PVE::QemuServer::CPUConfig qw(print_cpu_device get_cpu_options); @@ -7955,24 +7955,6 @@ sub scsihw_infos { 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 { my ($storecfg, $storeid, $src_volname, $format) = @_; my ($defFormat, $validFormats) = PVE::Storage::storage_default_format($storecfg, $storeid); diff --git a/PVE/QemuServer/Cloudinit.pm b/PVE/QemuServer/Cloudinit.pm index 3e93692..b616c7b 100644 --- a/PVE/QemuServer/Cloudinit.pm +++ b/PVE/QemuServer/Cloudinit.pm @@ -12,6 +12,7 @@ use Storable qw(dclone); use PVE::Tools qw(run_command file_set_contents); use PVE::Storage; use PVE::QemuServer; +use PVE::QemuServer::Helpers; 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. if (defined(my $ostype = $conf->{ostype})) { return 'configdrive2' - if PVE::QemuServer::windows_version($ostype); + if PVE::QemuServer::Helpers::windows_version($ostype); } return 'nocloud'; diff --git a/PVE/QemuServer/Helpers.pm b/PVE/QemuServer/Helpers.pm index a2ba20a..e91f906 100644 --- a/PVE/QemuServer/Helpers.pm +++ b/PVE/QemuServer/Helpers.pm @@ -13,6 +13,7 @@ use base 'Exporter'; our @EXPORT_OK = qw( min_version config_aware_timeout +windows_version ); my $nodename = PVE::INotify::nodename(); @@ -185,4 +186,22 @@ sub pvecfg_min_version { 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; -- 2.30.2