(rpcOpts *criurpc.CriuOpts, extraFiles *[]*os.File)
| 226 | } |
| 227 | |
| 228 | func (c *Container) handleRestoringNamespaces(rpcOpts *criurpc.CriuOpts, extraFiles *[]*os.File) error { |
| 229 | for _, ns := range c.config.Namespaces { |
| 230 | switch ns.Type { |
| 231 | case configs.NEWNET, configs.NEWPID: |
| 232 | // If the container is running in a network or PID namespace and has |
| 233 | // a path to the network or PID namespace configured, we will dump |
| 234 | // that network or PID namespace as an external namespace and we |
| 235 | // will expect that the namespace exists during restore. |
| 236 | // This basically means that CRIU will ignore the namespace |
| 237 | // and expect it to be setup correctly. |
| 238 | if err := c.handleRestoringExternalNamespaces(rpcOpts, extraFiles, ns.Type); err != nil { |
| 239 | return err |
| 240 | } |
| 241 | default: |
| 242 | // For all other namespaces except NET and PID CRIU has |
| 243 | // a simpler way of joining the existing namespace if set |
| 244 | nsPath := c.config.Namespaces.PathOf(ns.Type) |
| 245 | if nsPath == "" { |
| 246 | continue |
| 247 | } |
| 248 | if ns.Type == configs.NEWCGROUP { |
| 249 | // CRIU has no code to handle NEWCGROUP |
| 250 | return fmt.Errorf("Do not know how to handle namespace %v", ns.Type) |
| 251 | } |
| 252 | // CRIU has code to handle NEWTIME, but it does not seem to be defined in runc |
| 253 | |
| 254 | // CRIU will issue a warning for NEWUSER: |
| 255 | // criu/namespaces.c: 'join-ns with user-namespace is not fully tested and dangerous' |
| 256 | rpcOpts.JoinNs = append(rpcOpts.JoinNs, &criurpc.JoinNamespace{ |
| 257 | Ns: mkPtr(configs.NsName(ns.Type)), |
| 258 | NsFile: mkPtr(nsPath), |
| 259 | }) |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | return nil |
| 264 | } |
| 265 | |
| 266 | func (c *Container) handleRestoringExternalNamespaces(rpcOpts *criurpc.CriuOpts, extraFiles *[]*os.File, t configs.NamespaceType) error { |
| 267 | if !c.criuSupportsExtNS(t) { |
no test coverage detected