[pve-devel] [PATCH 15/19] phase3_cleanup : clear migration lock on source vm

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Mar 9 17:10:36 CET 2017


On 02/22/2017 02:33 PM, Alexandre Derumier wrote:
> Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
> ---
>   PVE/QemuMigrate.pm | 6 ++++++
>   1 file changed, 6 insertions(+)
>
> diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
> index 35b752e..6c238b7 100644
> --- a/PVE/QemuMigrate.pm
> +++ b/PVE/QemuMigrate.pm
> @@ -1043,6 +1043,12 @@ sub phase3_cleanup {
>       }
>   
>       # clear migrate lock
> +    if ($self->{opts}->{externalcluster}) {
> +	my $src_conf = PVE::QemuConfig->load_config($vmid);
> +	delete $src_conf->{lock};
> +	eval { PVE::QemuConfig->write_config($vmid, $src_conf) };
> +    }
> +

You do not lock the config here, so you could run into a race, qm unlock 
does it like this:

>         PVE::QemuConfig->lock_config ($vmid, sub {
>             my $conf = PVE::QemuConfig->load_config($vmid);
>             delete $conf->{lock};
>             delete $conf->{pending}->{lock} if $conf->{pending}; # 
> just to be sure
>             PVE::QemuConfig->write_config($vmid, $conf);
>         });
>


Else I'm still not quite sure about keeping the whole source VM as it,
at least the functionality could then be called a "live clone to other 
cluster".


>       my $cmd = [ @{$self->{rem_ssh}}, 'qm', 'unlock', $targetvmid ];
>       $self->cmd_logerr($cmd, errmsg => "failed to clear migrate lock");
>   }





More information about the pve-devel mailing list