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 a36f99a29..6f877ab0e 100644 --- a/utils_linux.go +++ b/utils_linux.go @@ -38,10 +38,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