mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-13 13:46:46 +00:00
clh: improve driver logging for failed hypervisor
added logging of stdout and stderr for failed hypervisor Fixes: #2271 Signed-off-by: Johan Kuijpers <johan.kuijpers@ericsson.com>
This commit is contained in:
parent
7b8e15f3a7
commit
6af127f7f9
@ -7,9 +7,9 @@ package virtcontainers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
@ -84,6 +84,7 @@ type cloudHypervisor struct {
|
|||||||
socketPath string
|
socketPath string
|
||||||
version CloudHypervisorVersion
|
version CloudHypervisorVersion
|
||||||
cliBuilder *DefaultCLIBuilder
|
cliBuilder *DefaultCLIBuilder
|
||||||
|
cmdOutput bytes.Buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
var clhKernelParams = []Param{
|
var clhKernelParams = []Param{
|
||||||
@ -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)
|
return fmt.Errorf("failed to launch cloud-hypervisor: %s, error messages from log: %s", err, strErr)
|
||||||
}
|
}
|
||||||
if err := clh.waitVMM(clhTimeout); err != nil {
|
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()
|
clh.shutdownVirtiofsd()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -836,11 +837,12 @@ func (clh *cloudHypervisor) LaunchClh() (string, int, error) {
|
|||||||
clh.Logger().WithField("args", strings.Join(cli.args, " ")).Info()
|
clh.Logger().WithField("args", strings.Join(cli.args, " ")).Info()
|
||||||
|
|
||||||
cmd := exec.Command(clhPath, cli.args...)
|
cmd := exec.Command(clhPath, cli.args...)
|
||||||
cmd.Stderr = ioutil.Discard
|
cmd.Stdout = &clh.cmdOutput
|
||||||
|
cmd.Stderr = &clh.cmdOutput
|
||||||
|
|
||||||
if clh.config.Debug {
|
if clh.config.Debug {
|
||||||
cmd.Env = os.Environ()
|
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 {
|
if err := cmd.Start(); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user