@@ -89,6 +89,11 @@ type JailerConfig struct {
89
89
// formatted like <cgroup_file>=<value>, like "cpu.shares=10"
90
90
CgroupArgs []string
91
91
92
+ // ParentCgroup is the parent cgroup for the jailer. By specifying this
93
+ // parameter, the jailer will create a new cgroup named id for the
94
+ // microvm in the <cgroup_base>/<parent_cgroup> subfolder.
95
+ ParentCgroup string
96
+
92
97
// Stdout specifies the IO writer for STDOUT to use when spawning the jailer.
93
98
Stdout io.Writer
94
99
// Stderr specifies the IO writer for STDERR to use when spawning the jailer.
@@ -114,6 +119,7 @@ type JailerCommandBuilder struct {
114
119
firecrackerArgs []string
115
120
cgroupVersion string
116
121
cgroupArgs []string
122
+ parentCgroup string
117
123
118
124
stdin io.Reader
119
125
stdout io.Writer
@@ -156,6 +162,10 @@ func (b JailerCommandBuilder) Args() []string {
156
162
args = append (args , "--cgroup-version" , b .cgroupVersion )
157
163
}
158
164
165
+ if len (b .parentCgroup ) > 0 {
166
+ args = append (args , "--parent-cgroup" , b .parentCgroup )
167
+ }
168
+
159
169
if len (b .chrootBaseDir ) > 0 {
160
170
args = append (args , "--chroot-base-dir" , b .chrootBaseDir )
161
171
}
@@ -237,6 +247,12 @@ func (b JailerCommandBuilder) WithCgroupArgs(cgroupArgs ...string) JailerCommand
237
247
return b
238
248
}
239
249
250
+ // WithParentCgroup will set the parent cgroup for the jailer.
251
+ func (b JailerCommandBuilder ) WithParentCgroup (parentCgroup string ) JailerCommandBuilder {
252
+ b .parentCgroup = parentCgroup
253
+ return b
254
+ }
255
+
240
256
// WithChrootBaseDir will set the given path as the chroot base directory. This
241
257
// specifies where chroot jails are built and defaults to /srv/jailer.
242
258
func (b JailerCommandBuilder ) WithChrootBaseDir (path string ) JailerCommandBuilder {
@@ -375,6 +391,7 @@ func jail(ctx context.Context, m *Machine, cfg *Config) error {
375
391
WithDaemonize (cfg .JailerCfg .Daemonize ).
376
392
WithCgroupVersion (cfg .JailerCfg .CgroupVersion ).
377
393
WithCgroupArgs (cfg .JailerCfg .CgroupArgs ... ).
394
+ WithParentCgroup (cfg .JailerCfg .ParentCgroup ).
378
395
WithFirecrackerArgs (fcArgs ... ).
379
396
WithStdout (stdout ).
380
397
WithStderr (stderr )
0 commit comments