Skip to content

Commit

Permalink
use criu cgroup mode const from go-criu
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaodong Liu <[email protected]>
  • Loading branch information
XiaodongLoong committed Aug 10, 2020
1 parent a340fa9 commit 7f64fb4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
7 changes: 4 additions & 3 deletions checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strconv"
"strings"

criu "github.com/checkpoint-restore/go-criu/v4/rpc"
"github.com/opencontainers/runc/libcontainer"
"github.com/opencontainers/runc/libcontainer/system"
"github.com/opencontainers/runtime-spec/specs-go"
Expand Down Expand Up @@ -109,11 +110,11 @@ func setManageCgroupsMode(context *cli.Context, options *libcontainer.CriuOpts)
if cgOpt := context.String("manage-cgroups-mode"); cgOpt != "" {
switch cgOpt {
case "soft":
options.ManageCgroupsMode = libcontainer.CRIU_CG_MODE_SOFT
options.ManageCgroupsMode = criu.CriuCgMode_SOFT
case "full":
options.ManageCgroupsMode = libcontainer.CRIU_CG_MODE_FULL
options.ManageCgroupsMode = criu.CriuCgMode_FULL
case "strict":
options.ManageCgroupsMode = libcontainer.CRIU_CG_MODE_STRICT
options.ManageCgroupsMode = criu.CriuCgMode_STRICT
default:
fatal(errors.New("Invalid manage cgroups mode"))
}
Expand Down
12 changes: 2 additions & 10 deletions libcontainer/criu_opts_linux.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
package libcontainer

// cgroup restoring strategy provided by criu
type cgMode uint32

const (
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
)
import criu "github.com/checkpoint-restore/go-criu/v4/rpc"

type CriuPageServerInfo struct {
Address string // IP address of CRIU page server
Expand All @@ -32,7 +24,7 @@ type CriuOpts struct {
PreDump bool // call criu predump to perform iterative checkpoint
PageServer CriuPageServerInfo // allow to dump to criu page server
VethPairs []VethPairName // pass the veth to criu when restore
ManageCgroupsMode cgMode // dump or restore cgroup mode
ManageCgroupsMode criu.CriuCgMode // dump or restore cgroup mode
EmptyNs uint32 // don't c/r properties for namespace from this mask
AutoDedup bool // auto deduplication for incremental dumps
LazyPages bool // restore memory pages lazily using userfaultfd
Expand Down

0 comments on commit 7f64fb4

Please sign in to comment.