[pve-devel] [PATCH 2/2] migrate: add some more log output

Thomas Lamprecht t.lamprecht at proxmox.com
Tue May 31 11:34:48 CEST 2016


Output all errors - if any - and add some log outputs on what we qmp
commands we do with which parameters, may be helpful when debugging
or analyzing a users problem.

Also check if the queried status is defined, as on a error this may
not be.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 PVE/QemuMigrate.pm | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index 865d06a..cf4c0a5 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -381,6 +381,7 @@ sub phase2 {
 	$self->log('info', "migrate_set_downtime error: $@") if $@;
     }
 
+    $self->log('info', "set migration_caps");
     eval {
 	PVE::QemuServer::set_migration_caps($vmid);
     };
@@ -388,10 +389,12 @@ sub phase2 {
 
     #set cachesize 10% of the total memory
     my $cachesize = int($conf->{memory}*1048576/10);
+    $self->log('info', "set cachesize: $cachesize");
     eval {
-	PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "migrate-set-cache-size", value => $cachesize);
+	PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "migrate-set-cache-size", value => int($cachesize));
     };
-	
+    $self->log('info', "migrate-set-cache-size error: $@") if $@;
+
     if (PVE::QemuServer::vga_conf_has_spice($conf->{vga})) {
 	my $rpcenv = PVE::RPCEnvironment::get();
 	my $authuser = $rpcenv->get_user();
@@ -412,6 +415,7 @@ sub phase2 {
 
     }
 
+    $self->log('info', "start migrate command to $ruri");
     eval {
         PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "migrate", uri => $ruri);
     };
@@ -436,6 +440,7 @@ sub phase2 {
 	if (my $err = $@) {
 	    $err_count++;
 	    warn "query migrate failed: $err\n";
+	    $self->log('info', "query migrate failed: $err");
 	    if ($err_count <= 5) {
 		usleep(1000000);
 		next;
@@ -443,12 +448,12 @@ sub phase2 {
 	    die "too many query migrate failures - aborting\n";
 	}
 
-        if ($stat->{status} =~ m/^(setup)$/im) {
+        if (defined($stat->{status}) && $stat->{status} =~ m/^(setup)$/im) {
             sleep(1);
             next;
         }
 
-	if ($stat->{status} =~ m/^(active|completed|failed|cancelled)$/im) {
+	if (defined($stat->{status}) && $stat->{status} =~ m/^(active|completed|failed|cancelled)$/im) {
 	    $merr = undef;
 	    $err_count = 0;
 	    if ($stat->{status} eq 'completed') {
@@ -461,6 +466,7 @@ sub phase2 {
 	    }
 
 	    if ($stat->{status} eq 'failed' || $stat->{status} eq 'cancelled') {
+		$self->log('info', "migration status error: $stat->{status}");
 		die "aborting\n"
 	    }
 
-- 
2.1.4





More information about the pve-devel mailing list