mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
criuSwrk: prepare for CRIU VERSION RPC
To use the CRIU VERSION RPC the criuSwrk function is adapted to work with CriuOpts set to 'nil' as CriuOpts is not required for the VERSION RPC. Also do not print c.criuVersion if it is '0' as the first RPC call will always be the VERSION call and only after that the version will be known. Signed-off-by: Adrian Reber <areber@redhat.com>
This commit is contained in:
@@ -1059,7 +1059,14 @@ func (c *linuxContainer) criuSwrk(process *Process, req *criurpc.CriuReq, opts *
|
||||
return err
|
||||
}
|
||||
|
||||
logPath := filepath.Join(opts.WorkDirectory, req.GetOpts().GetLogFile())
|
||||
var logPath string
|
||||
if opts != nil {
|
||||
logPath = filepath.Join(opts.WorkDirectory, req.GetOpts().GetLogFile())
|
||||
} else {
|
||||
// For the VERSION RPC 'opts' is set to 'nil' and therefore
|
||||
// opts.WorkDirectory does not exist. Set logPath to "".
|
||||
logPath = ""
|
||||
}
|
||||
criuClient := os.NewFile(uintptr(fds[0]), "criu-transport-client")
|
||||
criuClientFileCon, err := net.FileConn(criuClient)
|
||||
criuClient.Close()
|
||||
@@ -1074,7 +1081,11 @@ func (c *linuxContainer) criuSwrk(process *Process, req *criurpc.CriuReq, opts *
|
||||
defer criuServer.Close()
|
||||
|
||||
args := []string{"swrk", "3"}
|
||||
logrus.Debugf("Using CRIU %d at: %s", c.criuVersion, c.criuPath)
|
||||
if c.criuVersion != 0 {
|
||||
// If the CRIU Version is still '0' then this is probably
|
||||
// the initial CRIU run to detect the version. Skip it.
|
||||
logrus.Debugf("Using CRIU %d at: %s", c.criuVersion, c.criuPath)
|
||||
}
|
||||
logrus.Debugf("Using CRIU with following args: %s", args)
|
||||
cmd := exec.Command(c.criuPath, args...)
|
||||
if process != nil {
|
||||
|
||||
Reference in New Issue
Block a user