Bug 48510 - Enable to choose cgroups hierarchies for systemd-nspawn
Summary: Enable to choose cgroups hierarchies for systemd-nspawn
Status: RESOLVED FIXED
Alias: None
Product: systemd
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: All All
: medium enhancement
Assignee: Lennart Poettering
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-10 08:15 UTC by Léo Gillot-Lamure
Modified: 2012-04-11 15:46 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Patch delivered (4.36 KB, patch)
2012-04-11 04:59 UTC, Léo Gillot-Lamure
Details | Splinter Review
With STRV_FOREACH (4.75 KB, patch)
2012-04-11 06:14 UTC, Léo Gillot-Lamure
Details | Splinter Review
v3 (4.50 KB, patch)
2012-04-11 07:02 UTC, Léo Gillot-Lamure
Details | Splinter Review

Description Léo Gillot-Lamure 2012-04-10 08:15:42 UTC
systemd-nspawn creates a cgroup for each container launched. It would be useful to choose in which cgroup hierarchies this cgroup will appear, similarly to the "DefaultControllers" option of systemd.conf.
This would be supported via a commandline flag, like "-C cpu,freezer"

For example making it appear in the cpu:/ hierarchy would enable to say "i do not want this container to eat more that 75% of cpu", or making it appear in the freeze:/ hierarchy would enable to pause a container.

This would be useful in the case, for example, of a chrooted building environnment when you don't want the build to eat all your cpu.
Comment 1 Lennart Poettering 2012-04-10 13:19:20 UTC
Yupp, makes a lot of sense, happy to take a patch!
Comment 2 Léo Gillot-Lamure 2012-04-11 04:59:35 UTC
Created attachment 59801 [details] [review]
Patch delivered

Here is the patch. It is made against v44 but seems to apply cleanly on master.
I didn't build the manpage (dunno how to make it without making the whole thing), so i'm not *certain* there is no syntax error.

This patch does not verify if the specified controllers exist so if you enter "-C lol,blah" it will create /sys/fs/cgroup/{lol,blah}/user/<user>/<session>/nspawn-<pid>/tasks and this won't be wiped at the exit of the container.

Also, if you enter contrived inputs like "-C ," it will crash with "Assertion 'controller' failed at src/cgroup-util.c:693, function cg_create_and_attach(). Aborting."
Comment 3 Léo Gillot-Lamure 2012-04-11 06:14:36 UTC
Created attachment 59804 [details] [review]
With STRV_FOREACH
Comment 4 Léo Gillot-Lamure 2012-04-11 07:02:09 UTC
Created attachment 59805 [details] [review]
v3
Comment 5 Lennart Poettering 2012-04-11 15:46:58 UTC
Thanks, applied with minor changes!


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.