1
0

feat: watch for kernel panic/warn/bug

This commit is contained in:
dump_stack() 2023-12-25 15:03:07 +00:00
parent 6f53a3f386
commit 1b3e23d188
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC

View File

@ -188,17 +188,20 @@ func kvmExists() bool {
return true
}
func (q *System) panicWatcher() {
for {
time.Sleep(time.Second)
if strings.Contains(q.Stdout, "Kernel panic") {
func (q *System) checkOopsPanic(s string) {
if strings.Contains(s, "Kernel panic") {
q.KernelPanic = true
q.Log.Debug().Msg("kernel panic")
q.Log.Warn().Msg("kernel panic")
time.Sleep(time.Second)
// There is no reason to stay alive after kernel panic
q.Stop()
return
}
} else if strings.Contains(s, "BUG") {
q.Log.Warn().Msg(s)
time.Sleep(time.Second)
// consider BUG() as non-recoverable state
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()
q.Stdout += m + "\n"
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))
}
go q.panicWatcher()
if q.Timeout != 0 {
go func() {
time.Sleep(q.Timeout)