From da4a5a9515eeb213484b7fcea1c1d54a8be080e8 Mon Sep 17 00:00:00 2001 From: Nikolas Sepos Date: Fri, 18 Aug 2017 00:31:49 +0200 Subject: [PATCH 1/2] Add AutoDedup option to CriuOpts Memory image deduplication, very useful for incremental dumps. See: https://criu.org/Memory_images_deduplication Signed-off-by: Nikolas Sepos --- libcontainer/container_linux.go | 2 ++ libcontainer/criu_opts_linux.go | 1 + 2 files changed, 3 insertions(+) diff --git a/libcontainer/container_linux.go b/libcontainer/container_linux.go index cbdfe0d5c..186faab0c 100644 --- a/libcontainer/container_linux.go +++ b/libcontainer/container_linux.go @@ -811,6 +811,7 @@ func (c *linuxContainer) Checkpoint(criuOpts *CriuOpts) error { FileLocks: proto.Bool(criuOpts.FileLocks), EmptyNs: proto.Uint32(criuOpts.EmptyNs), OrphanPtsMaster: proto.Bool(true), + AutoDedup: proto.Bool(criuOpts.AutoDedup), } fcg := c.cgroupManager.GetPaths()["freezer"] @@ -1012,6 +1013,7 @@ func (c *linuxContainer) Restore(process *Process, criuOpts *CriuOpts) error { FileLocks: proto.Bool(criuOpts.FileLocks), EmptyNs: proto.Uint32(criuOpts.EmptyNs), OrphanPtsMaster: proto.Bool(true), + AutoDedup: proto.Bool(criuOpts.AutoDedup), }, } diff --git a/libcontainer/criu_opts_linux.go b/libcontainer/criu_opts_linux.go index 9423d2464..8f142c9fa 100644 --- a/libcontainer/criu_opts_linux.go +++ b/libcontainer/criu_opts_linux.go @@ -34,4 +34,5 @@ type CriuOpts struct { VethPairs []VethPairName // pass the veth to criu when restore ManageCgroupsMode cgMode // dump or restore cgroup mode EmptyNs uint32 // don't c/r properties for namespace from this mask + AutoDedup bool // auto deduplication for incremental dumps } From 3f234b15d035e5509df9449f00b65115819612e8 Mon Sep 17 00:00:00 2001 From: Nikolas Sepos Date: Fri, 18 Aug 2017 16:19:21 +0200 Subject: [PATCH 2/2] Add auto-dedup flag for checkpoint/restore When doing incremental dumps is useful to use auto deduplication of memory images to save space. Signed-off-by: Nikolas Sepos --- checkpoint.go | 1 + restore.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/checkpoint.go b/checkpoint.go index 788f33475..d62816b77 100644 --- a/checkpoint.go +++ b/checkpoint.go @@ -35,6 +35,7 @@ checkpointed.`, cli.BoolFlag{Name: "pre-dump", Usage: "dump container's memory information only, leave the container running after this"}, cli.StringFlag{Name: "manage-cgroups-mode", Value: "", Usage: "cgroups mode: 'soft' (default), 'full' and 'strict'"}, cli.StringSliceFlag{Name: "empty-ns", Usage: "create a namespace, but don't restore its properties"}, + cli.BoolFlag{Name: "auto-dedup", Usage: "enable auto deduplication of memory images"}, }, Action: func(context *cli.Context) error { if err := checkArgs(context, 1, exactArgs); err != nil { diff --git a/restore.go b/restore.go index ca9e1e897..7342f9df4 100644 --- a/restore.go +++ b/restore.go @@ -82,6 +82,10 @@ using the runc checkpoint command.`, Name: "empty-ns", Usage: "create a namespace, but don't restore its properties", }, + cli.BoolFlag{ + Name: "auto-dedup", + Usage: "enable auto deduplication of memory images", + }, }, Action: func(context *cli.Context) error { if err := checkArgs(context, 1, exactArgs); err != nil { @@ -123,5 +127,6 @@ func criuOptions(context *cli.Context) *libcontainer.CriuOpts { ShellJob: context.Bool("shell-job"), FileLocks: context.Bool("file-locks"), PreDump: context.Bool("pre-dump"), + AutoDedup: context.Bool("auto-dedup"), } }