From a54c2b7b920e69215f16cd02bb95957902ab1541 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 11 Sep 2018 15:33:45 +0200 Subject: 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 --- vm/vmimpl/vmimpl.go | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'vm/vmimpl/vmimpl.go') 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) -- cgit mrf-deployment