cr: wait the criu process properly
Signed-off-by: Andrey Vagin <avagin@openvz.org>
This commit is contained in:
parent
b28fbb20a3
commit
e75d0228cc
|
@ -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 {
|
||||
|
|
|
@ -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) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(data) == 0 {
|
||||
|
|
Loading…
Reference in New Issue