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

Commit

Permalink
cr: wait the criu process properly
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Vagin <[email protected]>
  • Loading branch information
avagin authored and crosbymichael committed Apr 3, 2015
1 parent 41a90af commit 753c326
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
11 changes: 11 additions & 0 deletions container_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,21 @@ func (c *linuxContainer) Restore(process *Process) error {
if err := cmd.Start(); err != nil {
return err
}

// cmd.Wait() waits cmd.goroutines which are used for proxying file descriptors.
// Here we want to wait only the CRIU process.
st, err := cmd.Process.Wait()
if err != nil {
return err
}
if !st.Success() {
return fmt.Errorf("criu failed: %s", st.String())
}
r, err := newRestoredProcess(pidfile, cmd)
if err != nil {
return err
}

// TODO: crosbymichael restore previous process information by saving the init process information in
// the conatiner's state file or separate process state files.
if err := c.updateState(r); err != nil {
Expand Down
18 changes: 2 additions & 16 deletions restored_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"os"
"os/exec"
"strconv"
"time"

"github.com/docker/libcontainer/system"
)
Expand All @@ -18,21 +17,8 @@ func newRestoredProcess(pidfile string, criuCommand *exec.Cmd) (*restoredProcess
data []byte
err error
)
// XXX The loop below should be replaced by a wait
// on CRIU to complete. See the comment at the
// begining of Restore() in "container_linux.go.
for i := 0; i < 20; i++ {
data, err = ioutil.ReadFile(pidfile)
if err == nil {
break
}
if !os.IsNotExist(err) {
return nil, err
}
time.Sleep(100 * time.Millisecond)
}
// Did CRIU fail?
if os.IsNotExist(err) {
data, err = ioutil.ReadFile(pidfile)
if err != nil {
return nil, err
}
if len(data) == 0 {
Expand Down

0 comments on commit 753c326

Please sign in to comment.