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

Commit

Permalink
virtcontainers: fix the issue of missing qemu error logs
Browse files Browse the repository at this point in the history
When 'debug' is enabled, qemu's debug info is output
into qemu's log file. When lauching qemu failed, it's
better to log these debug info and return it directly
for debugging.

Fixes:#2042

Signed-off-by: lifupan <[email protected]>
  • Loading branch information
lifupan committed Sep 20, 2019
1 parent fef938f commit 1f93cff
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion virtcontainers/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,15 @@ func (q *qemu) startSandbox(timeout int) error {
var strErr string
strErr, err = govmmQemu.LaunchQemu(q.qemuConfig, newQMPLogger())
if err != nil {
return fmt.Errorf("fail to launch qemu: %s, error messages from qemu log: %s", err, strErr)
if q.config.Debug && q.qemuConfig.LogFile != "" {
b, err := ioutil.ReadFile(q.qemuConfig.LogFile)
if err == nil {
strErr += string(b)
}
}

q.Logger().WithError(err).Errorf("failed to launch qemu: %s", strErr)
return fmt.Errorf("failed to launch qemu: %s, error messages from qemu log: %s", err, strErr)
}

err = q.waitSandbox(timeout) // the virtiofsd deferred checks err's value
Expand Down

0 comments on commit 1f93cff

Please sign in to comment.