all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: David Riley <d.riley@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH qemu-server v2 10/10] fix #7294: helpers: use cluster-wide version helper
Date: Fri, 26 Jun 2026 15:10:35 +0200	[thread overview]
Message-ID: <20260626131035.112374-11-d.riley@proxmox.com> (raw)
In-Reply-To: <20260626131035.112374-1-d.riley@proxmox.com>

Drop the local `version_cmp` and `pvecfg_min_version` implementations
and update call sites to use the centralized tools module in
pve-common.

Link: https://bugzilla.proxmox.com/show_bug.cgi?id=7294
Signed-off-by: David Riley <d.riley@proxmox.com>
---
 src/PVE/QemuMigrate.pm        |  3 ++-
 src/PVE/QemuServer/Helpers.pm | 42 ++---------------------------------
 2 files changed, 4 insertions(+), 41 deletions(-)

diff --git a/src/PVE/QemuMigrate.pm b/src/PVE/QemuMigrate.pm
index 8da6f15d..65950a8f 100644
--- a/src/PVE/QemuMigrate.pm
+++ b/src/PVE/QemuMigrate.pm
@@ -23,6 +23,7 @@ use PVE::Storage::Plugin;
 use PVE::Storage;
 use PVE::StorageTunnel;
 use PVE::Tools;
+use PVE::Tools qw(pvecfg_min_version);
 use PVE::Tunnel;
 
 use PVE::QemuConfig;
@@ -1400,7 +1401,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::Tools::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..c0db925b 100644
--- a/src/PVE/QemuServer/Helpers.pm
+++ b/src/PVE/QemuServer/Helpers.pm
@@ -11,6 +11,7 @@ use PVE::Cluster;
 use PVE::INotify;
 use PVE::ProcFSTools;
 use PVE::Tools;
+use PVE::Tools qw(version_cmp);
 
 use base 'Exporter';
 our @EXPORT_OK = qw(
@@ -228,39 +229,13 @@ sub min_version {
     my ($verstr, $major, $minor, $pve) = @_;
 
     if ($verstr =~ m/^(\d+)\.(\d+)(?:\.(\d+))?(?:\+pve(\d+))?/) {
-        return 1 if version_cmp($1, $major, $2, $minor, $4, $pve) >= 0;
+        return 1 if PVE::Tools::version_cmp($1, $major, $2, $minor, $4, $pve) >= 0;
         return 0;
     }
 
     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





      parent reply	other threads:[~2026-06-26 13:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26 13:10 [PATCH access-control/cluster/common/manager/network/proxmox-widget-toolkit/qemu-server v2 00/10] fix #7294: pool: add SDN VNets as pool members David Riley
2026-06-26 13:10 ` [PATCH pve-manager v2 01/10] ui: replace var with let to match style guide for variable declaration David Riley
2026-06-26 13:10 ` [PATCH pve-manager v2 02/10] fix #7294: api: pool: add SDN VNets as pool members David Riley
2026-06-26 13:10 ` [PATCH pve-manager v2 03/10] fix #7294: ui: " David Riley
2026-06-26 13:10 ` [PATCH proxmox-widget-toolkit v2 04/10] fix #7294: css: theme: add opacity override for pool VNet icon David Riley
2026-06-26 13:10 ` [PATCH pve-access-control v2 05/10] fix #7294: acl: pool: add SDN VNets as pool members David Riley
2026-06-26 13:10 ` [PATCH pve-network v2 06/10] fix #7294: sdn: register api formats for zones and vnets David Riley
2026-06-26 13:10 ` [PATCH pve-network v2 07/10] fix #7294: sdn: vnet: update pool members on vnet migration and deletion David Riley
2026-06-26 13:10 ` [PATCH pve-common v2 08/10] tools: add helpers for version comparison David Riley
2026-06-26 13:10 ` [PATCH pve-cluster v2 09/10] fix #7294: cluster: helpers: add cluster-wide version assertion David Riley
2026-06-26 13:10 ` David Riley [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260626131035.112374-11-d.riley@proxmox.com \
    --to=d.riley@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal