Commit Graph

84 Commits

Author SHA1 Message Date
Lennart Poettering 241da3287d unit: make sure the dropins we write are high-priority 2013-06-28 00:41:24 +02:00
Lennart Poettering b42defe3b8 dbus: make more cgroup attributes runtime settable 2013-06-27 21:50:35 +02:00
Lennart Poettering 8e2af47840 dbus: add infrastructure for changing multiple properties at once on units and hook some cgroup attributes up to it
This introduces two bus calls to make runtime changes to selected bus
properties, optionally with persistence.

This currently hooks this up only for three cgroup atributes, but this
brings the infrastructure to add more changable attributes.

This allows setting multiple attributes at once, and takes an array
rather than a dictionary of properties, in order to implement simple
resetting of lists using the same approach as when they are sourced from
unit files. This means, that list properties are appended to by this
call, unless they are first reset via assigning the empty list.
2013-06-27 21:14:56 +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 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 702a2d8f6a core: unref slice ref after use 2013-06-18 02:07:35 +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 d956ac29a1 core: unit_inactive_or_pending() should actually do as it claims 2013-05-06 22:28:56 +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
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
Mirco Tischler fcf8c44041 core: remove duplicate MESSAGE= from log message
This was needed with log_struct_unit() but log_notice_unit() adds it
anyway.
2013-04-25 21:50:48 -04:00
Cristian Rodríguez b1e2b33c52 Add some extra __attribute__ ((format)) s 2013-04-25 21:50:48 -04:00
Lennart Poettering 31afa0a44c unit: rework stop pending logic
When a trigger unit wants to know if a stop is queued for it, we should
just check precisely that and do not check whether it is actually
stopped already. This is because we use these checks usually from state
change calls where the state variables are not updated yet.

This change splits unit_pending_inactive() into two calls
unit_inactive_or_pending() and unit_stop_pending(). The former checks
state and pending jobs, the latter only pending jobs.
2013-04-25 22:01:49 -03: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 3ecaa09bcc unit: rework trigger dependency logic
Instead of having explicit type-specific callbacks that inform the
triggering unit when a triggered unit changes state, make this generic
so that state changes are forwarded betwee any triggered and triggering
unit.

Also, get rid of UnitRef references from automount, timer, path units,
to the units they trigger and rely exclsuively on UNIT_TRIGGER type
dendencies.
2013-04-23 16:00:32 -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
Zbigniew Jędrzejewski-Szmek c1b6628d64 core: log a few more things under UNIT=... 2013-04-17 00:09:16 -04:00
Lennart Poettering 7a9ec5c902 core: let's make our log messages proper sentences with full stops 2013-04-15 21:59:04 +02:00
Zbigniew Jędrzejewski-Szmek b92bea5d2a Use initalization instead of explicit zeroing
Before, we would initialize many fields twice: first
by filling the structure with zeros, and then a second
time with the real values. We can let the compiler do
the job for us, avoiding one copy.

A downside of this patch is that text gets slightly
bigger. This is because all zero() calls are effectively
inlined:

$ size build/.libs/systemd
         text    data     bss     dec     hex filename
before 897737  107300    2560 1007597   f5fed build/.libs/systemd
after  897873  107300    2560 1007733   f6075 build/.libs/systemd

… actually less than 1‰.

A few asserts that the parameter is not null had to be removed. I
don't think this changes much, because first, it is quite unlikely
for the assert to fail, and second, an immediate SEGV is almost as
good as an assert.
2013-04-05 19:50:57 -04:00
Lennart Poettering 2fa4092c28 util: make time formatting a bit smarter
Instead of outputting "5h 55s 50ms 3us" we'll now output "5h
55.050003s". Also, while outputting the accuracy is configurable.

Basically we now try use "dot notation" for all time values > 1min. For
>= 1s we use 's' as unit, otherwise for >= 1ms we use 'ms' as unit, and
finally 'us'.

This should give reasonably values in most cases.
2013-04-04 02:56:56 +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
Zbigniew Jędrzejewski-Szmek 2875e22b65 Replace s/Dropin/DropIn/ 2013-04-02 10:24:51 -04:00
Oleksii Shevchuk ae7a7182da Introspect and monitor dropin configuration 2013-04-01 23:43:49 -04:00
Lennart Poettering 335b5240ae unit: never retroactively start requisites
Requesites are not supposed to be auto-started afterall, they are just
checks, so don't try to be smarter here than appropriate.

Based on a patch from Michal Schmidt.
2013-03-23 03:16:17 +01:00
Lennart Poettering d91c34f21f exec: Assigning the empty string to CapabilityBoundSet= should drop all caps
Previously, it would set all caps, but it should drop them all, anything
else makes little sense.

Also, document that this works as it does, and what to do in order to
assign all caps to the bounding set.

https://bugzilla.redhat.com/show_bug.cgi?id=914705
2013-03-22 23:28:44 +01:00
Michal Schmidt 814cc56212 core: single unit_kill implementation for all unit types
There are very few differences in the implementations of the kill method in the
unit types that have one. Let's unify them.

This does not yet unify unit_kill() with unit_kill_context().
2013-03-13 17:21:53 +01:00
Michal Schmidt 6b19ad24d3 unit: count deserialized job only after it's definitely installed
Installation of a deserialized job may fail (though purely in theory),
so increase the running job counter only when succeeding.
2013-03-02 12:29:04 +01:00
Michal Schmidt 9e9e2b722c core: fix running jobs counters after reload/reexec
All active units will call unit_notify() during coldplug, so we just
make sure we're counting from zero again and get the correct result for
n_on_console.

For n_running_jobs we likewise reset it to zero and then count
the running jobs as we encounter them in deserialization.
2013-03-01 18:38:22 +01:00
Oleksii Shevchuk bf6dcfa6a7 unit: fix the race in deserialization.
unit_notify is fired in deserelization code (particulary in
service_set_state). Units passed in random order, and there is possibility,
that unit with StopWhenUnneeded=yes passed before it actual dependecies. In
that case unit will be stopped as unneeded, because deps in UNIT_INACTIVE state
yet.

So, reuse similar logic (unit.c:1421) to avoid this race
2013-03-01 15:11:35 +01:00
Michal Schmidt 7ed9f6cd78 core: count active units that may mind our printing to /dev/console 2013-02-28 02:24:01 +01:00
Michal Schmidt 546ac4f007 core/unit: use a temp variable for manager pointer in unit_notify() 2013-02-28 02:23:47 +01:00
Michal Schmidt 49b1d37726 core: redefine unit_status_printf()
Take advantage of the fact that almost all callers want to pass unit
description as the last parameter. Those who don't can use the more
flexible manager_status_printf().
2013-02-28 02:23:21 +01:00
Michal Schmidt 25cee55076 core: add manager_status_printf()
unit_status_printf() checks the state of the manager, not of the unit
as such. Move it to manager.c and rename it to manager_status_printf().

Temporarily keep unit_status_printf as a wrapper macro.
2013-02-28 00:14:40 +01:00
Lennart Poettering 26d04f86a3 unit: rework resource management API
This introduces a new static list of known attributes and their special
semantics. This means that cgroup attribute values can now be
automatically translated from user to kernel notation for command line
set settings, too.

This also adds proper support for multi-line attributes.
2013-02-27 18:50:41 +01:00
Michal Schmidt 9d246da3c6 unit: don't Require systemd-journald.socket from units
It is not really necessary to have a hard requirement dependency on
systemd-journald.socket in almost every unit. The socket gets pulled
into boot via at least two ways:
 sockets.target -> systemd-journald.socket
 sysinit.target -> systemd-journald.service -> systemd-journald.socket

So just assume something pulled the socket in and drop the automatic
requirement dependencies on it.

"systemctl stop systemd-journald.socket" will now not take the whole
system down with it.
2013-02-16 01:18:09 +01: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
Lennart Poettering cd2086fe65 core: unify kill code of mount, service, socket, swap units 2013-01-26 05:53:30 +01:00
Lennart Poettering 6d3a739048 unit: fix typo 2013-01-19 01:18:01 +01:00
Lennart Poettering 71645acac2 unit: optionally allow making cgroup attribute changes persistent 2013-01-19 01:02:30 +01:00
Lennart Poettering e884315e3d cgroup: additional validity checks for cgroup attribute names 2013-01-19 01:02:30 +01:00
Mirco Tischler bbc9006e6b core: log USER_UNIT instead of UNIT if in user session 2013-01-18 11:14:00 -05:00
Nestor Ovroy 8755586eba core: corrects check of strduped controller string
In commit 246aa6d (core: add bus API and systemctl commands for altering
cgroup parameters during runtime), when rewriting unit_add_one_default_cgroup
to prefered style, the check of strduped b->controller was incorrectly
changed to check the containing structure. Correct it.
2013-01-17 09:31:50 -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 8afbb8e118 unit: allow extension of unit files with .d/*.conf drop-ins
For all unit files foobar.service we will now read
foobar.service.d/*.conf, too. This may be used to override certain unit
settings without having to edit unit files directly.

This makes it really easy to change specific settings for services
without having to edit any unit file:

mkdir /etc/systemd/system/avahi-daemon.service.d/
echo -e '[Service]\nNice=99' > /etc/systemd/system/avahi-daemon.service.d/nice.conf
systemctl daemon-reload
2013-01-11 00:21:06 +01:00
Lennart Poettering 36697dc019 timer: implement calendar time events 2012-11-23 21:37:58 +01:00
Lennart Poettering 68b29a9fca manager: introduce watch_init() initializer for watches 2012-11-22 00:45:22 +01:00
Zbigniew Jędrzejewski-Szmek 23635a8547 systemd: use structured logging for unit changes
Information which unit a log entry pertains to enables systemctl
status to display more log messages.
2012-10-18 21:33:52 +02:00
Zbigniew Jędrzejewski-Szmek 1ca6783f5e log: introduce a macro to format message id
The MESSAGE_ID=... stanza will appear in countless number of places.
It is just too long to write it out in full each time.

Incidentally, this also fixes a typo of MESSSAGE is three places.
2012-10-13 14:26:30 +02:00
Zbigniew Jędrzejewski-Szmek 67445f4e22 core: move ManagerRunningAs to shared
Note: I did s/MANAGER/SYSTEMD/ everywhere, even though it makes the
patch quite verbose. Nevertheless, keeping MANAGER prefix in some
places, and SYSTEMD prefix in others would just lead to confusion down
the road. Better to rip off the band-aid now.
2012-09-18 19:53:34 +02:00
Lennart Poettering 3ef63c3174 unit-printf: before resolving exec context specifiers check whether the object actually has an exec context 2012-09-18 11:40:01 +02:00