(rpcOpts *criurpc.CriuOpts, extraFiles *[]*os.File, t configs.NamespaceType)
| 264 | } |
| 265 | |
| 266 | func (c *Container) handleRestoringExternalNamespaces(rpcOpts *criurpc.CriuOpts, extraFiles *[]*os.File, t configs.NamespaceType) error { |
| 267 | if !c.criuSupportsExtNS(t) { |
| 268 | return fmt.Errorf("criu lacks support for external %s namespace during the restoration process (old criu version?)", configs.NsName(t)) |
| 269 | } |
| 270 | |
| 271 | nsPath := c.config.Namespaces.PathOf(t) |
| 272 | if nsPath == "" { |
| 273 | return nil |
| 274 | } |
| 275 | // CRIU wants the information about an existing namespace |
| 276 | // like this: --inherit-fd fd[<fd>]:<key> |
| 277 | // The <key> needs to be the same as during checkpointing. |
| 278 | // We are always using 'extRoot<TYPE>NS' as the key in this. |
| 279 | nsFd, err := os.Open(nsPath) |
| 280 | if err != nil { |
| 281 | logrus.Errorf("If a specific network namespace is defined it must exist: %s", err) |
| 282 | return fmt.Errorf("Requested network namespace %v does not exist", nsPath) |
| 283 | } |
| 284 | inheritFd := &criurpc.InheritFd{ |
| 285 | Key: mkPtr(criuNsToKey(t)), |
| 286 | // The offset of four is necessary because 0, 1, 2 and 3 are |
| 287 | // already used by stdin, stdout, stderr, 'criu swrk' socket. |
| 288 | Fd: mkPtr(int32(4 + len(*extraFiles))), |
| 289 | } |
| 290 | rpcOpts.InheritFd = append(rpcOpts.InheritFd, inheritFd) |
| 291 | // All open FDs need to be transferred to CRIU via extraFiles |
| 292 | *extraFiles = append(*extraFiles, nsFd) |
| 293 | |
| 294 | return nil |
| 295 | } |
| 296 | |
| 297 | func (c *Container) Checkpoint(criuOpts *CriuOpts) error { |
| 298 | const logFile = "dump.log" |
no test coverage detected