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 {
|
if err := cmd.Start(); err != nil {
|
||||||
return err
|
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)
|
r, err := newRestoredProcess(pidfile, cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: crosbymichael restore previous process information by saving the init process information in
|
// TODO: crosbymichael restore previous process information by saving the init process information in
|
||||||
// the conatiner's state file or separate process state files.
|
// the conatiner's state file or separate process state files.
|
||||||
if err := c.updateState(r); err != nil {
|
if err := c.updateState(r); err != nil {
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/docker/libcontainer/system"
|
"github.com/docker/libcontainer/system"
|
||||||
)
|
)
|
||||||
|
@ -18,21 +17,8 @@ func newRestoredProcess(pidfile string, criuCommand *exec.Cmd) (*restoredProcess
|
||||||
data []byte
|
data []byte
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
// XXX The loop below should be replaced by a wait
|
data, err = ioutil.ReadFile(pidfile)
|
||||||
// on CRIU to complete. See the comment at the
|
if err != nil {
|
||||||
// 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) {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
|
|
Loading…
Reference in New Issue