Merge pull request #2539 from kolyshkin/ext-pidns-nits
external pidns c/r code nits
This commit is contained in:
commit
9ada2e6d4f
|
@ -853,7 +853,7 @@ func (c *linuxContainer) criuSupportsExtNS(t configs.NamespaceType) bool {
|
||||||
return c.checkCriuVersion(minVersion) == nil
|
return c.checkCriuVersion(minVersion) == nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *linuxContainer) criuNsToKey(t configs.NamespaceType) string {
|
func criuNsToKey(t configs.NamespaceType) string {
|
||||||
return "extRoot" + strings.Title(configs.NsName(t)) + "NS"
|
return "extRoot" + strings.Title(configs.NsName(t)) + "NS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -873,7 +873,7 @@ func (c *linuxContainer) handleCheckpointingExternalNamespaces(rpcOpts *criurpc.
|
||||||
if err := unix.Stat(nsPath, &ns); err != nil {
|
if err := unix.Stat(nsPath, &ns); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
criuExternal := fmt.Sprintf("%s[%d]:%s", configs.NsName(t), ns.Ino, c.criuNsToKey(t))
|
criuExternal := fmt.Sprintf("%s[%d]:%s", configs.NsName(t), ns.Ino, criuNsToKey(t))
|
||||||
rpcOpts.External = append(rpcOpts.External, criuExternal)
|
rpcOpts.External = append(rpcOpts.External, criuExternal)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -897,11 +897,12 @@ func (c *linuxContainer) handleRestoringExternalNamespaces(rpcOpts *criurpc.Criu
|
||||||
logrus.Errorf("If a specific network namespace is defined it must exist: %s", err)
|
logrus.Errorf("If a specific network namespace is defined it must exist: %s", err)
|
||||||
return fmt.Errorf("Requested network namespace %v does not exist", nsPath)
|
return fmt.Errorf("Requested network namespace %v does not exist", nsPath)
|
||||||
}
|
}
|
||||||
inheritFd := new(criurpc.InheritFd)
|
inheritFd := &criurpc.InheritFd{
|
||||||
inheritFd.Key = proto.String(c.criuNsToKey(t))
|
Key: proto.String(criuNsToKey(t)),
|
||||||
// The offset of four is necessary because 0, 1, 2 and 3 is already
|
// The offset of four is necessary because 0, 1, 2 and 3 are
|
||||||
// used by stdin, stdout, stderr, 'criu swrk' socket.
|
// already used by stdin, stdout, stderr, 'criu swrk' socket.
|
||||||
inheritFd.Fd = proto.Int32(int32(4 + len(*extraFiles)))
|
Fd: proto.Int32(int32(4 + len(*extraFiles))),
|
||||||
|
}
|
||||||
rpcOpts.InheritFd = append(rpcOpts.InheritFd, inheritFd)
|
rpcOpts.InheritFd = append(rpcOpts.InheritFd, inheritFd)
|
||||||
// All open FDs need to be transferred to CRIU via extraFiles
|
// All open FDs need to be transferred to CRIU via extraFiles
|
||||||
*extraFiles = append(*extraFiles, nsFd)
|
*extraFiles = append(*extraFiles, nsFd)
|
||||||
|
|
Loading…
Reference in New Issue