From 9a7d0a5412c35bdc7d0ec09fc21c1d4277e62d31 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 20 Jun 2018 15:31:06 +0200 Subject: [PATCH] pkg/report: pass vm type to NewReporter For the case when VM type affects output. Will be needed for gvisor. It is kinda linux, but kinda not. --- pkg/instance/instance.go | 4 ++-- pkg/report/linux_test.go | 8 ++++---- pkg/report/report.go | 4 ++-- pkg/report/report_test.go | 2 +- syz-manager/manager.go | 4 ++-- tools/syz-crush/crush.go | 4 ++-- tools/syz-parse/syz-parse.go | 2 +- tools/syz-repro/repro.go | 2 +- tools/syz-symbolize/symbolize.go | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pkg/instance/instance.go b/pkg/instance/instance.go index 2410713a..b5f44376 100644 --- a/pkg/instance/instance.go +++ b/pkg/instance/instance.go @@ -118,8 +118,8 @@ func (env *Env) Test(numVMs int, reproSyz, reproOpts, reproC []byte) ([]error, e if err := mgrconfig.Complete(env.cfg); err != nil { return nil, err } - reporter, err := report.NewReporter(env.cfg.TargetOS, env.cfg.KernelSrc, - filepath.Dir(env.cfg.Vmlinux), nil, env.cfg.ParsedIgnores) + reporter, err := report.NewReporter(env.cfg.TargetOS, env.cfg.Type, + env.cfg.KernelSrc, filepath.Dir(env.cfg.Vmlinux), nil, env.cfg.ParsedIgnores) if err != nil { return nil, err } diff --git a/pkg/report/linux_test.go b/pkg/report/linux_test.go index 8cd66ede..0543fcbe 100644 --- a/pkg/report/linux_test.go +++ b/pkg/report/linux_test.go @@ -12,14 +12,14 @@ import ( ) func TestLinuxIgnores(t *testing.T) { - reporter, err := NewReporter("linux", "", "", nil, nil) + reporter, err := NewReporter("linux", "", "", "", nil, nil) if err != nil { t.Fatal(err) } ignores1 := []*regexp.Regexp{ regexp.MustCompile("BUG: bug3"), } - reporter1, err := NewReporter("linux", "", "", nil, ignores1) + reporter1, err := NewReporter("linux", "", "", "", nil, ignores1) if err != nil { t.Fatal(err) } @@ -27,7 +27,7 @@ func TestLinuxIgnores(t *testing.T) { regexp.MustCompile("BUG: bug3"), regexp.MustCompile("BUG: bug1"), } - reporter2, err := NewReporter("linux", "", "", nil, ignores2) + reporter2, err := NewReporter("linux", "", "", "", nil, ignores2) if err != nil { t.Fatal(err) } @@ -36,7 +36,7 @@ func TestLinuxIgnores(t *testing.T) { regexp.MustCompile("BUG: bug1"), regexp.MustCompile("BUG: bug2"), } - reporter3, err := NewReporter("linux", "", "", nil, ignores3) + reporter3, err := NewReporter("linux", "", "", "", nil, ignores3) if err != nil { t.Fatal(err) } diff --git a/pkg/report/report.go b/pkg/report/report.go index 680656f9..a40fedf9 100644 --- a/pkg/report/report.go +++ b/pkg/report/report.go @@ -45,12 +45,12 @@ type Report struct { Maintainers []string } -// NewReporter creates reporter for the specified OS: +// NewReporter creates reporter for the specified OS/vmType: // kernelSrc: path to kernel sources directory // kernelObj: path to kernel build directory (can be empty for in-tree build) // symbols: kernel symbols (result of pkg/symbolizer.ReadSymbols on kernel object file) // ignores: optional list of regexps to ignore (must match first line of crash message) -func NewReporter(os, kernelSrc, kernelObj string, symbols map[string][]symbolizer.Symbol, +func NewReporter(os, vmType, kernelSrc, kernelObj string, symbols map[string][]symbolizer.Symbol, ignores []*regexp.Regexp) (Reporter, error) { ctor := ctors[os] if ctor == nil { diff --git a/pkg/report/report_test.go b/pkg/report/report_test.go index 1459f069..14d6c45c 100644 --- a/pkg/report/report_test.go +++ b/pkg/report/report_test.go @@ -214,7 +214,7 @@ func forEachFile(t *testing.T, dir string, fn func(t *testing.T, reporter Report if err != nil { t.Fatal(err) } - reporter, err := NewReporter(os, "", "", nil, nil) + reporter, err := NewReporter(os, "", "", "", nil, nil) if err != nil { t.Fatal(err) } diff --git a/syz-manager/manager.go b/syz-manager/manager.go index 26a2de21..964bc3e3 100644 --- a/syz-manager/manager.go +++ b/syz-manager/manager.go @@ -835,8 +835,8 @@ func (mgr *Manager) getReporter() report.Reporter { kernelSrc = mgr.cfg.KernelSrc kernelObj = filepath.Dir(mgr.cfg.Vmlinux) } - mgr.reporter, err = report.NewReporter(mgr.cfg.TargetOS, kernelSrc, kernelObj, - allSymbols, mgr.cfg.ParsedIgnores) + mgr.reporter, err = report.NewReporter(mgr.cfg.TargetOS, mgr.cfg.Type, + kernelSrc, kernelObj, allSymbols, mgr.cfg.ParsedIgnores) if err != nil { log.Fatalf("%v", err) } diff --git a/tools/syz-crush/crush.go b/tools/syz-crush/crush.go index 20560d0a..b73c9027 100644 --- a/tools/syz-crush/crush.go +++ b/tools/syz-crush/crush.go @@ -44,8 +44,8 @@ func main() { if err != nil { log.Fatalf("%v", err) } - reporter, err := report.NewReporter(cfg.TargetOS, cfg.KernelSrc, - filepath.Dir(cfg.Vmlinux), nil, cfg.ParsedIgnores) + reporter, err := report.NewReporter(cfg.TargetOS, cfg.Type, + cfg.KernelSrc, filepath.Dir(cfg.Vmlinux), nil, cfg.ParsedIgnores) if err != nil { log.Fatalf("%v", err) } diff --git a/tools/syz-parse/syz-parse.go b/tools/syz-parse/syz-parse.go index b86cecb2..64841dab 100644 --- a/tools/syz-parse/syz-parse.go +++ b/tools/syz-parse/syz-parse.go @@ -40,7 +40,7 @@ func parseReport(os, file string) { fmt.Printf("Error: %v\n", err) return } - reporter, err := report.NewReporter(os, "", "", nil, nil) + reporter, err := report.NewReporter(os, "", "", "", nil, nil) if err != nil { fmt.Printf("Error: %v\n", err) return diff --git a/tools/syz-repro/repro.go b/tools/syz-repro/repro.go index e041d393..8fcb04e4 100644 --- a/tools/syz-repro/repro.go +++ b/tools/syz-repro/repro.go @@ -57,7 +57,7 @@ func main() { for i := range vmIndexes { vmIndexes[i] = i } - reporter, err := report.NewReporter(cfg.TargetOS, cfg.KernelSrc, "", nil, cfg.ParsedIgnores) + reporter, err := report.NewReporter(cfg.TargetOS, cfg.Type, cfg.KernelSrc, "", nil, cfg.ParsedIgnores) if err != nil { log.Fatalf("%v", err) } diff --git a/tools/syz-symbolize/symbolize.go b/tools/syz-symbolize/symbolize.go index acb9db57..e683a5b0 100644 --- a/tools/syz-symbolize/symbolize.go +++ b/tools/syz-symbolize/symbolize.go @@ -26,7 +26,7 @@ func main() { flag.PrintDefaults() os.Exit(1) } - reporter, err := report.NewReporter(*flagOS, *flagKernelSrc, *flagKernelObj, nil, nil) + reporter, err := report.NewReporter(*flagOS, "", *flagKernelSrc, *flagKernelObj, nil, nil) if err != nil { fmt.Fprintf(os.Stderr, "failed to create reporter: %v\n", err) os.Exit(1)