]> git.proxmox.com Git - qemu-server.git/commitdiff
hide long commandline on vm_start/migrate failure
authorStefan Reiter <s.reiter@proxmox.com>
Mon, 9 Dec 2019 15:14:08 +0000 (16:14 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 12 Dec 2019 12:35:40 +0000 (13:35 +0100)
By default run_command prints the entire commandline executed when an
error occurs, but QEMU and our migrate command are not only
uninteresting to the user[*] but also annoyingly long. Hide them and only
print the exit code.

[*] Especially our migrate command, since it can't be manually executed
anyway. QEMU's commandline *might* contain something interesting, but is
so long that it's tricky to parse anyway, any a user can always call 'qm
showcmd --pretty'.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
PVE/QemuMigrate.pm
PVE/QemuServer.pm

index f909873318c6a0fec214652ac5ba330f7ddf72e2..b5ec45c54ee243eb842d61d2ee7b6121930c3c31 100644 (file)
@@ -595,7 +595,7 @@ sub phase2 {
 
     # Note: We try to keep $spice_ticket secret (do not pass via command line parameter)
     # instead we pipe it through STDIN
-    PVE::Tools::run_command($cmd, input => $spice_ticket, outfunc => sub {
+    my $exitcode = PVE::Tools::run_command($cmd, input => $spice_ticket, outfunc => sub {
        my $line = shift;
 
        if ($line =~ m/^migration listens on tcp:(localhost|[\d\.]+|\[[\d\.:a-fA-F]+\]):(\d+)$/) {
@@ -629,7 +629,9 @@ sub phase2 {
     }, errfunc => sub {
        my $line = shift;
        $self->log('info', $line);
-    });
+    }, noerr => 1);
+
+    die "remote command failed with exit code $exitcode\n" if $exitcode;
 
     die "unable to detect remote migration address\n" if !$raddr;
 
index c8e2b6678ebfa19711c92bd14ccf7b46b5d8c46d..45fee3cae9ab14e4c6e20df84474d746a9e679da 100644 (file)
@@ -5405,7 +5405,11 @@ sub vm_start {
                                                  : $defaults->{cpuunits};
 
        my $start_timeout = ($conf->{hugepages} || $is_suspended) ? 300 : 30;
-       my %run_params = (timeout => $statefile ? undef : $start_timeout, umask => 0077);
+       my %run_params = (
+           timeout => $statefile ? undef : $start_timeout,
+           umask => 0077,
+           noerr => 1,
+       );
 
        my %properties = (
            Slice => 'qemu.slice',
@@ -5421,7 +5425,9 @@ sub vm_start {
        my $run_qemu = sub {
            PVE::Tools::run_fork sub {
                PVE::Systemd::enter_systemd_scope($vmid, "Proxmox VE VM $vmid", %properties);
-               run_command($cmd, %run_params);
+
+               my $exitcode = run_command($cmd, %run_params);
+               die "QEMU exited with code $exitcode\n" if $exitcode;
            };
        };