Commit Graph

45 Commits

Author SHA1 Message Date
Lennart Poettering ac9ef33358 cgroup: when uninstalling agent, actually turn it off first 2013-07-10 23:47:15 +02:00
Kay Sievers ad929bcc27 disable the cgroups release agent when shutting down
During shutdown, when we try to clean up all remaining processes, the
kernel will fork new agents every time a cgroup runs empty. These
new processes cause delays in the final SIGTERM, SIGKILL logic.

Apart from that, this should also avoid that the kernel-forked binaries
cause unpredictably timed access to the filesystem which we might need to
unmount.
2013-07-04 20:31:18 +02:00
Lennart Poettering 374ec6abf3 libsystemd-logind: fix detection of session/user/machine of a PID 2013-07-02 02:34:15 +02:00
Lennart Poettering 6c12b52e19 core: add new "scope" unit type for making a unit of pre-existing processes
"Scope" units are very much like service units, however with the
difference that they are created from pre-existing processes, rather
than processes that systemd itself forks off. This means they are
generated programmatically via the bus API as transient units rather
than from static configuration read from disk. Also, they do not provide
execution-time parameters, as at the time systemd adds the processes to
the scope unit they already exist and the parameters cannot be applied
anymore.

The primary benefit of this new unit type is to create arbitrary cgroups
for worker-processes forked off an existing service.

This commit also adds a a new mode to "systemd-run" to run the specified
processes in a scope rather then a transient service.
2013-07-01 00:18:00 +02:00
Lennart Poettering 4ad490007b core: general cgroup rework
Replace the very generic cgroup hookup with a much simpler one. With
this change only the high-level cgroup settings remain, the ability to
set arbitrary cgroup attributes is removed, so is support for adding
units to arbitrary cgroup controllers or setting arbitrary paths for
them (especially paths that are different for the various controllers).

This also introduces a new -.slice root slice, that is the parent of
system.slice and friends. This enables easy admin configuration of
root-level cgrouo properties.

This replaces DeviceDeny= by DevicePolicy=, and implicitly adds in
/dev/null, /dev/zero and friends if DeviceAllow= is used (unless this is
turned off by DevicePolicy=).
2013-06-27 04:17:34 +02:00
Lennart Poettering 1021b21bc6 login: add an api to determine the slice a PID is located in to libsystemd-login 2013-06-21 01:46:27 +02:00
Lennart Poettering 9444b1f20e logind: add infrastructure to keep track of machines, and move to slices
- This changes all logind cgroup objects to use slice objects rather
  than fixed croup locations.

- logind can now collect minimal information about running
  VMs/containers. As fixed cgroup locations can no longer be used we
  need an entity that keeps track of machine cgroups in whatever slice
  they might be located. Since logind already keeps track of users,
  sessions and seats this is a trivial addition.

- nspawn will now register with logind and pass various bits of metadata
  along. A new option "--slice=" has been added to place the container
  in a specific slice.

- loginctl gained commands to list, introspect and terminate machines.

- user.slice and machine.slice will now be pulled in by logind.service,
  since only logind.service requires this slice.
2013-06-20 03:49:59 +02:00
Lennart Poettering a016b9228f core: add new .slice unit type for partitioning systems
In order to prepare for the kernel cgroup rework, let's introduce a new
unit type to systemd, the "slice". Slices can be arranged in a tree and
are useful to partition resources freely and hierarchally by the user.

Each service unit can now be assigned to one of these slices, and later
on login users and machines may too.

Slices translate pretty directly to the cgroup hierarchy, and the
various objects can be assigned to any of the slices in the tree.
2013-06-17 21:36:51 +02:00
Lennart Poettering b043cd0b7e cgroup: the "tasks" attribute is obsolete, cgroup.procs is the new replacement 2013-06-06 15:49:01 +02:00
Lennart Poettering a0ab566574 cgroup: when escaping a cgroup object name, also escape names that start with a dot 2013-05-03 19:06:06 +02:00
Zbigniew Jędrzejewski-Szmek 44a6b1b680 Add __attribute__((const, pure, format)) in various places
I'm assuming that it's fine if a _const_ or _pure_ function
calls assert. It is assumed that the assert won't trigger,
and even if it does, it can only trigger on the first call
with a given set of parameters, and we don't care if the
compiler moves the order of calls.
2013-05-02 22:52:09 -04:00
Zbigniew Jędrzejewski-Szmek 38158b920e cgls: add --machine/-M
cg_get_machine_path is modified to include the escaped machine name
+ ".nspawn" if the machine argument is nonnull.
2013-05-01 10:15:25 -04:00
Lennart Poettering 8af8afd6b3 cgroup: make cg_pid_get_path() work properly for co-mounted controllers and normalized named hierarchies 2013-04-30 08:36:01 -03:00
Lennart Poettering 5954c07433 cgroup: do not allow manipulating the cgroup path of units within the systemd:/system subtree 2013-04-30 08:36:01 -03:00
Zbigniew Jędrzejewski-Szmek 2a371001f8 Use attribute(unused) in PROTECT_ERRNO
clang emits warnings about unused attribute _saved_errno_, which drown
out other—potentially useful—warnings. gcc documentation is not exactly
verbose about the effects of __attribute__((unused)) on variables, but
let's assume that it works if the unit test passes.
2013-04-25 21:50:48 -04:00
Lennart Poettering 78edb35ab4 cgroup: always validate cgroup controller names
Let's better be safe than sorry.
2013-04-24 19:02:13 -03:00
Lennart Poettering ae018d9bc9 cgroup: make sure all our cgroup objects have a suffix and are properly escaped
Session objects will now get the .session suffix, user objects the .user
suffix, nspawn containers the .nspawn suffix.

This also changes the user cgroups to be named after the numeric UID
rather than the username, since this allows us the parse these paths
standalone without requiring access to the cgroup file system.

This also changes the mapping of instanced units to cgroups. Instead of
mapping foo@bar.service to the cgroup path /user/foo@.service/bar we
will now map it to /user/foo@.service/foo@bar.service, in order to
ensure that all our objects are properly suffixed in the tree.
2013-04-22 23:14:12 -03:00
Lennart Poettering aff38e74bd nspawn: suffix the nspawn cgroups with ".nspawn"
As discussed with Dan Berrange it's a good idea to suffix all objects in
the cgroup tree with ".something", so that when the system is
partitioned using a resource management tool we can drop objects of
different types into the same partition directory without generate
namespace conflicts.

We'l add this to the Pax Control Group document as soon as write access
to the fdo wiki is restored.
2013-04-22 23:14:12 -03:00
Harald Hoyer 7fd1b19bc9 move _cleanup_ attribute in front of the type
http://lists.freedesktop.org/archives/systemd-devel/2013-April/010510.html
2013-04-18 09:11:22 +02:00
Lennart Poettering 7027ff61a3 nspawn: introduce the new /machine/ tree in the cgroup tree and move containers there
Containers will now carry a label (normally derived from the root
directory name, but configurable by the user), and the container's root
cgroup is /machine/<label>. This label is called "machine name", and can
cover both containers and VMs (as soon as libvirt also makes use of
/machine/).

libsystemd-login can be used to query the machine name from a process.

This patch also includes numerous clean-ups for the cgroup code.
2013-04-16 04:41:21 +02:00
Lennart Poettering 6c03089c32 bus: handle env vars safely
Make sure that our library is safe for usage in SUID programs when it
comes to env var handling
2013-04-15 14:05:03 +02:00
Lennart Poettering 2d76d14ea3 cgroup: clean-ups 2013-04-08 20:35:25 +02:00
Lennart Poettering 974efc4658 cgroup: always keep access mode of 'tasks' and 'cgroup.procs' files in cgroup directories in sync 2013-04-08 18:22:47 +02:00
Lennart Poettering 574d5f2dfc util: rename write_one_line_file() to write_string_file()
You can write much more than just one line with this call (and we
frequently do), so let's correct the naming.
2013-04-03 20:12:56 +02:00
Harald Hoyer a5c32cff1f honor SELinux labels, when creating and writing config files
Also split out some fileio functions to fileio.c and provide a SELinux
aware pendant in fileio-label.c

see https://bugzilla.redhat.com/show_bug.cgi?id=881577
2013-02-14 16:19:38 +01:00
Thomas Hindoe Paaboel Andersen 641906e936 use strneq instead of strncmp 2013-02-13 00:56:13 +01:00
Lennart Poettering e884315e3d cgroup: additional validity checks for cgroup attribute names 2013-01-19 01:02:30 +01:00
Zbigniew Jędrzejewski-Szmek 96cde13ace core/cgroup-util: simplify functions and add tests 2013-01-18 11:14:00 -05:00
Zbigniew Jędrzejewski-Szmek 3f98659cce core/group-util: merge two functions 2013-01-18 11:14:00 -05:00
Mirco Tischler ef1673d169 journal: log _SYSTEMD_USER_UNIT for user session units 2013-01-18 11:14:00 -05:00
Lennart Poettering 246aa6dd9d core: add bus API and systemctl commands for altering cgroup parameters during runtime 2013-01-14 21:24:57 +01:00
Lennart Poettering b08121d004 systemctl: don't show cgroup field for a unit if cgroup is empty 2012-12-24 00:29:39 +01:00
Lennart Poettering b7def68494 util: rename join() to strjoin()
This is to match strappend() and the other string related functions.
2012-07-13 13:41:01 +02:00
Lennart Poettering ba1261bc02 build-sys: fix built with --disable-logind 2012-05-30 22:25:01 +02:00
Kay Sievers 9eb977db5b util: split-out path-util.[ch] 2012-05-08 02:33:10 +02:00
Lennart Poettering 37099707e2 cgroup: fix alloca() misuse in cg_shorten_controllers() 2012-05-03 23:23:38 +02:00
Kay Sievers 018ef268b1 silence a bunch of gcc warnings 2012-04-17 18:42:09 +02:00
Lennart Poettering b59e246565 logind: remove redundant entries from logind's default controller lists too 2012-04-16 19:15:00 +02:00
Lennart Poettering b69d29ce04 systemctl: show main and control PID explicitly in cgroup-show
In some cases the main/control PID of a service can be outside of the
services cgroups (for example, if logind readjusts the processes'
cgroup). In order to clarify this for the user show the main/control PID
in the cgroup tree nonetheless, but mark them specially.
2012-04-16 18:59:40 +02:00
Lennart Poettering c3175a7f40 cgls: don't show empty cgroups by default 2012-04-16 18:59:08 +02:00
Lennart Poettering 3474ae3c7e cgroup: if a controller is not available don't try to create cgroups in its hierarchy 2012-04-16 18:59:07 +02:00
Lennart Poettering 5430f7f2bc relicense to LGPLv2.1 (with exceptions)
We finally got the OK from all contributors with non-trivial commits to
relicense systemd from GPL2+ to LGPL2.1+.

Some udev bits continue to be GPL2+ for now, but we are looking into
relicensing them too, to allow free copy/paste of all code within
systemd.

The bits that used to be MIT continue to be MIT.

The big benefit of the relicensing is that closed source code may now
link against libsystemd-login.so and friends.
2012-04-12 00:24:39 +02:00
Kay Sievers cc527a4734 split selinux label operations out of cgroup-util, socket-util
This prevents linking of selinux and libdl for another 15 binaries.
2012-04-11 12:49:00 +02:00
Kay Sievers 49e942b2bc rename basic.la to shared.la and put selinux deps in shared-selinx.la
Only 34 of 74 tools need libselinux linked, and libselinux is a pain
with its unconditional library constructor.
2012-04-10 22:43:05 +02:00
Kay Sievers 77d47be64f move cgroup-util.[ch] to shared/ 2012-04-10 18:46:51 +02:00
Renamed from src/cgroup-util.c (Browse further)