From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 207D51FF13C for ; Thu, 11 Jun 2026 17:00:36 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D6C58FB95; Thu, 11 Jun 2026 17:00:12 +0200 (CEST) From: David Riley To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server 9/9] fix #7294: helpers: use cluster-wide version helper Date: Thu, 11 Jun 2026 16:59:35 +0200 Message-ID: <20260611145935.147788-10-d.riley@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260611145935.147788-1-d.riley@proxmox.com> References: <20260611145935.147788-1-d.riley@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1781189946451 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.172 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [helpers.pm,qemumigrate.pm,proxmox.com] Message-ID-Hash: LPUWZMIOIBWSDUUQNSYG3NGMJN7FV555 X-Message-ID-Hash: LPUWZMIOIBWSDUUQNSYG3NGMJN7FV555 X-MailFrom: d.riley@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Drop the local `version_cmp` and `pvecfg_min_version` implementations and update call sites to use the centralized helpers module in pve-cluster. Link: https://bugzilla.proxmox.com/show_bug.cgi?id=7294 Signed-off-by: David Riley --- src/PVE/QemuMigrate.pm | 2 +- src/PVE/QemuServer/Helpers.pm | 40 +---------------------------------- 2 files changed, 2 insertions(+), 40 deletions(-) diff --git a/src/PVE/QemuMigrate.pm b/src/PVE/QemuMigrate.pm index d4de9f87..331d263b 100644 --- a/src/PVE/QemuMigrate.pm +++ b/src/PVE/QemuMigrate.pm @@ -1394,7 +1394,7 @@ sub phase2 { # Check if target is new enough for having the port encoded in the proxy ticket. if ( $target_version - && PVE::QemuServer::Helpers::pvecfg_min_version($target_version, 9, 1, 9) + && PVE::Cluster::Helpers::pvecfg_min_version($target_version, 9, 1, 9) ) { $ticket_port = $spice_port; } diff --git a/src/PVE/QemuServer/Helpers.pm b/src/PVE/QemuServer/Helpers.pm index dd17eef5..b0d72ab4 100644 --- a/src/PVE/QemuServer/Helpers.pm +++ b/src/PVE/QemuServer/Helpers.pm @@ -8,6 +8,7 @@ use IO::File; use JSON; use PVE::Cluster; +use PVE::Cluster::Helpers qw(version_cmp); use PVE::INotify; use PVE::ProcFSTools; use PVE::Tools; @@ -235,32 +236,6 @@ sub min_version { die "internal error: cannot check version of invalid string '$verstr'"; } -# gets in pairs the versions you want to compares, i.e.: -# ($a-major, $b-major, $a-minor, $b-minor, $a-extra, $b-extra, ...) -# returns 0 if same, -1 if $a is older than $b, +1 if $a is newer than $b -sub version_cmp { - my @versions = @_; - - my $size = scalar(@versions); - - return 0 if $size == 0; - - if ($size & 1) { - my (undef, $fn, $line) = caller(0); - die "cannot compare odd count of versions, called from $fn:$line\n"; - } - - for (my $i = 0; $i < $size; $i += 2) { - my ($left, $right) = splice(@versions, 0, 2); - $left //= 0; - $right //= 0; - - return 1 if $left > $right; - return -1 if $left < $right; - } - return 0; -} - sub config_aware_timeout { my ($config, $memory, $is_suspended) = @_; my $timeout = 30; @@ -307,19 +282,6 @@ sub get_node_pvecfg_version { return $version_info->{version}; } -sub pvecfg_min_version { - my ($verstr, $major, $minor, $release) = @_; - - return 0 if !$verstr; - - if ($verstr =~ m/^(\d+)\.(\d+)(?:[.-](\d+))?/) { - return 1 if version_cmp($1, $major, $2, $minor, $3 // 0, $release) >= 0; - return 0; - } - - die "internal error: cannot check version of invalid string '$verstr'"; -} - sub parse_number_sets { my ($set) = @_; my $res = []; -- 2.47.3