[pve-devel] [PATCH qemu-server 3/4] fix #2493: show QEMU errors in migration log
Thomas Lamprecht
t.lamprecht at proxmox.com
Tue Dec 10 09:09:38 CET 2019
On 12/9/19 4:14 PM, Stefan Reiter wrote:
> 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;
$msg is always defined, and you want to print it too, if it's (why ever) '0'
or other false-y values.
> + chomp $msg;
already done by run_command, FWIW, the whole log func could have been
reduced to:
$run_params{logfunc} = sub { print "QEMU: $_[0]\n" }
> + print "QEMU: $msg\n";
> + };
> + }
> +
> my %properties = (
> Slice => 'qemu.slice',
> KillMode => 'none',
>
More information about the pve-devel
mailing list