From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server] fix #4549: capture and bubble up qemu errors correctly
Date: Tue, 9 May 2023 10:46:54 +0200 [thread overview]
Message-ID: <20230509084654.666207-1-c.heiss@proxmox.com> (raw)
See [0]. The issue is that currently, all messages from qemu get
directly sent to stdout by run_command(). In turn, this output was
missing from mail notifications.
Fix this by unifying it with the migration logging, properly capturing
the output and including it in the error message, which then gets
further passed on. Also has the benefit that messages from qemu are now
prefixed with 'QEMU: ' in all cases, making it more uniform.
As for phase2_start_local_cluster(), this now gets caught by the
`errfunc`, thus the special handling can be removed.
For `vzdump`, testing was done by manually setting a non-existent bridge
on a network interface. For (live-)migration, a bridge was created which
exists on the source node but not on the target. Both cases trigger an
qemu error when it tries to start up, very similarly to the bug report.
[0] https://bugzilla.proxmox.com/show_bug.cgi?id=4549
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
PVE/QemuMigrate.pm | 2 --
PVE/QemuServer.pm | 16 ++++++++--------
2 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index 09cc1d8..b1c28b3 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -998,8 +998,6 @@ sub phase2_start_local_cluster {
my $drive = $1;
my $volid = $2;
$target_replicated_volumes->{$volid} = $drive;
- } elsif ($line =~ m/^QEMU: (.*)$/) {
- $self->log('info', "[$self->{node}] $1\n");
}
}, errfunc => sub {
my $line = shift;
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index c1d0fd2..8375b2a 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -5885,15 +5885,9 @@ sub vm_start_nolock {
timeout => $statefile ? undef : $start_timeout,
umask => 0077,
noerr => 1,
+ quiet => 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 { print "QEMU: $_[0]\n" };
- }
-
my %systemd_properties = (
Slice => 'qemu.slice',
KillMode => 'process',
@@ -5922,13 +5916,19 @@ sub vm_start_nolock {
$tpmpid = start_swtpm($storecfg, $vmid, $tpm, $migratedfrom);
}
+ # '\r\n' needs to be used as a line separator here, as that is what run_command() splits
+ # lines on. If just a newline is used, all error message lines end up on a single line
+ # in the migration tasklog.
+ my $err = '';
+ $run_params{logfunc} = sub { $err .= "QEMU: $1\r\n"; };
+
my $exitcode = run_command($cmd, %run_params);
if ($exitcode) {
if ($tpmpid) {
warn "stopping swtpm instance (pid $tpmpid) due to QEMU startup error\n";
kill 'TERM', $tpmpid;
}
- die "QEMU exited with code $exitcode\n";
+ die "QEMU exited with code $exitcode\r\n$err";
}
};
};
--
2.39.2
next reply other threads:[~2023-05-09 8:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-09 8:46 Christoph Heiss [this message]
2023-06-12 11:22 ` Fiona Ebner
2023-06-12 11:26 ` Fiona Ebner
2023-06-12 14:54 ` Thomas Lamprecht
2023-06-13 7:05 ` Fiona Ebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230509084654.666207-1-c.heiss@proxmox.com \
--to=c.heiss@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox