syzkaller/vm/vm.go

42 lines
842 B
Go
Raw Normal View History

2015-10-12 08:16:57 +00:00
// Copyright 2015 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
package vm
import (
"fmt"
"regexp"
2015-10-12 08:16:57 +00:00
)
type Instance interface {
Run()
}
type Config struct {
2015-10-19 10:53:24 +00:00
Workdir string
ManagerPort int
Params []byte
EnabledSyscalls string
Suppressions []*regexp.Regexp
2015-10-19 12:00:20 +00:00
NoCover bool
NoDropPrivs bool
Leak bool
Procs int
}
type ctorFunc func(cfg *Config, index int) (Instance, error)
2015-10-12 08:16:57 +00:00
var ctors = make(map[string]ctorFunc)
func Register(typ string, ctor ctorFunc) {
ctors[typ] = ctor
}
func Create(typ string, cfg *Config, index int) (Instance, error) {
2015-10-12 08:16:57 +00:00
ctor := ctors[typ]
if ctor == nil {
return nil, fmt.Errorf("unknown instance type '%v'", typ)
}
return ctor(cfg, index)
2015-10-12 08:16:57 +00:00
}