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

Commit

Permalink
cr: split work and image directories
Browse files Browse the repository at this point in the history
This directory can be removed when criu completes.

Signed-off-by: Andrey Vagin <[email protected]>
  • Loading branch information
avagin committed Apr 2, 2015
1 parent 07dbdd6 commit ce6573b
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions container_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 {
Expand All @@ -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"),
Expand Down

0 comments on commit ce6573b

Please sign in to comment.