[pve-devel] [PATCH_V2 1/2] fix unlock handling after migration.

Wolfgang Link w.link at proxmox.com
Fri Sep 4 12:01:08 CEST 2015


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 | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/PVE/LXC/Migrate.pm b/src/PVE/LXC/Migrate.pm
index bf6d701..8287961 100644
--- a/src/PVE/LXC/Migrate.pm
+++ b/src/PVE/LXC/Migrate.pm
@@ -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");	
     }
 }
 
-- 
2.1.4





More information about the pve-devel mailing list