[pve-devel] [PATCH qemu-server] Change target in replication-state when replication direction is switched.

Wolfgang Link w.link at proxmox.com
Wed Jun 21 08:35:47 CEST 2017


This is necessary to avoid a full sync which will fail because the disk already exists.
---
 PVE/QemuMigrate.pm | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index 8e541bf..0c931c5 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -859,8 +859,21 @@ my $transfer_replication_state = sub {
     my $stateobj = PVE::ReplicationState::read_state();
 
     if (defined($stateobj->{$vmid})) {
+
+	my $tmp_state = {};
+
+	my $mig_node = $self->{node};
+	my $new_target = PVE::INotify::nodename();
+	foreach my $key (keys %{$stateobj->{$vmid}}) {
+	    if ($key =~ /^(.*\/)\Q$mig_node\E$/) {
+		$tmp_state->{"$1$new_target"} = $stateobj->{$vmid}->{$key};
+	    } else {
+		$tmp_state->{$key} = $stateobj->{$vmid}->{$key};
+	    }
+	}
+
 	# This have to be quoted when it run it over ssh.
-	my $state = PVE::Tools::shellquote(encode_json($stateobj->{$vmid}));
+	my $state = PVE::Tools::shellquote(encode_json($tmp_state));
 
 	my $cmd = [ @{$self->{rem_ssh}}, 'pvesr', 'set-state', $vmid, $state];
 	$self->cmd($cmd);
-- 
2.11.0





More information about the pve-devel mailing list