mirror of
https://git.proxmox.com/git/pve-guest-common
synced 2025-08-14 15:44:10 +00:00
PVE/ReplicationState.pm: implement write_vmid_job_states
Update all job states related to a specific $vmid
This commit is contained in:
parent
683a30e062
commit
55222f3747
@ -68,6 +68,7 @@ sub read_job_state {
|
|||||||
return extract_job_state($stateobj, $jobcfg);
|
return extract_job_state($stateobj, $jobcfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# update state for a single job
|
||||||
sub write_job_state {
|
sub write_job_state {
|
||||||
my ($jobcfg, $state) = @_;
|
my ($jobcfg, $state) = @_;
|
||||||
|
|
||||||
@ -94,6 +95,25 @@ sub write_job_state {
|
|||||||
PVE::GuestHelpers::guest_migration_lock($vmid, undef, $code);
|
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 {
|
sub replication_snapshot_name {
|
||||||
my ($jobid, $last_sync) = @_;
|
my ($jobid, $last_sync) = @_;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user