so that it can be used within job_status Signed-off-by: Fabian Ebner <f.eb...@proxmox.com> ---
Changes from v1: * this was part of the following patch PVE/ReplicationConfig.pm | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/PVE/ReplicationConfig.pm b/PVE/ReplicationConfig.pm index 9dfb9da..6ba87ae 100644 --- a/PVE/ReplicationConfig.pm +++ b/PVE/ReplicationConfig.pm @@ -230,21 +230,26 @@ sub find_local_replication_job { # makes old_target the new source for all local jobs of this guest # makes new_target the target for the single local job with target old_target +sub switch_replication_job_target_nolock { + my ($cfg, $vmid, $old_target, $new_target) = @_; + + foreach my $jobcfg (values %{$cfg->{ids}}) { + next if $jobcfg->{guest} ne $vmid; + next if $jobcfg->{type} ne 'local'; + + $jobcfg->{target} = $new_target if $jobcfg->{target} eq $old_target; + $jobcfg->{source} = $old_target; + } + $cfg->write(); +} + sub switch_replication_job_target { my ($vmid, $old_target, $new_target) = @_; my $update_jobs = sub { my $cfg = PVE::ReplicationConfig->new(); - foreach my $jobcfg (values %{$cfg->{ids}}) { - next if $jobcfg->{guest} ne $vmid; - next if $jobcfg->{type} ne 'local'; - - $jobcfg->{target} = $new_target if $jobcfg->{target} eq $old_target; - $jobcfg->{source} = $old_target; - } - $cfg->write(); + $cfg->switch_replication_job_target_nolock($vmid, $old_target, $new_target); }; - lock($update_jobs); } -- 2.20.1 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel