(resp *criurpc.CriuResp, process *Process, cmd *exec.Cmd, opts *CriuOpts, fds []string, oob []byte)
| 1109 | } |
| 1110 | |
| 1111 | func (c *Container) criuNotifications(resp *criurpc.CriuResp, process *Process, cmd *exec.Cmd, opts *CriuOpts, fds []string, oob []byte) error { |
| 1112 | notify := resp.GetNotify() |
| 1113 | if notify == nil { |
| 1114 | return fmt.Errorf("invalid response: %s", resp.String()) |
| 1115 | } |
| 1116 | script := notify.GetScript() |
| 1117 | logrus.Debugf("notify: %s\n", script) |
| 1118 | switch script { |
| 1119 | case "post-dump": |
| 1120 | f, err := os.Create(filepath.Join(c.stateDir, "checkpoint")) //nolint:forbidigo // this is a host-side operation in a runc-controlled directory |
| 1121 | if err != nil { |
| 1122 | return err |
| 1123 | } |
| 1124 | f.Close() |
| 1125 | case "network-unlock": |
| 1126 | if err := unlockNetwork(c.config); err != nil { |
| 1127 | return err |
| 1128 | } |
| 1129 | case "network-lock": |
| 1130 | if err := lockNetwork(c.config); err != nil { |
| 1131 | return err |
| 1132 | } |
| 1133 | case "setup-namespaces": |
| 1134 | if c.config.HasHook(configs.Prestart, configs.CreateRuntime) { |
| 1135 | s, err := c.currentOCIState() |
| 1136 | if err != nil { |
| 1137 | return nil |
| 1138 | } |
| 1139 | s.Pid = int(notify.GetPid()) |
| 1140 | |
| 1141 | if err := c.config.Hooks.Run(configs.Prestart, s); err != nil { |
| 1142 | return err |
| 1143 | } |
| 1144 | if err := c.config.Hooks.Run(configs.CreateRuntime, s); err != nil { |
| 1145 | return err |
| 1146 | } |
| 1147 | } |
| 1148 | case "post-restore": |
| 1149 | pid := notify.GetPid() |
| 1150 | |
| 1151 | p, err := os.FindProcess(int(pid)) |
| 1152 | if err != nil { |
| 1153 | return err |
| 1154 | } |
| 1155 | cmd.Process = p |
| 1156 | |
| 1157 | r, err := newRestoredProcess(cmd, fds) |
| 1158 | if err != nil { |
| 1159 | return err |
| 1160 | } |
| 1161 | process.ops = r |
| 1162 | if err := c.state.transition(&restoredState{ |
| 1163 | imageDir: opts.ImagesDirectory, |
| 1164 | c: c, |
| 1165 | }); err != nil { |
| 1166 | return err |
| 1167 | } |
| 1168 | // create a timestamp indicating when the restored checkpoint was started |
no test coverage detected