aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-06-20 15:26:37 +0200
committerDmitry Vyukov <dvyukov@google.com>2018-06-22 16:40:45 +0200
commit87bfb99cfe1eef9469625911574b1caab04557d3 (patch)
treed29a283db2df928698c2c39850b1133b11ef55b6
parentef9ddfbe36910afb0336375fec3cfed65a74897f (diff)
vm: pass instance to MonitorExecution
It may need it later to try to obtain additional diagnostic from hanged instances.
-rw-r--r--pkg/instance/instance.go4
-rw-r--r--pkg/repro/repro.go2
-rw-r--r--syz-manager/manager.go2
-rw-r--r--tools/syz-crush/crush.go2
-rw-r--r--vm/vm.go3
5 files changed, 7 insertions, 6 deletions
diff --git a/pkg/instance/instance.go b/pkg/instance/instance.go
index 9a1b95dae..2410713ae 100644
--- a/pkg/instance/instance.go
+++ b/pkg/instance/instance.go
@@ -240,7 +240,7 @@ func (inst *inst) testInstance() error {
if err != nil {
return fmt.Errorf("failed to run binary in VM: %v", err)
}
- rep := vm.MonitorExecution(outc, errc, inst.reporter, true)
+ rep := inst.vm.MonitorExecution(outc, errc, inst.reporter, true)
if rep != nil {
if err := inst.reporter.Symbolize(rep); err != nil {
// TODO(dvyukov): send such errors to dashboard.
@@ -323,7 +323,7 @@ func (inst *inst) testProgram(command string, testTime time.Duration) error {
if err != nil {
return fmt.Errorf("failed to run binary in VM: %v", err)
}
- rep := vm.MonitorExecution(outc, errc, inst.reporter, true)
+ rep := inst.vm.MonitorExecution(outc, errc, inst.reporter, true)
if rep == nil {
return nil
}
diff --git a/pkg/repro/repro.go b/pkg/repro/repro.go
index c6106b4bd..2501d1672 100644
--- a/pkg/repro/repro.go
+++ b/pkg/repro/repro.go
@@ -610,7 +610,7 @@ func (ctx *context) testImpl(inst *vm.Instance, command string, duration time.Du
if err != nil {
return false, fmt.Errorf("failed to run command in VM: %v", err)
}
- rep := vm.MonitorExecution(outc, errc, ctx.reporter, true)
+ rep := inst.MonitorExecution(outc, errc, ctx.reporter, true)
if rep == nil {
ctx.reproLog(2, "program did not crash")
return false, nil
diff --git a/syz-manager/manager.go b/syz-manager/manager.go
index 1f73c531d..26a2de213 100644
--- a/syz-manager/manager.go
+++ b/syz-manager/manager.go
@@ -584,7 +584,7 @@ func (mgr *Manager) runInstance(index int) (*Crash, error) {
return nil, fmt.Errorf("failed to run fuzzer: %v", err)
}
- rep := vm.MonitorExecution(outc, errc, mgr.getReporter(), false)
+ rep := inst.MonitorExecution(outc, errc, mgr.getReporter(), false)
if rep == nil {
// This is the only "OK" outcome.
log.Logf(0, "vm-%v: running for %v, restarting", index, time.Since(start))
diff --git a/tools/syz-crush/crush.go b/tools/syz-crush/crush.go
index 90a7b6185..20560d0ad 100644
--- a/tools/syz-crush/crush.go
+++ b/tools/syz-crush/crush.go
@@ -110,7 +110,7 @@ func runInstance(cfg *mgrconfig.Config, reporter report.Reporter, vmPool *vm.Poo
}
log.Logf(0, "vm-%v: crushing...", index)
- rep := vm.MonitorExecution(outc, errc, reporter, false)
+ rep := inst.MonitorExecution(outc, errc, reporter, false)
if rep == nil {
// This is the only "OK" outcome.
log.Logf(0, "vm-%v: running long enough, restarting", index)
diff --git a/vm/vm.go b/vm/vm.go
index f4729c2c2..ff283cd2f 100644
--- a/vm/vm.go
+++ b/vm/vm.go
@@ -107,7 +107,8 @@ func (inst *Instance) Close() {
// outc/errc is what vm.Instance.Run returns, reporter parses kernel output for oopses.
// If canExit is false and the program exits, it is treated as an error.
// Returns a non-symbolized crash report, or nil if no error happens.
-func MonitorExecution(outc <-chan []byte, errc <-chan error, reporter report.Reporter, canExit bool) (
+func (inst *Instance) MonitorExecution(outc <-chan []byte, errc <-chan error,
+ reporter report.Reporter, canExit bool) (
rep *report.Report) {
var output []byte
waitForOutput := func() {