]> git.proxmox.com Git - qemu-server.git/commitdiff
Change target in replication-state when replication direction is switched
authorDietmar Maurer <dietmar@proxmox.com>
Wed, 21 Jun 2017 08:59:45 +0000 (10:59 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 21 Jun 2017 08:59:45 +0000 (10:59 +0200)
PVE/QemuMigrate.pm

index 8e541bf04b820a4dbe2c063cc60d210fe692e9e1..0f330a89a6365186248e901ad393f65990635f8c 100644 (file)
@@ -858,9 +858,17 @@ my $transfer_replication_state = sub {
 
     my $stateobj = PVE::ReplicationState::read_state();
 
-    if (defined($stateobj->{$vmid})) {
+    my $target_node = $self->{node};
+    my $local_node = PVE::INotify::nodename();
+
+    my $oldid = PVE::ReplicationConfig::Cluster->get_unique_target_id({ target => $target_node });
+    my $newid = PVE::ReplicationConfig::Cluster->get_unique_target_id({ target => $local_node });
+
+    if (defined(my $vmstate = $stateobj->{$vmid})) {
+       $vmstate->{$newid} = delete($vmstate->{$oldid}) if defined($vmstate->{$oldid});
+
        # 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($vmstate));
 
        my $cmd = [ @{$self->{rem_ssh}}, 'pvesr', 'set-state', $vmid, $state];
        $self->cmd($cmd);