[pve-devel] [pve-guest-common 2/2] set_remote_state

Wolfgang Link w.link at proxmox.com
Fri Jun 9 08:19:48 CEST 2017


---
 PVE/ReplicationState.pm | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/PVE/ReplicationState.pm b/PVE/ReplicationState.pm
index be5cf5f..086d62f 100644
--- a/PVE/ReplicationState.pm
+++ b/PVE/ReplicationState.pm
@@ -92,4 +92,23 @@ sub replication_snapshot_name {
     wantarray ? ($prefix, $snapname) : $snapname;
 }
 
+sub set_remote_state {
+    my ($state, $vmid) = @_;
+
+    my $update = sub {
+	my $stateobj = read_state();
+	$stateobj->{$vmid} = $state;
+	PVE::Tools::file_set_contents($state_path, encode_json($stateobj));
+    };
+
+    my $code = sub {
+	PVE::Tools::lock_file($state_lock, 10, $update);
+	die $@ if $@;
+    };
+
+    # make sure we have guest_migration_lock during update
+    PVE::GuestHelpers::guest_migration_lock($vmid, undef, $code);
+
+}
+
 1;
-- 
2.11.0





More information about the pve-devel mailing list