Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
clh: improve driver logging for failed hypervisor
Browse files Browse the repository at this point in the history
added logging of stdout and stderr for failed hypervisor

Fixes: #2271

Signed-off-by: Johan Kuijpers <johan.kuijpers@ericsson.com>
  • Loading branch information
ericooper committed Nov 26, 2019
1 parent 7b8e15f commit 6af127f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions virtcontainers/clh.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ package virtcontainers

import (
"bufio"
"bytes"
"context"
"fmt"
"io/ioutil"
"net"
"os"
"os/exec"
Expand Down Expand Up @@ -84,6 +84,7 @@ type cloudHypervisor struct {
socketPath string
version CloudHypervisorVersion
cliBuilder *DefaultCLIBuilder
cmdOutput bytes.Buffer
}

var clhKernelParams = []Param{
Expand Down Expand Up @@ -295,7 +296,7 @@ func (clh *cloudHypervisor) startSandbox(timeout int) error {
return fmt.Errorf("failed to launch cloud-hypervisor: %s, error messages from log: %s", err, strErr)
}
if err := clh.waitVMM(clhTimeout); err != nil {
clh.Logger().WithField("error", err).Warn("cloud-hypervisor init failed")
clh.Logger().WithField("error", err).WithField("output", clh.cmdOutput.String()).Warn("cloud-hypervisor init failed")
clh.shutdownVirtiofsd()
return err
}
Expand Down Expand Up @@ -836,11 +837,12 @@ func (clh *cloudHypervisor) LaunchClh() (string, int, error) {
clh.Logger().WithField("args", strings.Join(cli.args, " ")).Info()

cmd := exec.Command(clhPath, cli.args...)
cmd.Stderr = ioutil.Discard
cmd.Stdout = &clh.cmdOutput
cmd.Stderr = &clh.cmdOutput

if clh.config.Debug {
cmd.Env = os.Environ()
cmd.Env = append(cmd.Env, "RUST_BACKTRACE=FULL")
cmd.Env = append(cmd.Env, "RUST_BACKTRACE=full")
}

if err := cmd.Start(); err != nil {
Expand Down

0 comments on commit 6af127f

Please sign in to comment.