aboutsummaryrefslogtreecommitdiffstats
path: root/vm/vmimpl/vmimpl.go
diff options
context:
space:
mode:
Diffstat (limited to 'vm/vmimpl/vmimpl.go')
-rw-r--r--vm/vmimpl/vmimpl.go23
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)