let user to specify the shim name or path

Signed-off-by: mYmNeo <thomassong@tencent.com>
This commit is contained in:
mYmNeo 2016-04-06 14:42:47 +08:00
parent 5e5daf2b33
commit 4eb27a5926
6 changed files with 21 additions and 9 deletions

View file

@ -17,8 +17,6 @@ import (
ocs "github.com/opencontainers/specs/specs-go"
)
var shimBinary = os.Args[0] + "-shim"
func getRootIDs(s *specs.Spec) (int, int, error) {
if s == nil {
return 0, 0, nil
@ -145,7 +143,7 @@ func (c *container) Start(checkpoint string, s Stdio) (Process, error) {
if err := os.Mkdir(processRoot, 0755); err != nil {
return nil, err
}
cmd := exec.Command(shimBinary,
cmd := exec.Command(c.shim,
c.id, c.bundle, c.runtime,
)
cmd.Dir = processRoot
@ -185,7 +183,7 @@ func (c *container) Exec(pid string, pspec specs.ProcessSpec, s Stdio) (pp Proce
c.RemoveProcess(pid)
}
}()
cmd := exec.Command(shimBinary,
cmd := exec.Command(c.shim,
c.id, c.bundle, c.runtime,
)
cmd.Dir = processRoot
@ -219,7 +217,7 @@ func (c *container) startCmd(pid string, cmd *exec.Cmd, p *process) error {
if err := cmd.Start(); err != nil {
if exErr, ok := err.(*exec.Error); ok {
if exErr.Err == exec.ErrNotFound || exErr.Err == os.ErrNotExist {
return fmt.Errorf("%s not installed on system", shimBinary)
return fmt.Errorf("%s not installed on system", c.shim)
}
}
return err