summaryrefslogtreecommitdiff
path: root/src/core/unit.c
AgeCommit message (Collapse)AuthorFilesLines
2014-01-29core: in containers, don't wait for cgroup empty notifications which will ↵Lennart Poettering1-3/+14
never come
2014-01-29core: use a bit more PID_FMTLennart Poettering1-5/+2
2014-01-29core: introduce new KillMode=mixed which sends SIGTERM only to the main ↵Lennart Poettering1-1/+2
process, but SIGKILL to all daemon processes This should fix some race with terminating systemd --user, where the system systemd instance might race against the user systemd instance when sending SIGTERM.
2014-01-27core: require mounts for the root and working directoriesZbigniew Jędrzejewski-Szmek1-0/+12
We know that launching a unit will fail if some required directories haven't been mounted yet. There's no point in starting it just to have it fail even before it gets a chance to run.
2014-01-27core: simplify check for path absolutenessZbigniew Jędrzejewski-Szmek1-5/+3
Just a microopt.
2013-12-26Use enums to make it obvious what boolean params meanZbigniew Jędrzejewski-Szmek1-1/+1
Suggested-by: Russ Allbery <rra@debian.org>
2013-12-14Add more _printf_'s for format-nonliteralsThomas Hindoe Paaboel Andersen1-0/+3
Clang is a bit more strict wrt format-nonliterals: http://clang.llvm.org/docs/LanguageExtensions.html#format-string-checking Adding these extra printf attributes also makes gcc able to find more problems. E.g. this patch uncovers a format issue in udev-builtin-path_id.c Some parts looked intetional about breaking the format-nonliteral check. I added some supression for warnings there.
2013-12-06Get rid of our reimplementation of basenameZbigniew Jędrzejewski-Szmek1-2/+2
The only problem is that libgen.h #defines basename to point to it's own broken implementation instead of the GNU one. This can be fixed by #undefining basename.
2013-12-02systemd: treat reload failure as failureZbigniew Jędrzejewski-Szmek1-1/+4
systemctl reload "suceeded" on stopped units, but it is documented to fail in this case. https://bugzilla.redhat.com/show_bug.cgi?id=1036845 Notes: Backport: bugfix
2013-12-02bus: add .busname unit type to implement kdbus-style bus activationLennart Poettering1-2/+3
2013-11-28core: initialize variableKay Sievers1-1/+1
2013-11-27service: add the ability for units to join other unit's PrivateNetwork= and ↵Lennart Poettering1-22/+96
PrivateTmp= namespaces
2013-11-26core: replace OnFailureIsolate= setting by a more generic OnFailureJobMode= ↵Lennart Poettering1-5/+6
setting and make use of it where applicable
2013-11-25core: include following set data in dumpLennart Poettering1-1/+12
2013-11-22cgroups: Cache controller masks and optimize queues.David Strauss1-2/+6
2013-11-20core: convert PID 1 to libsystemd-busLennart Poettering1-133/+21
This patch converts PID 1 to libsystemd-bus and thus drops the dependency on libdbus. The only remaining code using libdbus is a test case that validates our bus marshalling against libdbus' marshalling, and this dependency can be turned off. This patch also adds a couple of things to libsystem-bus, that are necessary to make the port work: - Synthesizing of "Disconnected" messages when bus connections are severed. - Support for attaching multiple vtables for the same interface on the same path. This patch also fixes the SetDefaultTarget() and GetDefaultTarget() bus calls which used an inappropriate signature. As a side effect we will now generate PropertiesChanged messages which carry property contents, rather than just invalidation information.
2013-11-16Fix RemainAfterExit services keeping a hold on consoleOlivier Brunel1-0/+3
When a service exits succesfully and has RemainAfterExit set, its hold on the console (in m->n_on_console) wasn't released since the unit state didn't change.
2013-11-15core: some more _cleanup_free_Zbigniew Jędrzejewski-Szmek1-16/+22
2013-11-13Only disable output on console during boot if neededOlivier Brunel1-1/+1
If there are no more jobs on console, no need/we shouldn't disable output.
2013-11-08Remove dead code and unexport some callsLennart Poettering1-61/+39
"make check-api-unused" informs us about code that is not used anymore or that is exported but only used internally. Fix these all over the place.
2013-10-14list: make our list macros a bit easier to use by not requring type spec on ↵Lennart Poettering1-14/+14
each invocation We can determine the list entry type via the typeof() gcc construct, and so we should to make the macros much shorter to use.
2013-10-13drop-ins: check return valueZbigniew Jędrzejewski-Szmek1-0/+3
If the function failed, nothing serious would happen because unlink would probably return EFAULT, but this would obscure the real error and is a bit sloppy. Notes: Backport: bugfix
2013-09-26core: rework how we match mount units against each otherLennart Poettering1-29/+133
Previously to automatically create dependencies between mount units we matched every mount unit agains all others resulting in O(n^2) complexity. On setups with large amounts of mount units this might make things slow. This change replaces the matching code to use a hashtable that is keyed by a path prefix, and points to a set of units that require that path to be around. When a new mount unit is installed it is hence sufficient to simply look up this set of units via its own file system paths to know which units to order after itself. This patch also changes all unit types to only create automatic mount dependencies via the RequiresMountsFor= logic, and this is exposed to the outside to make things more transparent. With this change we still have some O(n) complexities in place when handling mounts, but that's currently unavoidable due to kernel APIs, and still substantially better than O(n^2) as before. https://bugs.freedesktop.org/show_bug.cgi?id=69740 Notes: Backport: performance
2013-08-28Do not realloc strings, which are already in the hashmap as keysHarald Hoyer1-1/+1
This prevents corruption of the hashmap, because we would free() the keys in the hashmap, if the unit is already in there, with the same cgroup path. Notes: Backport: bugfix
2013-08-08dbus: use _cleanup_free_ instead of freeing ourselfRonny Chevalier1-22/+14
2013-07-30core: optionally send SIGHUP in addition to the configured kill signalLennart Poettering1-31/+53
This is useful to fake session ends for processes like shells.
2013-07-17systemd,systemctl: export condition status and show failing conditionZbigniew Jędrzejewski-Szmek1-1/+2
$ 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-Szmek1-1/+1
ConditionPathExists=/tmp/nosuchpath failed for nosuchpath.service.
2013-07-15systemd: do not output status messages once gettys are runningZbigniew Jędrzejewski-Szmek1-4/+8
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 Nykryn1-1/+1
2013-07-11core: simplify drop-in writing logic a bitLennart Poettering1-3/+55
let's make use of some format string magic!
2013-07-11cgroup: simplify how instantiated units are mapped to cgroupsLennart Poettering1-21/+7
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 Poettering1-1/+34
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 Poettering1-1/+7
Also, properly remove cgroup path from hashmap when freeing unit.
2013-07-10core: serialize/deserialize bus subscribersLennart Poettering1-1/+2
2013-07-02core: make GC more aggressiveLennart Poettering1-3/+0
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 Poettering1-2/+7
2013-07-01core: add new "scope" unit type for making a unit of pre-existing processesLennart Poettering1-1/+2
"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 Poettering1-24/+119
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 Poettering1-3/+3
2013-06-27dbus: make more cgroup attributes runtime settableLennart Poettering1-0/+19
2013-06-27dbus: add infrastructure for changing multiple properties at once on units ↵Lennart Poettering1-9/+16
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 Poettering1-358/+46
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 Poettering1-8/+19
- 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 Poettering1-0/+2
2013-06-17core: add new .slice unit type for partitioning systemsLennart Poettering1-6/+47
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 Poettering1-0/+3
2013-05-02Add __attribute__((const, pure, format)) in various placesZbigniew Jędrzejewski-Szmek1-2/+2
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 Poettering1-15/+20
systemd:/system subtree
2013-04-25core: remove duplicate MESSAGE= from log messageMirco Tischler1-1/+1
This was needed with log_struct_unit() but log_notice_unit() adds it anyway.