Systemd/src/test
Lennart Poettering efdb02375b core: unified cgroup hierarchy support
This patch set adds full support the new unified cgroup hierarchy logic
of modern kernels.

A new kernel command line option "systemd.unified_cgroup_hierarchy=1" is
added. If specified the unified hierarchy is mounted to /sys/fs/cgroup
instead of a tmpfs. No further hierarchies are mounted. The kernel
command line option defaults to off. We can turn it on by default as
soon as the kernel's APIs regarding this are stabilized (but even then
downstream distros might want to turn this off, as this will break any
tools that access cgroupfs directly).

It is possibly to choose for each boot individually whether the unified
or the legacy hierarchy is used. nspawn will by default provide the
legacy hierarchy to containers if the host is using it, and the unified
otherwise. However it is possible to run containers with the unified
hierarchy on a legacy host and vice versa, by setting the
$UNIFIED_CGROUP_HIERARCHY environment variable for nspawn to 1 or 0,
respectively.

The unified hierarchy provides reliable cgroup empty notifications for
the first time, via inotify. To make use of this we maintain one
manager-wide inotify fd, and each cgroup to it.

This patch also removes cg_delete() which is unused now.

On kernel 4.2 only the "memory" controller is compatible with the
unified hierarchy, hence that's the only controller systemd exposes when
booted in unified heirarchy mode.

This introduces a new enum for enumerating supported controllers, plus a
related enum for the mask bits mapping to it. The core is changed to
make use of this everywhere.

This moves PID 1 into a new "init.scope" implicit scope unit in the root
slice. This is necessary since on the unified hierarchy cgroups may
either contain subgroups or processes but not both. PID 1 hence has to
move out of the root cgroup (strictly speaking the root cgroup is the
only one where processes and subgroups are still allowed, but in order
to support containers nicey, we move PID 1 into the new scope in all
cases.) This new unit is also used on legacy hierarchy setups. It's
actually pretty useful on all systems, as it can then be used to filter
journal messages coming from PID 1, and so on.

The root slice ("-.slice") is now implicitly created and started (and
does not require a unit file on disk anymore), since
that's where "init.scope" is located and the slice needs to be started
before the scope can.

To check whether we are in unified or legacy hierarchy mode we use
statfs() on /sys/fs/cgroup. If the .f_type field reports tmpfs we are in
legacy mode, if it reports cgroupfs we are in unified mode.

This patch set carefuly makes sure that cgls and cgtop continue to work
as desired.

When invoking nspawn as a service it will implicitly create two
subcgroups in the cgroup it is using, one to move the nspawn process
into, the other to move the actual container processes into. This is
done because of the requirement that cgroups may either contain
processes or other subgroups.
2015-09-01 23:52:27 +02:00
..
.gitignore test: generate tests for OrderedHashmap from Hashmap tests 2014-10-23 17:38:02 +02:00
Makefile test: test tools should still be in the src/ directory 2012-04-12 13:48:01 +02:00
test-af-list.c test: add test for static lists 2015-07-31 19:58:27 +02:00
test-architecture.c condition: properly allow passing back errors from condition checks 2014-11-06 14:21:10 +01:00
test-arphrd-list.c test: add test for static lists 2015-07-31 19:58:27 +02:00
test-async.c shared/async: simplify asynchronous_job a bit 2015-02-02 20:31:18 -05:00
test-barrier.c test: disable test-barrier by default 2015-06-18 10:25:08 +02:00
test-bitmap.c bitmap: make bitmap_clear free the bitmap array 2015-07-31 19:08:26 +02:00
test-boot-timestamps.c treewide: no need to negate errno for log_*_errno() 2014-11-28 13:29:21 +01:00
test-btrfs.c fileio: consolidate write_string_file*() 2015-07-06 19:19:25 -04:00
test-calendarspec.c calendarspec: parse 'quarterly' and 'semi-annually' as shortcuts 2014-10-27 18:09:26 +01:00
test-cap-list.c remove unused includes 2015-02-23 23:53:42 +01:00
test-capability.c remove unused includes 2015-02-23 23:53:42 +01:00
test-cgroup-mask.c core: unified cgroup hierarchy support 2015-09-01 23:52:27 +02:00
test-cgroup-util.c shared: Drop 'name=' prefix from SYSTEMD_CGROUP_CONTROLLER define. 2015-06-02 11:25:52 +01:00
test-cgroup.c core: unified cgroup hierarchy support 2015-09-01 23:52:27 +02:00
test-condition.c util: split all hostname related calls into hostname-util.c 2015-05-18 17:10:07 +02:00
test-conf-files.c util: rework rm_rf() logic 2015-04-06 10:57:53 +02:00
test-conf-parser.c tests: add test-conf-parser 2015-05-30 11:19:35 +02:00
test-copy.c fileio: consolidate write_string_file*() 2015-07-06 19:19:25 -04:00
test-daemon.c core: allow informing systemd about service status changes with RELOADING=1 and STOPPING=1 sd_notify() messages 2014-08-21 17:24:21 +02:00
test-date.c test-date: don't fail test if log_max_level is higher than LOG_INFO 2014-09-30 23:40:40 +02:00
test-device-nodes.c shared/util: fix off-by-one error in tag_to_udev_node 2013-10-06 18:29:12 -04:00
test-dns-domain.c dns-domain: add call for concatenating two domain names 2015-08-21 12:41:07 +02:00
test-ellipsize.c shared: add terminal-util.[ch] 2015-04-11 00:34:02 +02:00
test-engine.c core: rename SystemdRunningAs to ManagerRunningAs 2015-05-11 22:51:49 +02:00
test-env-replace.c util: remove normalize_env_assignment(), it's unused 2015-04-10 16:23:46 +02:00
test-execute.c core: rename SystemdRunningAs to ManagerRunningAs 2015-05-11 22:51:49 +02:00
test-fdset.c test-fdset: add more tests 2015-05-30 11:19:35 +02:00
test-fileio.c fileio: consolidate write_string_file*() 2015-07-06 19:19:25 -04:00
test-firewall-util.c firewall: rename fw-util.[ch] → firewall-util.[ch] 2015-06-15 14:08:02 +02:00
test-fstab-util.c fstab-util: fix priority parsing and add test 2015-01-11 23:41:42 -05:00
test-hashmap-plain.c hashmap: fix iterators to not skip entries 2015-06-14 16:56:02 +02:00
test-hashmap.c hashmap: allow NULL key in ordered_hashmap_next() 2015-06-17 17:28:44 +02:00
test-helper.h replace tabs with spaces in some files 2014-02-21 03:50:12 +01:00
test-hostname-util.c Merge branch 'hostnamectl-dot-v2' 2015-08-05 21:02:41 -04:00
test-hostname.c btrfs: support recursively removing btrfs snapshots 2015-04-06 11:28:16 +02:00
test-id128.c Always prefer our headers to system headers 2014-07-31 08:56:03 -04:00
test-install.c remove unused includes 2015-02-23 23:53:42 +01:00
test-ipcrm.c logind: automatically remove SysV + POSIX IPC objects when the users owning them fully log out 2014-03-14 01:49:44 +01:00
test-job-type.c remove unused includes 2015-02-23 23:53:42 +01:00
test-json.c json: minor style fixes 2015-05-21 23:30:37 +02:00
test-libudev.c test-libudev: fix leak in error case 2015-05-11 21:42:59 +02:00
test-list.c basic: add LIST_INSERT_BEFORE 2015-08-04 03:23:43 -07:00
test-locale-util.c remove unused includes 2015-02-23 23:53:42 +01:00
test-log.c shared: add formats-util.h 2015-04-10 23:54:48 +02:00
test-loopback.c remove unused includes 2015-02-23 23:53:42 +01:00
test-namespace.c shared: add process-util.[ch] 2015-04-10 23:54:49 +02:00
test-netlink-manual.c test-netlink-manual: typo fix 2015-06-14 13:57:35 +02:00
test-ns.c core: Private*/Protect* options with RootDirectory 2015-05-18 18:47:45 +02:00
test-path-lookup.c core: rename SystemdRunningAs to ManagerRunningAs 2015-05-11 22:51:49 +02:00
test-path-util.c path-util: Fix path_is_mount_point for parent mount points in symlink mode 2015-06-09 16:16:56 +02:00
test-path.c core: rename SystemdRunningAs to ManagerRunningAs 2015-05-11 22:51:49 +02:00
test-prioq.c hashmap: introduce hash_ops to make struct Hashmap smaller 2014-09-15 16:08:50 +02:00
test-process-util.c sd-bus: properly handle creds that are known but undefined for a process 2015-04-29 21:45:58 +02:00
test-pty.c treewide: fix typos of let's 2015-07-06 20:09:54 -04:00
test-ratelimit.c tests: add test-ratelimit 2014-06-24 02:40:50 +02:00
test-replace-var.c shared: add API for replacing @FOO@ style variables in strings 2012-11-14 22:21:16 +01:00
test-ring.c remove unused includes 2015-02-23 23:53:42 +01:00
test-sched-prio.c core: rename SystemdRunningAs to ManagerRunningAs 2015-05-11 22:51:49 +02:00
test-set.c core: set_put never returns -EEXIST 2015-04-10 17:13:15 +02:00
test-sigbus.c tests: use assert_se instead of assert 2015-01-22 23:10:56 +01:00
test-sleep.c treewide: Correct typos and spell plural of bus consistent 2015-05-11 15:51:30 +02:00
test-socket-util.c test-socket-util: add test for in_addr_is_null() 2015-07-31 19:58:29 +02:00
test-strbuf.c treewide: correct spacing near eol in code comments 2014-12-11 15:10:03 +01:00
test-strip-tab-ansi.c shared: add terminal-util.[ch] 2015-04-11 00:34:02 +02:00
test-strv.c strv: Add strv_shell_escape 2015-08-07 15:50:43 +00:00
test-strxcpyx.c remove unused includes 2015-02-23 23:53:42 +01:00
test-tables.c remove unused includes 2015-02-23 23:53:42 +01:00
test-terminal-util.c shared: add terminal-util.[ch] 2015-04-11 00:34:02 +02:00
test-time.c test-time: test "infinity" parsing in nanoseconds 2015-02-24 13:27:10 +01:00
test-tmpfiles.c shared: add formats-util.h 2015-04-10 23:54:48 +02:00
test-udev.c everywhere: port everything to sigprocmask_many() and friends 2015-06-15 20:13:23 +02:00
test-uid-range.c treewide: introduce UID_INVALID (and friends) as macro for (uid_t) -1 2014-11-28 20:55:04 +01:00
test-unaligned.c shared: unaligned - use void* instead of unaligned be16_t* 2014-11-05 16:54:22 +01:00
test-unit-file.c load-fragment: reset the list on an ExecStart= containing only whitespace 2015-06-17 11:12:12 -07:00
test-unit-name.c util: split all hostname related calls into hostname-util.c 2015-05-18 17:10:07 +02:00
test-utf8.c test: utf8 - fix utf16 tests on BE machines 2015-02-18 15:23:23 +01:00
test-util.c test-util: fix a memleak 2015-08-25 23:52:18 +02:00
test-verbs.c test-verbs: add unit tests for verbs minilib 2015-01-08 15:57:38 -05:00
test-watchdog.c remove unused includes 2015-02-23 23:53:42 +01:00
test-xml.c bus: add basic dbus1 policy parser 2014-06-06 19:41:24 +02:00