diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-09-11 15:33:45 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-09-11 15:33:45 +0200 |
| commit | a54c2b7b920e69215f16cd02bb95957902ab1541 (patch) | |
| tree | 639d5554879f3e475fc806cffa5608f9cfa630fd /vm/vmimpl/vmimpl.go | |
| parent | 472947468d9571f86c2fde301a04478f22b3544b (diff) | |
syz-ci: de-hardcode list of VMs that support overcommit
We currently have this list in multiple places (somewhat diverged).
Specify this "overcommit" property in VM implementations.
In particular, we also want to allow overcommit for "vmm" type.
Update #712
Diffstat (limited to 'vm/vmimpl/vmimpl.go')
| -rw-r--r-- | vm/vmimpl/vmimpl.go | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/vm/vmimpl/vmimpl.go b/vm/vmimpl/vmimpl.go index 7d3411ee9..e9ac59dd6 100644 --- a/vm/vmimpl/vmimpl.go +++ b/vm/vmimpl/vmimpl.go @@ -81,30 +81,29 @@ func (err BootError) BootError() (string, []byte) { return err.Title, err.Output } -// Create creates a VM type that can be used to create individual VMs. -func Create(typ string, env *Env) (Pool, error) { - ctor := ctors[typ] - if ctor == nil { - return nil, fmt.Errorf("unknown instance type '%v'", typ) +// Register registers a new VM type within the package. +func Register(typ string, ctor ctorFunc, allowsOvercommit bool) { + Types[typ] = Type{ + Ctor: ctor, + Overcommit: allowsOvercommit, } - return ctor(env) } -// Register registers a new VM type within the package. -func Register(typ string, ctor ctorFunc) { - ctors[typ] = ctor +type Type struct { + Ctor ctorFunc + Overcommit bool } +type ctorFunc func(env *Env) (Pool, error) + var ( // Close to interrupt all pending operations in all VMs. Shutdown = make(chan struct{}) ErrTimeout = errors.New("timeout") - ctors = make(map[string]ctorFunc) + Types = make(map[string]Type) ) -type ctorFunc func(env *Env) (Pool, error) - func Multiplex(cmd *exec.Cmd, merger *OutputMerger, console io.Closer, timeout time.Duration, stop, closed <-chan bool, debug bool) (<-chan []byte, <-chan error, error) { errc := make(chan error, 1) |
