Allow dumped image to be transferred to a criu page server

--page-server to specify the IP address of criu page server
--port to specify the port of the criu page server

Docker-DCO-1.1-Signed-off-by: Hui Kang <hkang.sunysb@gmail.com>
This commit is contained in:
root 2015-04-23 20:16:47 +00:00 committed by Michael Crosby
parent 4fc7543317
commit 7a012fe3b5
3 changed files with 48 additions and 9 deletions

View File

@ -340,6 +340,14 @@ func (c *linuxContainer) Checkpoint(criuOpts *CriuOpts) error {
ExtUnixSk: proto.Bool(criuOpts.ExternalUnixConnections),
}
// append optional criu opts, e.g., page-server and port
if criuOpts.Ps.Address != "" && criuOpts.Ps.Port != 0 {
rpcOpts.Ps = &criurpc.CriuPageServerInfo{
Address: proto.String(criuOpts.Ps.Address),
Port: proto.Int32(criuOpts.Ps.Port),
}
}
t := criurpc.CriuReqType_DUMP
req := criurpc.CriuReq{
Type: &t,

View File

@ -1,10 +1,16 @@
package libcontainer
type CriuOpts struct {
ImagesDirectory string // directory for storing image files
WorkDirectory string // directory to cd and write logs/pidfiles/stats to
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
type CriuPageServerInfo struct {
Address string // IP address of CRIU page server
Port int32 // port number of CRIU page server
}
type CriuOpts struct {
ImagesDirectory string // directory for storing image files
WorkDirectory string // directory to cd and write logs/pidfiles/stats to
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
Ps *CriuPageServerInfo // allow to dump to criu page server
}

View File

@ -2,6 +2,7 @@ package main
import (
"fmt"
"strconv"
"github.com/codegangsta/cli"
"github.com/docker/libcontainer"
)
@ -17,6 +18,8 @@ var checkpointCommand = cli.Command{
cli.BoolFlag{Name: "tcp-established", Usage: "allow open tcp connections"},
cli.BoolFlag{Name: "ext-unix-sk", Usage: "allow external unix sockets"},
cli.BoolFlag{Name: "shell-job", Usage: "allow shell jobs"},
cli.StringFlag{Name: "page-server", Value: "", Usage: "IP address of the page server"},
cli.StringFlag{Name: "port", Value: "", Usage: "port number of the page server"},
},
Action: func(context *cli.Context) {
imagePath := context.String("image-path")
@ -28,14 +31,36 @@ var checkpointCommand = cli.Command{
if err != nil {
fatal(err)
}
if err := container.Checkpoint(&libcontainer.CriuOpts{
// these are the mandatory criu options for a container
criuOpts := &libcontainer.CriuOpts{
ImagesDirectory: imagePath,
WorkDirectory: context.String("work-path"),
LeaveRunning: context.Bool("leave-running"),
TcpEstablished: context.Bool("tcp-established"),
ExternalUnixConnections: context.Bool("ext-unix-sk"),
ShellJob: context.Bool("shell-job"),
}); err != nil {
}
// xxx following criu opts are optional
// The dump image can be sent to a criu page server
var port string
if psAddress := context.String("page-server"); psAddress != "" {
if port = context.String("port"); port == "" {
fatal(fmt.Errorf("The --port number isn't specified"))
}
port_int, err := strconv.Atoi(port)
if err != nil {
fatal(fmt.Errorf("Invalid port number"))
}
criuOpts.Ps = &libcontainer.CriuPageServerInfo{
Address: psAddress,
Port: int32(port_int),
}
}
if err := container.Checkpoint(criuOpts); err != nil {
fatal(err)
}
},