[pve-devel] [PATCH pve-guest-common 2/2] PVE::ReplicationState - hold guest_migration_lock during state update
Dietmar Maurer
dietmar at proxmox.com
Fri Jun 2 10:20:24 CEST 2017
Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
PVE/ReplicationState.pm | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/PVE/ReplicationState.pm b/PVE/ReplicationState.pm
index cd7dc69..d0eaf80 100644
--- a/PVE/ReplicationState.pm
+++ b/PVE/ReplicationState.pm
@@ -5,9 +5,9 @@ use strict;
use JSON;
use PVE::Tools;
+use PVE::GuestHelpers;
use PVE::ReplicationConfig;
-
# Note: regression tests can overwrite $state_path for testing
our $state_path = "/var/lib/pve-manager/pve-replication-state.json";
our $state_lock = "/var/lib/pve-manager/pve-replication-state.lck";
@@ -65,7 +65,7 @@ sub write_job_state {
my $vmid = $jobcfg->{guest};
my $tid = $plugin->get_unique_target_id($jobcfg);
- my $code = sub {
+ my $update = sub {
my $stateobj = read_state();
# Note: tuple ($vmid, $tid) is unique
@@ -74,8 +74,13 @@ sub write_job_state {
PVE::Tools::file_set_contents($state_path, encode_json($stateobj));
};
- PVE::Tools::lock_file($state_lock, 10, $code);
- die $@ if $@;
+ 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