2015-04-19 09:28:40 +08:00
|
|
|
package libcontainer
|
|
|
|
|
2015-08-06 23:14:59 +08:00
|
|
|
// cgroup restoring strategy provided by criu
|
2016-04-12 16:12:23 +08:00
|
|
|
type cgMode uint32
|
2015-08-06 23:14:59 +08:00
|
|
|
|
|
|
|
const (
|
2016-04-12 16:12:23 +08:00
|
|
|
CRIU_CG_MODE_SOFT cgMode = 3 + iota // restore cgroup properties if only dir created by criu
|
|
|
|
CRIU_CG_MODE_FULL // always restore all cgroups and their properties
|
|
|
|
CRIU_CG_MODE_STRICT // restore all, requiring them to not present in the system
|
|
|
|
CRIU_CG_MODE_DEFAULT // the same as CRIU_CG_MODE_SOFT
|
2015-08-06 23:14:59 +08:00
|
|
|
)
|
|
|
|
|
2015-04-24 04:16:47 +08:00
|
|
|
type CriuPageServerInfo struct {
|
|
|
|
Address string // IP address of CRIU page server
|
|
|
|
Port int32 // port number of CRIU page server
|
|
|
|
}
|
|
|
|
|
2015-08-25 00:26:39 +08:00
|
|
|
type VethPairName struct {
|
|
|
|
ContainerInterfaceName string
|
|
|
|
HostInterfaceName string
|
|
|
|
}
|
|
|
|
|
2015-04-19 09:28:40 +08:00
|
|
|
type CriuOpts struct {
|
2015-04-24 23:13:15 +08:00
|
|
|
ImagesDirectory string // directory for storing image files
|
|
|
|
WorkDirectory string // directory to cd and write logs/pidfiles/stats to
|
2017-12-05 14:26:25 +08:00
|
|
|
ParentImage string // directory for storing parent image files in pre-dump and dump
|
2015-04-24 23:13:15 +08:00
|
|
|
LeaveRunning bool // leave container in running state after checkpoint
|
|
|
|
TcpEstablished bool // checkpoint/restore established TCP connections
|
|
|
|
ExternalUnixConnections bool // allow external unix connections
|
|
|
|
ShellJob bool // allow to dump and restore shell jobs
|
2015-06-27 17:56:24 +08:00
|
|
|
FileLocks bool // handle file locks, for safety
|
2016-08-24 17:48:56 +08:00
|
|
|
PreDump bool // call criu predump to perform iterative checkpoint
|
2015-04-24 23:13:15 +08:00
|
|
|
PageServer CriuPageServerInfo // allow to dump to criu page server
|
2015-08-25 00:26:39 +08:00
|
|
|
VethPairs []VethPairName // pass the veth to criu when restore
|
2016-04-12 16:12:23 +08:00
|
|
|
ManageCgroupsMode cgMode // dump or restore cgroup mode
|
2016-02-19 06:17:04 +08:00
|
|
|
EmptyNs uint32 // don't c/r properties for namespace from this mask
|
2017-08-18 06:31:49 +08:00
|
|
|
AutoDedup bool // auto deduplication for incremental dumps
|
2017-07-24 23:43:14 +08:00
|
|
|
LazyPages bool // restore memory pages lazily using userfaultfd
|
runc checkpoint: fix --status-fd to accept fd
1. The command `runc checkpoint --lazy-server --status-fd $FD` actually
accepts a file name as an $FD. Make it accept a file descriptor,
like its name implies and the documentation states.
In addition, since runc itself does not use the result of CRIU status
fd, remove the code which relays it, and pass the FD directly to CRIU.
Note 1: runc should close this file descriptor itself after passing it
to criu, otherwise whoever waits on it might wait forever.
Note 2: due to the way criu swrk consumes the fd (it reopens
/proc/$SENDER_PID/fd/$FD), runc can't close it as soon as criu swrk has
started. There is no good way to know when criu swrk has reopened the
fd, so we assume that as soon as we have received something back, the
fd is already reopened.
2. Since the meaning of --status-fd has changed, the test case using
it needs to be fixed as well.
Modify the lazy migration test to remove "sleep 2", actually waiting
for the the lazy page server to be ready.
While at it,
- remove the double fork (using shell's background process is
sufficient here);
- check the exit code for "runc checkpoint" and "criu lazy-pages";
- remove the check for no errors in dump.log after restore, as we
are already checking its exit code.
[v2: properly close status fd after spawning criu]
[v3: move close status fd to after the first read]
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-04-21 17:43:24 +08:00
|
|
|
StatusFd int // fd for feedback when lazy server is ready
|
2015-04-19 09:28:40 +08:00
|
|
|
}
|