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

Dietmar Maurer dietmar at proxmox.com
Mon Jun 12 11:18:50 CEST 2017


Why don't you use write_job_state() ?

> +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
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel




More information about the pve-devel mailing list