mirror of
https://github.com/reactos/syzkaller.git
synced 2024-10-08 09:43:21 +00:00
37 lines
733 B
Go
37 lines
733 B
Go
// 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"
|
|
)
|
|
|
|
type Instance interface {
|
|
Run()
|
|
}
|
|
|
|
type Config struct {
|
|
Workdir string
|
|
ManagerPort int
|
|
Params []byte
|
|
EnabledSyscalls string
|
|
NoCover bool
|
|
}
|
|
|
|
type ctorFunc func(cfg *Config, index int) (Instance, error)
|
|
|
|
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) {
|
|
ctor := ctors[typ]
|
|
if ctor == nil {
|
|
return nil, fmt.Errorf("unknown instance type '%v'", typ)
|
|
}
|
|
return ctor(cfg, index)
|
|
}
|