From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id D48A51FF17C for ; Wed, 9 Jul 2025 18:23:20 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E9FC1114A2; Wed, 9 Jul 2025 18:22:52 +0200 (CEST) To: pve-devel@lists.proxmox.com Date: Wed, 9 Jul 2025 18:21:57 +0200 In-Reply-To: <20250709162202.2952597-1-alexandre.derumier@groupe-cyllene.com> References: <20250709162202.2952597-1-alexandre.derumier@groupe-cyllene.com> MIME-Version: 1.0 Message-ID: List-Id: Proxmox VE development discussion List-Post: From: Alexandre Derumier via pve-devel Precedence: list Cc: Alexandre Derumier X-Mailman-Version: 2.1.29 X-BeenThere: pve-devel@lists.proxmox.com List-Subscribe: , List-Unsubscribe: , List-Archive: Reply-To: Proxmox VE development discussion List-Help: Subject: [pve-devel] [PATCH pve-storage 08/13] storage: add rename_snapshot method Content-Type: multipart/mixed; boundary="===============4771587406437704136==" Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" --===============4771587406437704136== Content-Type: message/rfc822 Content-Disposition: inline Return-Path: X-Original-To: pve-devel@lists.proxmox.com Delivered-To: pve-devel@lists.proxmox.com 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 B9F7DD7B3E for ; Wed, 9 Jul 2025 18:22:51 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 032FF10D20 for ; Wed, 9 Jul 2025 18:22:19 +0200 (CEST) Received: from bastiontest.odiso.net (unknown [IPv6:2a0a:1580:2000:6700::14]) (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 ; Wed, 9 Jul 2025 18:22:14 +0200 (CEST) Received: from formationkvm1.odiso.net (unknown [10.11.201.57]) by bastiontest.odiso.net (Postfix) with ESMTP id 0FF10862E56; Wed, 9 Jul 2025 18:22:05 +0200 (CEST) Received: by formationkvm1.odiso.net (Postfix, from userid 0) id 0D6DD10CBC9B; Wed, 9 Jul 2025 18:22:05 +0200 (CEST) From: Alexandre Derumier To: pve-devel@lists.proxmox.com Subject: [PATCH pve-storage 08/13] storage: add rename_snapshot method Date: Wed, 9 Jul 2025 18:21:57 +0200 Message-Id: <20250709162202.2952597-13-alexandre.derumier@groupe-cyllene.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250709162202.2952597-1-alexandre.derumier@groupe-cyllene.com> References: <20250709162202.2952597-1-alexandre.derumier@groupe-cyllene.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.089 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_NONE 0.1 DMARC none policy HEADER_FROM_DIFFERENT_DOMAINS 0.039 From and EnvelopeFrom 2nd level mail domains are different KAM_DMARC_NONE 0.25 DKIM has Failed or SPF has failed on the message and the domain has no DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Signed-off-by: Alexandre Derumier --- ApiChangeLog | 3 +++ src/PVE/Storage.pm | 25 +++++++++++++++++++++++++ src/PVE/Storage/BTRFSPlugin.pm | 6 ++++++ src/PVE/Storage/ESXiPlugin.pm | 6 ++++++ src/PVE/Storage/LVMPlugin.pm | 6 ++++++ src/PVE/Storage/LvmThinPlugin.pm | 6 ++++++ src/PVE/Storage/Plugin.pm | 16 ++++++++++++++++ src/PVE/Storage/RBDPlugin.pm | 6 ++++++ src/PVE/Storage/ZFSPoolPlugin.pm | 6 ++++++ 9 files changed, 80 insertions(+) diff --git a/ApiChangeLog b/ApiChangeLog index 2a01e3f..12eef1f 100644 --- a/ApiChangeLog +++ b/ApiChangeLog @@ -26,6 +26,9 @@ Future changes should be documented in here. The parameter *can* be used if some extra actions need to be done at the storage layer when the snapshot has already be done at qemu level when the vm is running. +* Introduce rename_snapshot() plugin method + This method allow to rename a vm disk snapshot name to a different snapshot name. + ## Version 11: * Allow declaring storage features via plugin data diff --git a/src/PVE/Storage.pm b/src/PVE/Storage.pm index 7f2da80..e0b79fa 100755 --- a/src/PVE/Storage.pm +++ b/src/PVE/Storage.pm @@ -2345,6 +2345,31 @@ sub rename_volume { ); } +sub rename_snapshot { + my ($cfg, $volid, $source_snap, $target_snap) = @_; + + die "no volid provided\n" if !$volid; + die "no source or target snap provided\n" if !$source_snap && !$target_snap; + + my ($storeid, $volname) = parse_volume_id($volid); + + activate_storage($cfg, $storeid); + + my $scfg = storage_config($cfg, $storeid); + my $plugin = PVE::Storage::Plugin->lookup($scfg->{type}); + + return $plugin->cluster_lock_storage( + $storeid, + $scfg->{shared}, + undef, + sub { + return $plugin->rename_snapshot( + $scfg, $storeid, $volname, $source_snap, $target_snap, + ); + }, + ); +} + # Various io-heavy operations require io/bandwidth limits which can be # configured on multiple levels: The global defaults in datacenter.cfg, and # per-storage overrides. When we want to do a restore from storage A to storage diff --git a/src/PVE/Storage/BTRFSPlugin.pm b/src/PVE/Storage/BTRFSPlugin.pm index 8c79ea4..26eef2b 100644 --- a/src/PVE/Storage/BTRFSPlugin.pm +++ b/src/PVE/Storage/BTRFSPlugin.pm @@ -995,6 +995,12 @@ sub rename_volume { return "${storeid}:$target_volname"; } +sub rename_snapshot { + my ($class, $scfg, $storeid, $volname, $source_snap, $target_snap) = @_; + + die "rename_snapshot is not supported for $class"; +} + sub get_import_metadata { return PVE::Storage::DirPlugin::get_import_metadata(@_); } diff --git a/src/PVE/Storage/ESXiPlugin.pm b/src/PVE/Storage/ESXiPlugin.pm index e655d7b..66ef289 100644 --- a/src/PVE/Storage/ESXiPlugin.pm +++ b/src/PVE/Storage/ESXiPlugin.pm @@ -497,6 +497,12 @@ sub rename_volume { die "renaming volumes is not supported for $class\n"; } +sub rename_snapshot { + my ($class, $scfg, $storeid, $volname, $source_snap, $target_snap) = @_; + + die "rename_snapshot is not supported for $class"; +} + sub volume_export_formats { my ($class, $scfg, $storeid, $volname, $snapshot, $base_snapshot, $with_snapshots) = @_; diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm index 72eb0cd..2441e59 100644 --- a/src/PVE/Storage/LVMPlugin.pm +++ b/src/PVE/Storage/LVMPlugin.pm @@ -855,4 +855,10 @@ sub rename_volume { return "${storeid}:${target_volname}"; } +sub rename_snapshot { + my ($class, $scfg, $storeid, $volname, $source_snap, $target_snap) = @_; + + die "rename_snapshot is not implemented for $class"; +} + 1; diff --git a/src/PVE/Storage/LvmThinPlugin.pm b/src/PVE/Storage/LvmThinPlugin.pm index e5df0b4..6bc76c9 100644 --- a/src/PVE/Storage/LvmThinPlugin.pm +++ b/src/PVE/Storage/LvmThinPlugin.pm @@ -468,4 +468,10 @@ sub volume_import_write { ); } +sub rename_snapshot { + my ($class, $scfg, $storeid, $volname, $source_snap, $target_snap) = @_; + + die "rename_snapshot is not supported for $class"; +} + 1; diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm index da26c0c..6b2dc32 100644 --- a/src/PVE/Storage/Plugin.pm +++ b/src/PVE/Storage/Plugin.pm @@ -2046,6 +2046,22 @@ sub rename_volume { return "${storeid}:${base}${target_vmid}/${target_volname}"; } +=pod + +=head3 rename_snapshot + + $plugin->rename_snapshot($scfg, $storeid, $volname, $source_snap, $target_snap) + +Rename a volume source snapshot C<$source_snap> to a target snapshot C<$target_snap>. + +=cut + +sub rename_snapshot { + my ($class, $scfg, $storeid, $volname, $source_snap, $target_snap) = @_; + + die "rename_snapshot is not implemented for $class"; +} + my sub blockdev_options_nbd_tcp { my ($host, $port, $export) = @_; diff --git a/src/PVE/Storage/RBDPlugin.pm b/src/PVE/Storage/RBDPlugin.pm index 38d61e9..ee33006 100644 --- a/src/PVE/Storage/RBDPlugin.pm +++ b/src/PVE/Storage/RBDPlugin.pm @@ -1055,4 +1055,10 @@ sub rename_volume { return "${storeid}:${base_name}${target_volname}"; } +sub rename_snapshot { + my ($class, $scfg, $storeid, $volname, $source_snap, $target_snap) = @_; + + die "rename_snapshot is not implemented for $class"; +} + 1; diff --git a/src/PVE/Storage/ZFSPoolPlugin.pm b/src/PVE/Storage/ZFSPoolPlugin.pm index 9cdfa68..28d4795 100644 --- a/src/PVE/Storage/ZFSPoolPlugin.pm +++ b/src/PVE/Storage/ZFSPoolPlugin.pm @@ -895,4 +895,10 @@ sub rename_volume { return "${storeid}:${base_name}${target_volname}"; } +sub rename_snapshot { + my ($class, $scfg, $storeid, $volname, $source_snap, $target_snap) = @_; + + die "rename_snapshot is not supported for $class"; +} + 1; -- 2.39.5 --===============4771587406437704136== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel --===============4771587406437704136==--