(process *Process, req *criurpc.CriuReq, opts *CriuOpts, extraFiles []*os.File)
| 901 | } |
| 902 | |
| 903 | func (c *Container) criuSwrk(process *Process, req *criurpc.CriuReq, opts *CriuOpts, extraFiles []*os.File) error { |
| 904 | fds, err := unix.Socketpair(unix.AF_LOCAL, unix.SOCK_SEQPACKET|unix.SOCK_CLOEXEC, 0) |
| 905 | if err != nil { |
| 906 | return err |
| 907 | } |
| 908 | |
| 909 | criuClient := os.NewFile(uintptr(fds[0]), "criu-transport-client") |
| 910 | criuClientFileCon, err := net.FileConn(criuClient) |
| 911 | criuClient.Close() |
| 912 | if err != nil { |
| 913 | return err |
| 914 | } |
| 915 | |
| 916 | criuClientCon := criuClientFileCon.(*net.UnixConn) |
| 917 | defer criuClientCon.Close() |
| 918 | |
| 919 | criuServer := os.NewFile(uintptr(fds[1]), "criu-transport-server") |
| 920 | defer criuServer.Close() |
| 921 | |
| 922 | if c.criuVersion != 0 { |
| 923 | // If the CRIU Version is still '0' then this is probably |
| 924 | // the initial CRIU run to detect the version. Skip it. |
| 925 | logrus.Debugf("Using CRIU %d", c.criuVersion) |
| 926 | } |
| 927 | cmd := exec.Command("criu", "swrk", "3") |
| 928 | if process != nil { |
| 929 | cmd.Stdin = process.Stdin |
| 930 | cmd.Stdout = process.Stdout |
| 931 | cmd.Stderr = process.Stderr |
| 932 | } |
| 933 | cmd.ExtraFiles = append(cmd.ExtraFiles, criuServer) |
| 934 | if extraFiles != nil { |
| 935 | cmd.ExtraFiles = append(cmd.ExtraFiles, extraFiles...) |
| 936 | } |
| 937 | |
| 938 | if err := cmd.Start(); err != nil { |
| 939 | return err |
| 940 | } |
| 941 | // we close criuServer so that even if CRIU crashes or unexpectedly exits, runc will not hang. |
| 942 | criuServer.Close() |
| 943 | // cmd.Process will be replaced by a restored init. |
| 944 | criuProcess := cmd.Process |
| 945 | |
| 946 | var criuProcessState *os.ProcessState |
| 947 | defer func() { |
| 948 | if criuProcessState == nil { |
| 949 | criuClientCon.Close() |
| 950 | _, err := criuProcess.Wait() |
| 951 | if err != nil { |
| 952 | logrus.Warnf("wait on criuProcess returned %v", err) |
| 953 | } |
| 954 | } |
| 955 | }() |
| 956 | |
| 957 | if err := c.criuApplyCgroups(criuProcess.Pid, req); err != nil { |
| 958 | return err |
| 959 | } |
| 960 |
no test coverage detected