diff options
| author | Taras Madan <tarasmadan@google.com> | 2025-08-05 10:03:38 +0200 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2025-08-07 10:01:30 +0000 |
| commit | 04cffc22d57a9014cb89df6c9f44de50d2eb2b9b (patch) | |
| tree | b6b5ff4cd8afb9342a2fc5d8dfaff21a4766139b /syz-manager | |
| parent | a9fce3b50a00a8dab6365de4c22749f4bd1f1ac6 (diff) | |
vm: refactoring
1. func Run optionally accepts the opts.
2. Some refactoring, more comments.
Diffstat (limited to 'syz-manager')
| -rw-r--r-- | syz-manager/manager.go | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/syz-manager/manager.go b/syz-manager/manager.go index fedf6a9e8..177cd5f01 100644 --- a/syz-manager/manager.go +++ b/syz-manager/manager.go @@ -597,12 +597,15 @@ func (mgr *Manager) fuzzerInstance(ctx context.Context, inst *vm.Instance, updIn injectExec := make(chan bool, 10) serv.CreateInstance(inst.Index(), injectExec, updInfo) - rep, vmInfo, err := mgr.runInstanceInner(ctx, inst, injectExec, vm.EarlyFinishCb(func() { - // Depending on the crash type and kernel config, fuzzing may continue - // running for several seconds even after kernel has printed a crash report. - // This litters the log and we want to prevent it. - serv.StopFuzzing(inst.Index()) - })) + rep, vmInfo, err := mgr.runInstanceInner(ctx, inst, + vm.WithExitCondition(vm.ExitTimeout), + vm.WithInjectExecuting(injectExec), + vm.WithEarlyFinishCb(func() { + // Depending on the crash type and kernel config, fuzzing may continue + // running for several seconds even after kernel has printed a crash report. + // This litters the log, and we want to prevent it. + serv.StopFuzzing(inst.Index()) + })) var extraExecs []report.ExecutorInfo if rep != nil && rep.Executor != nil { extraExecs = []report.ExecutorInfo{*rep.Executor} @@ -626,8 +629,8 @@ func (mgr *Manager) fuzzerInstance(ctx context.Context, inst *vm.Instance, updIn } } -func (mgr *Manager) runInstanceInner(ctx context.Context, inst *vm.Instance, injectExec <-chan bool, - finishCb vm.EarlyFinishCb) (*report.Report, []byte, error) { +func (mgr *Manager) runInstanceInner(ctx context.Context, inst *vm.Instance, opts ...func(*vm.RunOptions), +) (*report.Report, []byte, error) { fwdAddr, err := inst.Forward(mgr.serv.Port()) if err != nil { return nil, nil, fmt.Errorf("failed to setup port forwarding: %w", err) @@ -653,10 +656,7 @@ func (mgr *Manager) runInstanceInner(ctx context.Context, inst *vm.Instance, inj cmd := fmt.Sprintf("%v runner %v %v %v", executorBin, inst.Index(), host, port) ctxTimeout, cancel := context.WithTimeout(ctx, mgr.cfg.Timeouts.VMRunningTime) defer cancel() - _, rep, err := inst.Run(ctxTimeout, mgr.reporter, cmd, - vm.ExitTimeout, vm.InjectExecuting(injectExec), - finishCb, - ) + _, rep, err := inst.Run(ctxTimeout, mgr.reporter, cmd, opts...) if err != nil { return nil, nil, fmt.Errorf("failed to run fuzzer: %w", err) } |
