[pve-devel] [Patch V5 guest-common 6/7] Swap source and target in replication config, if VM was stolen.

Wolfgang Link w.link at proxmox.com
Wed May 9 14:48:26 CEST 2018


---
 PVE/ReplicationState.pm | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/PVE/ReplicationState.pm b/PVE/ReplicationState.pm
index 0851195..2851b62 100644
--- a/PVE/ReplicationState.pm
+++ b/PVE/ReplicationState.pm
@@ -254,8 +254,17 @@ sub job_status {
 
 	my $target = $jobcfg->{target};
 	if (!$jobcfg->{remove_job}) {
-	    # never sync to local node
-	    next if $target eq $local_node;
+	    # check if vm was stolen (swapped source target)
+	    if ($target eq $local_node) {
+		my $source = $jobcfg->{source};
+		if (defined($source) && $source ne $target) {
+		    $jobcfg = PVE::ReplicationConfig::swap_source_target_nolock($jobid);
+		    $cfg->{ids}->{$jobid} = $jobcfg;
+		} else {
+		    # never sync to local node
+		    next;
+		}
+	    }
 
 	    next if !$get_disabled && $jobcfg->{disable};
 	}
-- 
2.11.0





More information about the pve-devel mailing list