[pve-devel] [PATCH guest-common 2/4] replication: prepare: return additional information about snapshots

Fabian Ebner f.ebner at proxmox.com
Tue Oct 19 09:54:54 CEST 2021


This is backwards compatible, because existing users of prepare() only
rely on the elements to evaluate to true or be defined.

Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---

Depends on pve-storage for the new volume_snapshot_info function.

Build-breaks old pve-manager, because the test there assumes
volume_snapshot_list is used.

 src/PVE/Replication.pm | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/PVE/Replication.pm b/src/PVE/Replication.pm
index 32395ed..4d4f62f 100644
--- a/src/PVE/Replication.pm
+++ b/src/PVE/Replication.pm
@@ -181,11 +181,11 @@ sub prepare {
     my $last_snapshots = {};
     my $cleaned_replicated_volumes = {};
     foreach my $volid (@$volids) {
-	my $list = PVE::Storage::volume_snapshot_list($storecfg, $volid);
-	foreach my $snap (@$list) {
+	my $info = PVE::Storage::volume_snapshot_info($storecfg, $volid);
+	for my $snap (keys $info->%*) {
 	    if ((defined($snapname) && ($snap eq $snapname)) ||
 		(defined($parent_snapname) && ($snap eq $parent_snapname))) {
-		$last_snapshots->{$volid}->{$snap} = 1;
+		$last_snapshots->{$volid}->{$snap} = $info->{$snap};
 	    } elsif ($snap =~ m/^\Q$prefix\E/) {
 		if ($last_sync != 0) {
 		    $logfunc->("delete stale replication snapshot '$snap' on $volid");
@@ -206,11 +206,11 @@ sub prepare {
 		    }		
 		# Last_sync=0 and a replication snapshot only occur, if the VM was stolen
 		} else {
-		    $last_snapshots->{$volid}->{$snap} = 1;
+		    $last_snapshots->{$volid}->{$snap} = $info->{$snap};
 		}
 	    # Other snapshots might need to serve as replication base after rollback
 	    } else {
-		$last_snapshots->{$volid}->{$snap} = 1;
+		$last_snapshots->{$volid}->{$snap} = $info->{$snap};
 	    }
 	}
     }
-- 
2.30.2






More information about the pve-devel mailing list