]> git.proxmox.com Git - pve-container.git/commitdiff
fix unlock handling after migration.
authorWolfgang Link <w.link@proxmox.com>
Fri, 4 Sep 2015 10:01:08 +0000 (12:01 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 7 Sep 2015 10:08:16 +0000 (12:08 +0200)
this will handle if the migration was successful or not.
this is important, because this determines where the config is.

src/PVE/LXC/Migrate.pm

index bf6d701d3330f45f97405a4e68bcdaf74e4e96f5..1a51829c4228c89be1b100e51be9449c0c2eb86f 100644 (file)
@@ -116,6 +116,8 @@ sub phase1 {
     # move config
     die "Failed to move config to node '$self->{node}' - rename failed: $!\n"
        if !rename($conffile, $newconffile);
+
+    $self->{conf_migrated} = 1;
 }
 
 sub phase1_cleanup {
@@ -152,12 +154,17 @@ sub final_cleanup {
 
     $self->log('info', "start final cleanup");
 
-    my $conf = $self->{vmconf};
-    delete $conf->{lock};
+    if (!$self->{conf_migrated}) {
+       my $conf = $self->{vmconf};
+       delete $conf->{lock};
 
-    eval { PVE::LXC::write_config($vmid, $conf); };
-    if (my $err = $@) {
-       $self->log('err', $err);
+       eval { PVE::LXC::write_config($vmid, $conf); };
+       if (my $err = $@) {
+           $self->log('err', $err);
+       }
+    } else {
+       my $cmd = [ @{$self->{rem_ssh}}, 'pct', 'unlock', $vmid ];
+       $self->cmd_logerr($cmd, errmsg => "failed to clear migrate lock");      
     }
 }