diff --git a/linux/runtime.go b/linux/runtime.go index d063db2..9901e85 100644 --- a/linux/runtime.go +++ b/linux/runtime.go @@ -22,23 +22,35 @@ import ( const ( runtimeName = "linux" configFilename = "config.json" + defaultRuntime = "runc" ) func init() { plugin.Register(runtimeName, &plugin.Registration{ - Type: plugin.RuntimePlugin, - Init: New, + Type: plugin.RuntimePlugin, + Init: New, + Config: &Config{}, }) } -func New(ic *plugin.InitContext) (interface{}, error) { +type Config struct { + // Runtime is a path or name of an OCI runtime used by the shim + Runtime string `toml:"runtime"` +} + +func New(ic *containerd.InitContext) (interface{}, error) { path := filepath.Join(ic.State, runtimeName) if err := os.MkdirAll(path, 0700); err != nil { return nil, err } + cfg := ic.Config.(*Config) + if cfg.Runtime == "" { + cfg.Runtime = defaultRuntime + } c, cancel := context.WithCancel(ic.Context) return &Runtime{ root: path, + runtime: cfg.Runtime, events: make(chan *containerd.Event, 2048), eventsContext: c, eventsCancel: cancel, @@ -46,7 +58,8 @@ func New(ic *plugin.InitContext) (interface{}, error) { } type Runtime struct { - root string + root string + runtime string events chan *containerd.Event eventsContext context.Context @@ -70,7 +83,7 @@ func (r *Runtime) Create(ctx context.Context, id string, opts containerd.CreateO sopts := &shim.CreateRequest{ ID: id, Bundle: path, - Runtime: "runc", + Runtime: r.runtime, Stdin: opts.IO.Stdin, Stdout: opts.IO.Stdout, Stderr: opts.IO.Stderr,