@@ -83,6 +83,9 @@ type JailerConfig struct {
8383 // ChrootStrategy will dictate how files are transfered to the root drive.
8484 ChrootStrategy HandlersAdapter
8585
86+ // CgroupVersion is the version of the cgroup filesystem to use.
87+ CgroupVersion string
88+
8689 // Stdout specifies the IO writer for STDOUT to use when spawning the jailer.
8790 Stdout io.Writer
8891 // Stderr specifies the IO writer for STDERR to use when spawning the jailer.
@@ -106,6 +109,7 @@ type JailerCommandBuilder struct {
106109 netNS string
107110 daemonize bool
108111 firecrackerArgs []string
112+ cgroupVersion string
109113
110114 stdin io.Reader
111115 stdout io.Writer
@@ -140,6 +144,10 @@ func (b JailerCommandBuilder) Args() []string {
140144 args = append (args , "--cgroup" , fmt .Sprintf ("cpuset.cpus=%s" , cpulist ))
141145 }
142146
147+ if len (b .cgroupVersion ) > 0 {
148+ args = append (args , "--cgroup-version" , b .cgroupVersion )
149+ }
150+
143151 if len (b .chrootBaseDir ) > 0 {
144152 args = append (args , "--chroot-base-dir" , b .chrootBaseDir )
145153 }
@@ -271,6 +279,12 @@ func (b JailerCommandBuilder) WithFirecrackerArgs(args ...string) JailerCommandB
271279 return b
272280}
273281
282+ // WithCgroupVersion specifies which cgroup version to use
283+ func (b JailerCommandBuilder ) WithCgroupVersion (version string ) JailerCommandBuilder {
284+ b .cgroupVersion = version
285+ return b
286+ }
287+
274288// Build will build a jailer command.
275289func (b JailerCommandBuilder ) Build (ctx context.Context ) * exec.Cmd {
276290 cmd := exec .CommandContext (
@@ -334,6 +348,7 @@ func jail(ctx context.Context, m *Machine, cfg *Config) error {
334348 WithExecFile (cfg .JailerCfg .ExecFile ).
335349 WithChrootBaseDir (cfg .JailerCfg .ChrootBaseDir ).
336350 WithDaemonize (cfg .JailerCfg .Daemonize ).
351+ WithCgroupVersion (cfg .JailerCfg .CgroupVersion ).
337352 WithFirecrackerArgs (fcArgs ... ).
338353 WithStdout (stdout ).
339354 WithStderr (stderr )
0 commit comments