From b6954dce2f21b8feb1448edaaeeefc22f5ff4944 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Tue, 7 May 2024 17:04:45 +0200 Subject: pkg/vminfo: run programs interactively Use the same interfaces as the fuzzer. Now syz-manager no longer needs to treat machine check executions differently. --- pkg/vminfo/vminfo.go | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'pkg/vminfo/vminfo.go') diff --git a/pkg/vminfo/vminfo.go b/pkg/vminfo/vminfo.go index 8c5af606e..4f6ab7425 100644 --- a/pkg/vminfo/vminfo.go +++ b/pkg/vminfo/vminfo.go @@ -14,6 +14,7 @@ package vminfo import ( "bytes" + "context" "errors" "fmt" "io" @@ -23,14 +24,15 @@ import ( "github.com/google/syzkaller/pkg/cover" "github.com/google/syzkaller/pkg/flatrpc" + "github.com/google/syzkaller/pkg/fuzzer/queue" "github.com/google/syzkaller/pkg/mgrconfig" - "github.com/google/syzkaller/pkg/rpctype" "github.com/google/syzkaller/prog" "github.com/google/syzkaller/sys/targets" ) type Checker struct { checker + source queue.Source checkContext *checkContext } @@ -46,9 +48,12 @@ func New(cfg *mgrconfig.Config) *Checker { default: impl = new(stub) } + ctx := context.Background() + executor := queue.Plain() return &Checker{ checker: impl, - checkContext: newCheckContext(cfg, impl), + source: queue.Deduplicate(ctx, executor), + checkContext: newCheckContext(ctx, cfg, impl, executor), } } @@ -77,17 +82,25 @@ func (checker *Checker) MachineInfo(fileInfos []flatrpc.FileInfo) ([]cover.Kerne return modules, info.Bytes(), nil } -func (checker *Checker) StartCheck() ([]string, []rpctype.ExecutionRequest) { - return checker.checkFiles(), checker.checkContext.startCheck() +func (checker *Checker) CheckFiles() []string { + return checker.checkFiles() } -func (checker *Checker) FinishCheck(files []flatrpc.FileInfo, progs []rpctype.ExecutionResult, - featureInfos []flatrpc.FeatureInfo) (map[*prog.Syscall]bool, map[*prog.Syscall]string, Features, error) { +func (checker *Checker) Run(files []flatrpc.FileInfo, featureInfos []flatrpc.FeatureInfo) ( + map[*prog.Syscall]bool, map[*prog.Syscall]string, Features, error) { ctx := checker.checkContext checker.checkContext = nil - return ctx.finishCheck(files, progs, featureInfos) + ctx.start(files) + return ctx.wait(featureInfos) } +// Implementation of the queue.Source interface. +func (checker *Checker) Next() *queue.Request { + return checker.source.Next() +} + +var _ queue.Source = &Checker{} + type machineInfoFunc func(files filesystem, w io.Writer) (string, error) type checker interface { -- cgit mrf-deployment