libc/criuSwrk: remove applyCgroups param
Its value can be easily deduced from the request type. While at it, simplify the call logic. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
parent
142d0f2d5d
commit
52b56bc28e
|
@ -703,7 +703,7 @@ func (c *linuxContainer) checkCriuFeatures(criuOpts *CriuOpts, rpcOpts *criurpc.
|
|||
Features: criuFeat,
|
||||
}
|
||||
|
||||
err := c.criuSwrk(nil, req, criuOpts, false, nil)
|
||||
err := c.criuSwrk(nil, req, criuOpts, nil)
|
||||
if err != nil {
|
||||
logrus.Debugf("%s", err)
|
||||
return errors.New("CRIU feature check failed")
|
||||
|
@ -1045,7 +1045,7 @@ func (c *linuxContainer) Checkpoint(criuOpts *CriuOpts) error {
|
|||
}
|
||||
}
|
||||
|
||||
err = c.criuSwrk(nil, req, criuOpts, false, nil)
|
||||
err = c.criuSwrk(nil, req, criuOpts, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -1339,10 +1339,15 @@ func (c *linuxContainer) Restore(process *Process, criuOpts *CriuOpts) error {
|
|||
req.Opts.InheritFd = append(req.Opts.InheritFd, inheritFd)
|
||||
}
|
||||
}
|
||||
return c.criuSwrk(process, req, criuOpts, true, extraFiles)
|
||||
return c.criuSwrk(process, req, criuOpts, extraFiles)
|
||||
}
|
||||
|
||||
func (c *linuxContainer) criuApplyCgroups(pid int, req *criurpc.CriuReq) error {
|
||||
// need to apply cgroups only on restore
|
||||
if req.GetType() != criurpc.CriuReqType_RESTORE {
|
||||
return nil
|
||||
}
|
||||
|
||||
// XXX: Do we need to deal with this case? AFAIK criu still requires root.
|
||||
if err := c.cgroupManager.Apply(pid); err != nil {
|
||||
return err
|
||||
|
@ -1369,7 +1374,7 @@ func (c *linuxContainer) criuApplyCgroups(pid int, req *criurpc.CriuReq) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *linuxContainer) criuSwrk(process *Process, req *criurpc.CriuReq, opts *CriuOpts, applyCgroups bool, extraFiles []*os.File) error {
|
||||
func (c *linuxContainer) criuSwrk(process *Process, req *criurpc.CriuReq, opts *CriuOpts, extraFiles []*os.File) error {
|
||||
fds, err := unix.Socketpair(unix.AF_LOCAL, unix.SOCK_SEQPACKET|unix.SOCK_CLOEXEC, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -1433,11 +1438,8 @@ func (c *linuxContainer) criuSwrk(process *Process, req *criurpc.CriuReq, opts *
|
|||
}
|
||||
}()
|
||||
|
||||
if applyCgroups {
|
||||
err := c.criuApplyCgroups(criuProcess.Pid, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := c.criuApplyCgroups(criuProcess.Pid, req); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var extFds []string
|
||||
|
|
Loading…
Reference in New Issue