From 9ade2cc5ce63adc76a9d20a15cc1911126050167 Mon Sep 17 00:00:00 2001 From: Yang Hongyang Date: Wed, 6 Jul 2016 22:58:55 -0400 Subject: [PATCH] libcontainer: Add a helper func to set CriuPath Added a helper func to set CriuPath for LinuxFactory. Signed-off-by: Yang Hongyang --- libcontainer/factory_linux.go | 9 +++++++++ utils_linux.go | 5 +---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/libcontainer/factory_linux.go b/libcontainer/factory_linux.go index 7be538bc3..6cce46e0d 100644 --- a/libcontainer/factory_linux.go +++ b/libcontainer/factory_linux.go @@ -103,6 +103,15 @@ func TmpfsRoot(l *LinuxFactory) error { return nil } +// CriuPath returns an option func to configure a LinuxFactory with the +// provided criupath +func CriuPath(criupath string) func(*LinuxFactory) error { + return func(l *LinuxFactory) error { + l.CriuPath = criupath + return nil + } +} + // New returns a linux based container factory based in the root directory and // configures the factory with the provided option funcs. func New(root string, options ...func(*LinuxFactory) error) (Factory, error) { diff --git a/utils_linux.go b/utils_linux.go index aa98ebbf8..5c940b741 100644 --- a/utils_linux.go +++ b/utils_linux.go @@ -37,10 +37,7 @@ func loadFactory(context *cli.Context) (libcontainer.Factory, error) { return nil, fmt.Errorf("systemd cgroup flag passed, but systemd support for managing cgroups is not available") } } - return libcontainer.New(abs, cgroupManager, func(l *libcontainer.LinuxFactory) error { - l.CriuPath = context.GlobalString("criu") - return nil - }) + return libcontainer.New(abs, cgroupManager, libcontainer.CriuPath(context.GlobalString("criu"))) } // getContainer returns the specified container instance by loading it from state