libct: initialize inheritFD in place

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin 2020-07-31 17:55:09 -07:00
parent 8b973997a4
commit e54d1e4715
1 changed files with 6 additions and 5 deletions

View File

@ -896,11 +896,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(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)