summaryrefslogtreecommitdiff
path: root/src/core/unit.c
AgeCommit message (Collapse)Author
2013-07-17systemd,systemctl: export condition status and show failing conditionZbigniew Jędrzejewski-Szmek
$ systemctl --user status hoohoo hoohoo.service Loaded: loaded (/home/zbyszek/.config/systemd/user/hoohoo.service; static) Active: inactive (dead) start condition failed at Tue 2013-06-25 18:08:42 EDT; 1s ago ConditionPathExists=/tmp/hoo was not met Full information is exported over D-Bus: [(condition, trigger, negate, param, state),...] where state is one of "failed" (<0), "untested" (0), "OK" (>0). I've decided to use 0 for "untested", because it might be useful to differentiate different types of failure later on, without breaking compatibility. systemctl shows the failing condition, if there was a non-trigger failing condition, or says "none of the trigger conditions were met", because there're often many trigger conditions, and they must all fail for the condition to fail, so printing them all would consume a lot of space, and bring unnecessary attention to something that is quite low-level.
2013-07-17systemd: log failed conditionsZbigniew Jędrzejewski-Szmek
ConditionPathExists=/tmp/nosuchpath failed for nosuchpath.service.
2013-07-15systemd: do not output status messages once gettys are runningZbigniew Jędrzejewski-Szmek
Make Type=idle communication bidirectional: when bootup is finished, the manager, as before, signals idling Type=idle jobs to continue. However, if the boot takes too long, idling jobs signal the manager that they have had enough, wait a tiny bit more, and continue, taking ownership of the console. The manager, when signalled that Type=idle jobs are done, makes a note and will not write to the console anymore. This is a cosmetic issue, but quite noticable, so let's just fix it. Based on Harald Hoyer's patch. https://bugs.freedesktop.org/show_bug.cgi?id=54247 http://unix.stackexchange.com/questions/51805/systemd-messages-after-starting-login/
2013-07-12unit: check correct variable after strdupLukas Nykryn
2013-07-11core: simplify drop-in writing logic a bitLennart Poettering
let's make use of some format string magic!
2013-07-11cgroup: simplify how instantiated units are mapped to cgroupsLennart Poettering
Previously for an instantiated unit foo@bar.service we created a cgroup foo@.service/foo@bar.service, in order to place all instances of the same template inside the same subtree. As we now implicitly add all instantiated units into one per-template slice we don't need this complexity anymore, and instance units can map directly to the cgroups of their full name.
2013-07-11core: implicitly create a per-template slice for all instantiated units by ↵Lennart Poettering
default If no explicit slice is configured for an instantiated unit, create an implicit one for all instances of the same template.
2013-07-10unit: when deserializing cgroup path add it back into cgroup hashmapLennart Poettering
Also, properly remove cgroup path from hashmap when freeing unit.
2013-07-10core: serialize/deserialize bus subscribersLennart Poettering
2013-07-02core: make GC more aggressiveLennart Poettering
Since we should allow registering/unregistering transient units with the same name in a tight-loop, we need to make the GC more aggressive, so that dead units are cleaned up immediately instead of later. hence, execute the GC sweep on every event loop iteration and clean up units. This of course, means we need to be careful with adding units to the GC queue, which we already are since we execute check_gc() of each unit type already when adding something to the queue.
2013-07-02machined: sync to /run after job completedLennart Poettering
2013-07-01core: add new "scope" unit type for making a unit of pre-existing processesLennart Poettering
"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-06-28core: add transient unitsLennart Poettering
Transient units can be created via the bus API. They are configured via the method call parameters rather than on-disk files. They are subject to normal GC. Transient units currently may only be created for services (however, we will extend this), and currently only ExecStart= and the cgroup parameters can be configured (also to be extended). Transient units require a unique name, that previously had no configuration file on disk. A tool systemd-run is added that makes use of this functionality to run arbitrary command lines as transient services: $ systemd-run /bin/ping www.heise.de Will cause systemd to create a new transient service and run ping in it.
2013-06-28unit: make sure the dropins we write are high-priorityLennart Poettering
2013-06-27dbus: make more cgroup attributes runtime settableLennart Poettering
2013-06-27dbus: add infrastructure for changing multiple properties at once on units ↵Lennart Poettering
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-27core: general cgroup reworkLennart Poettering
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-20logind: add infrastructure to keep track of machines, and move to slicesLennart Poettering
- 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-18core: unref slice ref after useLennart Poettering
2013-06-17core: add new .slice unit type for partitioning systemsLennart Poettering
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-05-06core: unit_inactive_or_pending() should actually do as it claimsLennart Poettering
2013-05-02Add __attribute__((const, pure, format)) in various placesZbigniew Jędrzejewski-Szmek
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-04-30cgroup: do not allow manipulating the cgroup path of units within the ↵Lennart Poettering
systemd:/system subtree
2013-04-25core: remove duplicate MESSAGE= from log messageMirco Tischler
This was needed with log_struct_unit() but log_notice_unit() adds it anyway.
2013-04-25Add some extra __attribute__ ((format)) sCristian Rodríguez
2013-04-25unit: rework stop pending logicLennart Poettering
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-24cgroup: always validate cgroup controller namesLennart Poettering
Let's better be safe than sorry.
2013-04-23unit: rework trigger dependency logicLennart Poettering
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-22cgroup: make sure all our cgroup objects have a suffix and are properly escapedLennart Poettering
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-17core: log a few more things under UNIT=...Zbigniew Jędrzejewski-Szmek
2013-04-15core: let's make our log messages proper sentences with full stopsLennart Poettering
2013-04-05Use initalization instead of explicit zeroingZbigniew Jędrzejewski-Szmek
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-04util: make time formatting a bit smarterLennart Poettering
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-03util: rename write_one_line_file() to write_string_file()Lennart Poettering
You can write much more than just one line with this call (and we frequently do), so let's correct the naming.
2013-04-02Replace s/Dropin/DropIn/Zbigniew Jędrzejewski-Szmek
2013-04-01Introspect and monitor dropin configurationOleksii Shevchuk
2013-03-23unit: never retroactively start requisitesLennart Poettering
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-22exec: Assigning the empty string to CapabilityBoundSet= should drop all capsLennart Poettering
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-13core: single unit_kill implementation for all unit typesMichal Schmidt
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-02unit: count deserialized job only after it's definitely installedMichal Schmidt
Installation of a deserialized job may fail (though purely in theory), so increase the running job counter only when succeeding.
2013-03-01core: fix running jobs counters after reload/reexecMichal Schmidt
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-01unit: fix the race in deserialization.Oleksii Shevchuk
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-02-28core: count active units that may mind our printing to /dev/consoleMichal Schmidt
2013-02-28core/unit: use a temp variable for manager pointer in unit_notify()Michal Schmidt
2013-02-28core: redefine unit_status_printf()Michal Schmidt
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-28core: add manager_status_printf()Michal Schmidt
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-27unit: rework resource management APILennart Poettering
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-16unit: don't Require systemd-journald.socket from unitsMichal Schmidt
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-14honor SELinux labels, when creating and writing config filesHarald Hoyer
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-01-26core: unify kill code of mount, service, socket, swap unitsLennart Poettering