[pve-devel] [RFC qemu-server 2/4] fix #1338: migrate: stop nbd before resuming

Fabian Grünbichler f.gruenbichler at proxmox.com
Wed Apr 19 15:19:48 CEST 2017


since Qemu 2.9, block device write access is limited to one
writer unless shared_rw is set to true. there is an
exception for live-migrating local disks via NBD as long as
the VM is suspended.

stop the NBD server before resuming the VM accordingly to
unbreak local disk live-migration.

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
 PVE/QemuMigrate.pm | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index e6f147e..b513a67 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -884,6 +884,16 @@ sub phase3_cleanup {
         if !rename($conffile, $newconffile);
 
     if ($self->{livemigration}) {
+	if ($self->{storage_migration}) {
+	    # stop nbd server on remote vm - requirement for resume since 2.9
+	    my $cmd = [@{$self->{rem_ssh}}, 'qm', 'nbdstop', $vmid];
+
+	    eval{ PVE::Tools::run_command($cmd, outfunc => sub {}, errfunc => sub {}) };
+	    if (my $err = $@) {
+		$self->log('err', $err);
+		$self->{errors} = 1;
+	    }
+	}
 	# now that config file is move, we can resume vm on target if livemigrate
 	my $cmd = [@{$self->{rem_ssh}}, 'qm', 'resume', $vmid, '--skiplock', '--nocheck'];
 	eval{ PVE::Tools::run_command($cmd, outfunc => sub {}, 
@@ -942,14 +952,6 @@ sub phase3_cleanup {
 	    }
 	}
 
-	#stop nbd server to remote vm
-	my $cmd = [@{$self->{rem_ssh}}, 'qm', 'nbdstop', $vmid];
-
-	eval{ PVE::Tools::run_command($cmd, outfunc => sub {}, errfunc => sub {}) };
-	if (my $err = $@) {
-	    $self->log('err', $err);
-	    $self->{errors} = 1;
-	}
     }
 
     # clear migrate lock
-- 
2.1.4





More information about the pve-devel mailing list