MCPcopy
hub / github.com/opencontainers/runc / criuApplyCgroups

Method criuApplyCgroups

libcontainer/criu_linux.go:869–901  ·  view source on GitHub ↗
(pid int, req *criurpc.CriuReq)

Source from the content-addressed store, hash-verified

867}
868
869func (c *Container) criuApplyCgroups(pid int, req *criurpc.CriuReq) error {
870 // need to apply cgroups only on restore
871 if req.GetType() != criurpc.CriuReqType_RESTORE {
872 return nil
873 }
874
875 // XXX: Do we need to deal with this case? AFAIK criu still requires root.
876 if err := c.cgroupManager.Apply(pid); err != nil {
877 return err
878 }
879
880 if err := c.cgroupManager.Set(c.config.Cgroups.Resources); err != nil {
881 return err
882 }
883
884 // TODO(@kolyshkin): should we use c.cgroupManager.GetPaths()
885 // instead of reading /proc/pid/cgroup?
886 path := fmt.Sprintf("/proc/%d/cgroup", pid)
887 cgroupsPaths, err := cgroups.ParseCgroupFile(path)
888 if err != nil {
889 return err
890 }
891
892 for c, p := range cgroupsPaths {
893 cgroupRoot := &criurpc.CgroupRoot{
894 Ctrl: mkPtr(c),
895 Path: mkPtr(p),
896 }
897 req.Opts.CgRoot = append(req.Opts.CgRoot, cgroupRoot)
898 }
899
900 return nil
901}
902
903func (c *Container) criuSwrk(process *Process, req *criurpc.CriuReq, opts *CriuOpts, extraFiles []*os.File) error {
904 fds, err := unix.Socketpair(unix.AF_LOCAL, unix.SOCK_SEQPACKET|unix.SOCK_CLOEXEC, 0)

Callers 1

criuSwrkMethod · 0.95

Calls 3

mkPtrFunction · 0.70
ApplyMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected