cr: wait the criu process properly

Signed-off-by: Andrey Vagin <avagin@openvz.org>
This commit is contained in:
Andrey Vagin 2015-03-25 16:21:44 +03:00 committed by Michael Crosby
parent b28fbb20a3
commit e75d0228cc
2 changed files with 13 additions and 16 deletions

View File

@ -356,10 +356,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 {

View File

@ -8,7 +8,6 @@ import (
"os"
"os/exec"
"strconv"
"time"
"github.com/docker/libcontainer/system"
)
@ -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 {