cr: check criu version
CRIU version must be 1.5.1 or higher Signed-off-by: Andrey Vagin <avagin@openvz.org>
This commit is contained in:
parent
b836046422
commit
e0f87e2f23
|
@ -275,9 +275,34 @@ func addArgsFromEnv(evar string, args *[]string) {
|
||||||
fmt.Printf(">>> criu %v\n", *args)
|
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 {
|
func (c *linuxContainer) Checkpoint() error {
|
||||||
c.m.Lock()
|
c.m.Lock()
|
||||||
defer c.m.Unlock()
|
defer c.m.Unlock()
|
||||||
|
|
||||||
|
if err := c.checkCriuVersion(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
dir := filepath.Join(c.root, "checkpoint")
|
dir := filepath.Join(c.root, "checkpoint")
|
||||||
// Since a container can be C/R'ed multiple times,
|
// Since a container can be C/R'ed multiple times,
|
||||||
// the checkpoint directory may already exist.
|
// the checkpoint directory may already exist.
|
||||||
|
@ -310,6 +335,10 @@ func (c *linuxContainer) Restore(process *Process) error {
|
||||||
c.m.Lock()
|
c.m.Lock()
|
||||||
defer c.m.Unlock()
|
defer c.m.Unlock()
|
||||||
|
|
||||||
|
if err := c.checkCriuVersion(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
pidfile := filepath.Join(c.root, "restoredpid")
|
pidfile := filepath.Join(c.root, "restoredpid")
|
||||||
// Make sure pidfile doesn't already exist from a
|
// Make sure pidfile doesn't already exist from a
|
||||||
// previous restore. Otherwise, CRIU will fail.
|
// previous restore. Otherwise, CRIU will fail.
|
||||||
|
|
Loading…
Reference in New Issue