Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Commit

Permalink
cr: check criu version
Browse files Browse the repository at this point in the history
CRIU version must be 1.5.1 or higher

Signed-off-by: Andrey Vagin <[email protected]>
  • Loading branch information
avagin committed Apr 2, 2015
1 parent ee020f8 commit 37b1275
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions container_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,34 @@ func addArgsFromEnv(evar string, args *[]string) {
fmt.Printf(">>> criu %v\n", *args)
}

func (c *linuxContainer) checkCriuVersion() error {
var x, y, z int

out, err := exec.Command(c.criuPath, "-V").Output()
if err != nil {
return err
}

n, err := fmt.Sscanf(string(out), "Version: %d.%d.%d", &x, &y, &z)
if n < 2 || err != nil {
return fmt.Errorf("Unable to parse the CRIU version: %s", out)
}

if x*10000+y*100+z < 10501 {
return fmt.Errorf("CRIU version must be 1.5.1 or higher")
}

return nil
}

func (c *linuxContainer) Checkpoint() error {
c.m.Lock()
defer c.m.Unlock()

if err := c.checkCriuVersion(); err != nil {
return err
}

dir := filepath.Join(c.root, "checkpoint")
// Since a container can be C/R'ed multiple times,
// the checkpoint directory may already exist.
Expand Down Expand Up @@ -305,6 +330,10 @@ func (c *linuxContainer) Restore(process *Process) error {
c.m.Lock()
defer c.m.Unlock()

if err := c.checkCriuVersion(); err != nil {
return err
}

pidfile := filepath.Join(c.root, "restoredpid")
// Make sure pidfile doesn't already exist from a
// previous restore. Otherwise, CRIU will fail.
Expand Down

0 comments on commit 37b1275

Please sign in to comment.