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 /pkg | |
| parent | a9fce3b50a00a8dab6365de4c22749f4bd1f1ac6 (diff) | |
vm: refactoring
1. func Run optionally accepts the opts.
2. Some refactoring, more comments.
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/instance/execprog.go | 9 | ||||
| -rw-r--r-- | pkg/manager/diff.go | 7 | ||||
| -rw-r--r-- | pkg/report/report.go | 2 |
3 files changed, 11 insertions, 7 deletions
diff --git a/pkg/instance/execprog.go b/pkg/instance/execprog.go index 83461d07e..0b9f9ebf7 100644 --- a/pkg/instance/execprog.go +++ b/pkg/instance/execprog.go @@ -120,13 +120,16 @@ func (inst *ExecProgInstance) runCommand(command string, duration time.Duration, command = inst.StraceBin + filterCalls + ` -s 100 -x -f ` + command prefixOutput = []byte(fmt.Sprintf("%s\n\n<...>\n", command)) } - opts := []any{exitCondition} + optionalBeforeContext := func(*vm.RunOptions) {} if inst.BeforeContextLen != 0 { - opts = append(opts, vm.OutputSize(inst.BeforeContextLen)) + optionalBeforeContext = vm.WithBeforeContext(inst.BeforeContextLen) } ctxTimeout, cancel := context.WithTimeout(context.Background(), duration) defer cancel() - output, rep, err := inst.VMInstance.Run(ctxTimeout, inst.reporter, command, opts...) + output, rep, err := inst.VMInstance.Run(ctxTimeout, inst.reporter, command, + vm.WithExitCondition(exitCondition), + optionalBeforeContext, + ) if err != nil { return nil, fmt.Errorf("failed to run command in VM: %w", err) } diff --git a/pkg/manager/diff.go b/pkg/manager/diff.go index 4b4013169..ef70d7aa8 100644 --- a/pkg/manager/diff.go +++ b/pkg/manager/diff.go @@ -636,9 +636,10 @@ func (kc *kernelContext) runInstance(ctx context.Context, inst *vm.Instance, cmd := fmt.Sprintf("%v runner %v %v %v", executorBin, inst.Index(), host, port) ctxTimeout, cancel := context.WithTimeout(ctx, kc.cfg.Timeouts.VMRunningTime) defer cancel() - _, rep, err := inst.Run(ctxTimeout, kc.reporter, cmd, vm.ExitTimeout, - vm.InjectExecuting(injectExec), - vm.EarlyFinishCb(func() { + _, rep, err := inst.Run(ctxTimeout, kc.reporter, cmd, + 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. diff --git a/pkg/report/report.go b/pkg/report/report.go index 2ac039fdd..088f8c089 100644 --- a/pkg/report/report.go +++ b/pkg/report/report.go @@ -74,7 +74,7 @@ type Report struct { Executor *ExecutorInfo // reportPrefixLen is length of additional prefix lines that we added before actual crash report. reportPrefixLen int - // symbolized is set if the report is symbolized. + // symbolized is set if the report is symbolized. It prevents double symbolization. symbolized bool } |
