[pve-devel] [PATCH] migrate : add nocheck for resume

Alexandre Derumier aderumier at odiso.com
Wed Oct 14 11:06:06 CEST 2015


Users have reported resume bug when HA is used.

They seem to have a little race (bench show >0s < 1s) between the vm conf file move on source node and replication to,
and resume on target node.

I don't known why this is only with HA, maybe this occur will standard migration too.

Anyway, we don't need to read the vm config file to resume the vm on target host,
as we are sure that the vm is migrated, and config file move action is correct in the cluster.

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/API2/Qemu.pm   |  8 ++++++--
 PVE/QemuMigrate.pm |  2 +-
 PVE/QemuServer.pm  | 14 ++++++++++----
 3 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 8bcc2bf..3f16bcd 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -1888,6 +1888,8 @@ __PACKAGE__->register_method({
 	    node => get_standard_option('pve-node'),
 	    vmid => get_standard_option('pve-vmid'),
 	    skiplock => get_standard_option('skiplock'),
+	    nocheck => { type => 'boolean', optional => 1 },
+
 	},
     },
     returns => {
@@ -1908,14 +1910,16 @@ __PACKAGE__->register_method({
 	raise_param_exc({ skiplock => "Only root may use this option." })
 	    if $skiplock && $authuser ne 'root at pam';
 
-	die "VM $vmid not running\n" if !PVE::QemuServer::check_running($vmid);
+	my $nocheck = extract_param($param, 'nocheck');
+
+	die "VM $vmid not running\n" if !PVE::QemuServer::check_running($vmid, $nocheck);
 
 	my $realcmd = sub {
 	    my $upid = shift;
 
 	    syslog('info', "resume VM $vmid: $upid\n");
 
-	    PVE::QemuServer::vm_resume($vmid, $skiplock);
+	    PVE::QemuServer::vm_resume($vmid, $skiplock, $nocheck);
 
 	    return;
 	};
diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index 264a2a7..a1ee10a 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -584,7 +584,7 @@ sub phase3_cleanup {
 
     if ($self->{livemigration}) {
 	# now that config file is move, we can resume vm on target if livemigrate
-	my $cmd = [@{$self->{rem_ssh}}, 'qm', 'resume', $vmid, '--skiplock'];
+	my $cmd = [@{$self->{rem_ssh}}, 'qm', 'resume', $vmid, '--skiplock', '--nocheck'];
 	eval{ PVE::Tools::run_command($cmd, outfunc => sub {}, 
 		errfunc => sub {
 		    my $line = shift;
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 33b3a12..047cf97 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -4615,15 +4615,21 @@ sub vm_suspend {
 }
 
 sub vm_resume {
-    my ($vmid, $skiplock) = @_;
+    my ($vmid, $skiplock, $nocheck) = @_;
 
     lock_config($vmid, sub {
 
-	my $conf = load_config($vmid);
+	if (!$nocheck) {
 
-	check_lock($conf) if !($skiplock || ($conf->{lock} && $conf->{lock} eq 'backup'));
+	    my $conf = load_config($vmid);
 
-	vm_mon_cmd($vmid, "cont");
+	    check_lock($conf) if !($skiplock || ($conf->{lock} && $conf->{lock} eq 'backup'));
+
+	    vm_mon_cmd($vmid, "cont");
+
+	} else {
+	    vm_mon_cmd_nocheck($vmid, "cont");
+	}
     });
 }
 
-- 
2.1.4



More information about the pve-devel mailing list