[pve-devel] [PATCH stable-4 qemu-server 1/3] fix #1338: migrate: stop nbd before resuming

Fabian Gr├╝nbichler f.gruenbichler at proxmox.com
Wed Oct 4 08:57:19 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>
(cherry picked from commit 504105c638f2234c9d4a00109c9bb41e36c47ca3)
---
 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.14.1




More information about the pve-devel mailing list