[pve-devel] [PATCH qemu-server 3/4] fix #2493: show QEMU errors in migration log

Stefan Reiter s.reiter at proxmox.com
Mon Dec 9 16:14:09 CET 2019


QEMU usually only prints warnings and errors and stays silent otherwise,
so it makes sense to just log all of it's output.

Prefix it with '[<target_hostname>]' to indicate that the output is
coming from the remote node, so users know where to search for the
error.

Side effect is that the 'VM start' task created by the migration will
now show the "QEMU:" prefix, but it's still very readable IMHO.

Signed-off-by: Stefan Reiter <s.reiter at proxmox.com>
---
 PVE/QemuMigrate.pm |  4 +++-
 PVE/QemuServer.pm  | 12 ++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index b5ec45c..0353458 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -625,10 +625,12 @@ sub phase2 {
 	    $self->{target_drive}->{$targetdrive}->{volid} = $volid;
 	    $self->{target_drive}->{$targetdrive}->{nbd_uri} = $nbd_uri;
 
+	} elsif ($line =~ m/^QEMU: (.*)$/) {
+	    $self->log('info', "[$self->{node}] $1\n");
 	}
     }, errfunc => sub {
 	my $line = shift;
-	$self->log('info', $line);
+	$self->log('info', "[$self->{node}] $line");
     }, noerr => 1);
 
     die "remote command failed with exit code $exitcode\n" if $exitcode;
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 01b677b..4317516 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -5402,6 +5402,18 @@ sub vm_start {
 	    noerr => 1,
 	);
 
+	# when migrating, prefix QEMU output so other side can pick up any
+	# errors that might occur and show the user
+	if ($migratedfrom) {
+	    $run_params{quiet} = 1;
+	    $run_params{logfunc} = sub {
+		my $msg = shift;
+		return if !$msg;
+		chomp $msg;
+		print "QEMU: $msg\n";
+	    };
+	}
+
 	my %properties = (
 	    Slice => 'qemu.slice',
 	    KillMode => 'none',
-- 
2.20.1




More information about the pve-devel mailing list