feat: watch for kernel panic/warn/bug
This commit is contained in:
parent
6f53a3f386
commit
1b3e23d188
@ -188,17 +188,20 @@ func kvmExists() bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *System) panicWatcher() {
|
func (q *System) checkOopsPanic(s string) {
|
||||||
for {
|
if strings.Contains(s, "Kernel panic") {
|
||||||
|
q.KernelPanic = true
|
||||||
|
q.Log.Warn().Msg("kernel panic")
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
if strings.Contains(q.Stdout, "Kernel panic") {
|
// There is no reason to stay alive after kernel panic
|
||||||
q.KernelPanic = true
|
q.Stop()
|
||||||
q.Log.Debug().Msg("kernel panic")
|
} else if strings.Contains(s, "BUG") {
|
||||||
time.Sleep(time.Second)
|
q.Log.Warn().Msg(s)
|
||||||
// There is no reason to stay alive after kernel panic
|
time.Sleep(time.Second)
|
||||||
q.Stop()
|
// consider BUG() as non-recoverable state
|
||||||
return
|
q.Stop()
|
||||||
}
|
} else if strings.Contains(s, "WARNING") {
|
||||||
|
q.Log.Warn().Msg(s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,6 +310,7 @@ func (q *System) Start() (err error) {
|
|||||||
m := scanner.Text()
|
m := scanner.Text()
|
||||||
q.Stdout += m + "\n"
|
q.Stdout += m + "\n"
|
||||||
q.Log.Trace().Str("stdout", m).Msg("qemu")
|
q.Log.Trace().Str("stdout", m).Msg("qemu")
|
||||||
|
go q.checkOopsPanic(m)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -330,8 +334,6 @@ func (q *System) Start() (err error) {
|
|||||||
err = errors.New("qemu died immediately: " + string(q.Stderr))
|
err = errors.New("qemu died immediately: " + string(q.Stderr))
|
||||||
}
|
}
|
||||||
|
|
||||||
go q.panicWatcher()
|
|
||||||
|
|
||||||
if q.Timeout != 0 {
|
if q.Timeout != 0 {
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(q.Timeout)
|
time.Sleep(q.Timeout)
|
||||||
|
Loading…
Reference in New Issue
Block a user