5
0
mirror of git://git.proxmox.com/git/pve-guest-common.git synced 2024-12-24 21:34:13 +03:00

PVE/ReplicationState.pm: implement write_vmid_job_states

Update all job states related to a specific $vmid
This commit is contained in:
Dietmar Maurer 2017-06-12 11:33:05 +02:00
parent 683a30e062
commit 55222f3747

View File

@ -68,6 +68,7 @@ sub read_job_state {
return extract_job_state($stateobj, $jobcfg);
}
# update state for a single job
sub write_job_state {
my ($jobcfg, $state) = @_;
@ -94,6 +95,25 @@ sub write_job_state {
PVE::GuestHelpers::guest_migration_lock($vmid, undef, $code);
}
# update all job states related to a specific $vmid
sub write_vmid_job_states {
my ($vmid_state, $vmid) = @_;
my $update = sub {
my $stateobj = read_state();
$stateobj->{$vmid} = $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);
}
sub replication_snapshot_name {
my ($jobid, $last_sync) = @_;