diff --git a/container_linux.go b/container_linux.go index 137ac7ef8..d1302f7c8 100644 --- a/container_linux.go +++ b/container_linux.go @@ -298,15 +298,20 @@ func (c *linuxContainer) Checkpoint() error { return err } - dir := filepath.Join(c.root, "checkpoint") + imagePath := filepath.Join(c.root, "checkpoint") // Since a container can be C/R'ed multiple times, // the checkpoint directory may already exist. - if err := os.Mkdir(dir, 0655); err != nil && !os.IsExist(err) { + if err := os.Mkdir(imagePath, 0655); err != nil && !os.IsExist(err) { + return err + } + workPath := filepath.Join(c.root, "criu.work") + if err := os.Mkdir(workPath, 0655); err != nil && !os.IsExist(err) { return err } args := []string{ "dump", "-v4", - "-D", dir, + "--images-dir", imagePath, + "--work-dir", workPath, "-o", "dump.log", "--root", c.config.Rootfs, "--manage-cgroups", "--evasive-devices", @@ -351,6 +356,18 @@ func (c *linuxContainer) Restore(process *Process) error { defer criuClt.Close() defer criuSrv.Close() + workPath := filepath.Join(c.root, "criu.work") + // Since a container can be C/R'ed multiple times, + // the work directory may already exist. + if err := os.Mkdir(workPath, 0655); err != nil && !os.IsExist(err) { + return err + } + workDir, err := os.Open(workPath) + if err != nil { + return err + } + defer workDir.Close() + imagePath := filepath.Join(c.root, "checkpoint") imageDir, err := os.Open(imagePath) if err != nil { @@ -362,6 +379,7 @@ func (c *linuxContainer) Restore(process *Process) error { Type: &t, Opts: &criurpc.CriuOpts{ ImagesDirFd: proto.Int32(int32(imageDir.Fd())), + WorkDirFd: proto.Int32(int32(workDir.Fd())), EvasiveDevices: proto.Bool(true), LogLevel: proto.Int32(4), LogFile: proto.String("restore.log"),