[pve-devel] [PATCH v3 pve-manager 20/23] PVE::Replication - aquire guest_migration_lock during replication

Dietmar Maurer dietmar at proxmox.com
Tue May 30 15:20:17 CEST 2017


To block guest migration.

Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
 PVE/Replication.pm | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/PVE/Replication.pm b/PVE/Replication.pm
index 3d47d1ed..711b08ff 100644
--- a/PVE/Replication.pm
+++ b/PVE/Replication.pm
@@ -11,11 +11,13 @@ use PVE::ProcFSTools;
 use PVE::Tools;
 use PVE::CalendarEvent;
 use PVE::Cluster;
+use PVE::AbstractConfig;
 use PVE::QemuConfig;
 use PVE::QemuServer;
 use PVE::LXC::Config;
 use PVE::LXC;
 use PVE::Storage;
+use PVE::GuestHelpers;
 use PVE::ReplicationConfig;
 
 # Note: regression tests can overwrite $state_path for testing
@@ -388,7 +390,12 @@ my $run_replication = sub {
 
     $logfunc->($start_time, "$jobcfg->{id}: start replication job") if $logfunc;
 
-    eval { replicate($jobcfg, $state->{last_sync}, $start_time, $logfunc); };
+    eval {
+	my $timeout = 2; # do not wait too long - we repeat periodically anyways
+	PVE::GuestHelpers::guest_migration_lock(
+	    $jobcfg->{guest}, $timeout, \&replicate,
+	    $jobcfg, $state->{last_sync}, $start_time, $logfunc);
+    };
     my $err = $@;
 
     $state->{duration} = tv_interval($t0);
-- 
2.11.0




More information about the pve-devel mailing list