aboutsummaryrefslogtreecommitdiffstats
path: root/tools/syz-crush
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-06-02 20:09:00 +0200
committerDmitry Vyukov <dvyukov@google.com>2017-06-03 11:31:42 +0200
commitaf643baa328ae3d4b7076054bba648c4b8bf8056 (patch)
tree6e4687c745b63352dec21f6ac2a6a7d8fa1201c4 /tools/syz-crush
parent96b8d4e99c7812f91633ea6cd1aee5867965e742 (diff)
vm: overhaul
VM infrastructure currently has several problems: - Config struct is complete mess with a superset of params for all VM types - verification of Config is mess spread across several places - there is no place where VM code could do global initialization like creating GCE connection, uploading GCE image to GCS, matching adb devices with consoles, etc - it hard to add private VM implementations such impl would need to add code to config package which would lead to constant merge conflicts - interface for VM implementation is mixed with interface for VM users this does not allow to provide best interface for both of them - there is no way to add common code for all VM implementations This change solves these problems by: - splitting VM interface for users (vm package) and VM interface for VM implementations (vmimpl pacakge), this in turn allows to add common code - adding Pool concept that allows to do global initialization and config checking at the right time - decoupling manager config from VM-specific config each VM type now defines own config Note: manager configs need to be changed after this change: VM-specific parts are moved to own "vm" subobject. Note: this change also drops "local" VM type. Its story was long unclear and there is now syz-stress which solves the same problem.
Diffstat (limited to 'tools/syz-crush')
-rw-r--r--tools/syz-crush/crush.go40
1 files changed, 20 insertions, 20 deletions
diff --git a/tools/syz-crush/crush.go b/tools/syz-crush/crush.go
index 5a785a264..38e7eb8d4 100644
--- a/tools/syz-crush/crush.go
+++ b/tools/syz-crush/crush.go
@@ -21,10 +21,6 @@ import (
. "github.com/google/syzkaller/pkg/log"
"github.com/google/syzkaller/syz-manager/config"
"github.com/google/syzkaller/vm"
- _ "github.com/google/syzkaller/vm/adb"
- _ "github.com/google/syzkaller/vm/gce"
- _ "github.com/google/syzkaller/vm/kvm"
- _ "github.com/google/syzkaller/vm/qemu"
)
var (
@@ -40,24 +36,28 @@ func main() {
if len(flag.Args()) != 1 {
Fatalf("usage: syz-crush -config=config.file execution.log")
}
+ env := &vm.Env{
+ Name: cfg.Name,
+ Workdir: cfg.Workdir,
+ Image: cfg.Image,
+ Debug: false,
+ Config: cfg.VM,
+ }
+ vmPool, err := vm.Create(cfg.Type, env)
+ if err != nil {
+ Fatalf("%v", err)
+ }
Logf(0, "booting test machines...")
var shutdown uint32
var wg sync.WaitGroup
- wg.Add(cfg.Count + 1)
- for i := 0; i < cfg.Count; i++ {
+ wg.Add(vmPool.Count() + 1)
+ for i := 0; i < vmPool.Count(); i++ {
i := i
go func() {
defer wg.Done()
for {
- vmCfg, err := config.CreateVMConfig(cfg, i)
- if atomic.LoadUint32(&shutdown) != 0 {
- break
- }
- if err != nil {
- Fatalf("failed to create VM config: %v", err)
- }
- runInstance(cfg, vmCfg)
+ runInstance(cfg, vmPool, i)
if atomic.LoadUint32(&shutdown) != 0 {
break
}
@@ -80,8 +80,8 @@ func main() {
wg.Wait()
}
-func runInstance(cfg *config.Config, vmCfg *vm.Config) {
- inst, err := vm.Create(cfg.Type, vmCfg)
+func runInstance(cfg *config.Config, vmPool *vm.Pool, index int) {
+ inst, err := vmPool.Create(index)
if err != nil {
Logf(0, "failed to create instance: %v", err)
return
@@ -112,11 +112,11 @@ func runInstance(cfg *config.Config, vmCfg *vm.Config) {
return
}
- Logf(0, "%v: crushing...", vmCfg.Name)
- desc, _, output, crashed, timedout := vm.MonitorExecution(outc, errc, cfg.Type == "local", true, cfg.ParsedIgnores)
+ Logf(0, "vm-%v: crushing...", index)
+ desc, _, output, crashed, timedout := vm.MonitorExecution(outc, errc, true, cfg.ParsedIgnores)
if timedout {
// This is the only "OK" outcome.
- Logf(0, "%v: running long enough, restarting", vmCfg.Name)
+ Logf(0, "vm-%v: running long enough, restarting", index)
} else {
if !crashed {
// syz-execprog exited, but it should not.
@@ -128,7 +128,7 @@ func runInstance(cfg *config.Config, vmCfg *vm.Config) {
return
}
defer f.Close()
- Logf(0, "%v: crashed: %v, saving to %v", vmCfg.Name, desc, f.Name())
+ Logf(0, "vm-%v: crashed: %v, saving to %v", index, desc, f.Name())
f.Write(output)
}
return