Signed-off-by: Fabian Ebner <[email protected]>
---

New in v3.

 src/PVE/GuestHelpers.pm | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/PVE/GuestHelpers.pm b/src/PVE/GuestHelpers.pm
index 970c460..1183819 100644
--- a/src/PVE/GuestHelpers.pm
+++ b/src/PVE/GuestHelpers.pm
@@ -3,8 +3,9 @@ package PVE::GuestHelpers;
 use strict;
 use warnings;
 
-use PVE::Tools;
+use PVE::ReplicationConfig;
 use PVE::Storage;
+use PVE::Tools;
 
 use POSIX qw(strftime);
 use Scalar::Util qw(weaken);
@@ -82,6 +83,18 @@ sub guest_migration_lock {
     return $res;
 }
 
+sub run_with_replication_guard {
+    my ($vmid, $timeout, $log, $func, @param) = @_;
+
+    my $repl_conf = PVE::ReplicationConfig->new();
+    if ($repl_conf->check_for_existing_jobs($vmid, 1)) {
+       $log->("checking/waiting for active replication..") if $log;
+       guest_migration_lock($vmid, $timeout, $func, @param);
+    } else {
+       $func->(@param);
+    }
+}
+
 sub check_hookscript {
     my ($volid, $storecfg) = @_;
 
-- 
2.30.2



_______________________________________________
pve-devel mailing list
[email protected]
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to