code: func WithCgroups(daemon *Daemon, c *container.Container) coci.SpecOpts {
  	return func(ctx context.Context, _ coci.Client, _ *containers.Container, s *coci.Spec) error {
  		var cgroupsPath string
  		scopePrefix := "docker"
  		parent := "/docker"
  		useSystemd := UsingSystemd(daemon.configStore)
  		if useSystemd {
  			parent = "system.slice"
  		}
  
  		if c.HostConfig.CgroupParent != "" {
  			parent = c.HostConfig.CgroupParent
  		} else if daemon.configStore.CgroupParent != "" {
  			parent = daemon.configStore.CgroupParent
  		}
  
  		if useSystemd {
  			cgroupsPath = parent + ":" + scopePrefix + ":" + c.ID
  			logrus.Debugf("createSpec: cgroupsPath: %s", cgroupsPath)
  		} else {
  			cgroupsPath = filepath.Join(parent, c.ID)
  		}
  		s.Linux.CgroupsPath = cgroupsPath
  		p := cgroupsPath
  		if useSystemd {
  			initPath, err := cgroups.GetInitCgroup("cpu")
  			if err != nil {
  				return err
  			}
  			_, err = cgroups.GetOwnCgroup("cpu")
  			if err != nil {
  				return err
  			}
  			p = filepath.Join(initPath, s.Linux.CgroupsPath)
  		}
  
  		// Clean path to guard against things like ../../../BAD
  		parentPath := filepath.Dir(p)
  		if !filepath.IsAbs(parentPath) {
  			parentPath = filepath.Clean("/" + parentPath)
  		}
  
  		if err := daemon.initCgroupsPath(parentPath); err != nil {
  			return fmt.Errorf("linux init cgroups path: %v", err)
  		}
  		return nil
  	}
  }
docs: // WithCgroups sets the container's cgroups