aboutsummaryrefslogtreecommitdiffstats
path: root/vm
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2016-09-28 18:05:28 +0200
committerDmitry Vyukov <dvyukov@google.com>2016-09-28 18:05:28 +0200
commitc2918417cbe2da7ee83deb316c3e8163f14b01a0 (patch)
treee39af760694dd4f77e961549358dc1698d3faaae /vm
parentdb32fed8a15b542f3f4db9014b9dc6b03b93a979 (diff)
vm: give preference to kernel oops over "lost connection"
If lost connection races with a kernel oops (which probably caused the lost), give preference to the oops message (it should be more useful).
Diffstat (limited to 'vm')
-rw-r--r--vm/vm.go36
1 files changed, 22 insertions, 14 deletions
diff --git a/vm/vm.go b/vm/vm.go
index ac60c8de0..f27fa200d 100644
--- a/vm/vm.go
+++ b/vm/vm.go
@@ -105,6 +105,24 @@ func MonitorExecution(outc <-chan []byte, errc <-chan error, local, needOutput b
beforeContext = 256 << 10
afterContext = 128 << 10
)
+ extractError := func(defaultError string) (string, []byte, []byte, bool, bool) {
+ // Give it some time to finish writing the error message.
+ waitForOutput()
+ if !report.ContainsCrash(output[matchPos:]) {
+ return defaultError, nil, output, true, false
+ }
+ desc, text, start, end := report.Parse(output[matchPos:])
+ start = start + matchPos - beforeContext
+ if start < 0 {
+ start = 0
+ }
+ end = end + matchPos + afterContext
+ if end > len(output) {
+ end = len(output)
+ }
+ return desc, text, output[start:end], true, false
+ }
+
lastExecuteTime := time.Now()
ticker := time.NewTimer(3 * time.Minute)
tickerFired := false
@@ -123,8 +141,9 @@ func MonitorExecution(outc <-chan []byte, errc <-chan error, local, needOutput b
case TimeoutErr:
return err.Error(), nil, nil, false, true
default:
- waitForOutput()
- return "lost connection to test machine", nil, output, true, false
+ // Note: connection lost can race with a kernel oops message.
+ // In such case we want to return the kernel oops.
+ return extractError("lost connection to test machine")
}
case out := <-outc:
output = append(output, out...)
@@ -135,18 +154,7 @@ func MonitorExecution(outc <-chan []byte, errc <-chan error, local, needOutput b
lastExecuteTime = time.Now()
}
if report.ContainsCrash(output[matchPos:]) {
- // Give it some time to finish writing the error message.
- waitForOutput()
- desc, text, start, end := report.Parse(output[matchPos:])
- start = start + matchPos - beforeContext
- if start < 0 {
- start = 0
- }
- end = end + matchPos + afterContext
- if end > len(output) {
- end = len(output)
- }
- return desc, text, output[start:end], true, false
+ return extractError("")
}
if len(output) > 2*beforeContext {
copy(output, output[len(output)-beforeContext:])