summaryrefslogtreecommitdiff
path: root/src/core/unit.c
Commit message (Collapse)AuthorAge
* core: do not spawn jobs or touch other units during coldpluggingIvan Shapovalov2015-03-07
| | | | | | | | | | | | | Because the order of coldplugging is not defined, we can reference a not-yet-coldplugged unit and read its state while it has not yet been set to a meaningful value. This way, already active units may get started again. We fix this by deferring such actions until all units have been at least somehow coldplugged. Fixes https://bugs.freedesktop.org/show_bug.cgi?id=88401
* core: expose consumed CPU time per unitLennart Poettering2015-03-02
| | | | | | This adds support for showing the accumulated consumed CPU time per-unit in the "systemctl status" output. The property is also readable via the bus.
* core: rework device state logicLennart Poettering2015-02-28
| | | | | | | | | | | | | This change introduces a new state "tentative" for device units. Device units are considered "plugged" when udev announced them, "dead" when they are not available in the kernel, and "tentative" when they are referenced in /proc/self/mountinfo or /proc/swaps but not (yet) announced via udev. This should fix a race when device nodes (like loop devices) are created and immediately mounted. Previously, systemd might end up seeing the mount unit before the device, and would thus pull down the mount because its BindTo dependency on the device would not be fulfilled.
* core: emit changes for NFailedUnits propertyLucas De Marchi2015-02-26
| | | | | | | By notifying the clients when this property is changed it's possible to allow "system health monitor" tools to get transitions like running<->degraded. This is an alternative to send changes on the SystemState property since the latter is more difficult to derive.
* unit: When stopping due to BindsTo=, log which unit caused itColin Walters2015-02-26
| | | | | | | | | | | I'm trying to track down a relatively recent change in systemd which broke OSTree; see https://bugzilla.gnome.org/show_bug.cgi?id=743891 Systemd started to stop sysroot.mount, and this patch should help me debug why at least. While we're here, "break" on the first unit we find that will deactivate, as there's no point in further iteration.
* unit: use weaker dependencies between mount and device units in --user modeLennart Poettering2015-02-25
| | | | | | | | When running in user mode unmounting of mount units when a device vanishes is unlikely to work, and even if it would work is already done by PID 1 anyway. HEnce, when creating implicit dependencies between mount units and their backing devices, created a Wants= type dependency in --user mode, but leave a BindsTo= dependency in --system mode.
* remove unused includesThomas Hindoe Paaboel Andersen2015-02-23
| | | | | | This patch removes includes that are not used. The removals were found with include-what-you-use which checks if any of the symbols from a header is in use.
* include <poll.h> instead of <sys/poll.h>Thomas Hindoe Paaboel Andersen2015-02-12
| | | | | | include-what-you-use automatically does this and it makes finding unnecessary harder to spot. The only content of poll.h is a include of sys/poll.h so should be harmless.
* core: don't fail to run services in --user instances if $HOME is missingLennart Poettering2015-02-12
| | | | | | | | Otherwise we cannot even invoke systemd-exit.service anymore, thus not even exit. https://bugs.freedesktop.org/show_bug.cgi?id=83100 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=759320
* core: correct a log messageLennart Poettering2015-02-11
| | | | | The log message talks specifically about services, though it actually applies to any kind of unit.
* util: rework strappenda(), and rename it strjoina()Lennart Poettering2015-02-03
| | | | | | After all it is now much more like strjoin() than strappend(). At the same time, add support for NULL sentinels, even if they are normally not necessary.
* Add a snprinf wrapper which checks that the buffer was big enoughZbigniew Jędrzejewski-Szmek2015-02-01
| | | | | | | | | | If we scale our buffer to be wide enough for the format string, we should expect that the calculation was correct. char_array_0() invocations are removed, since snprintf nul-terminates the output in any case. A similar wrapper is used for strftime calls, but only in timedatectl.c.
* core: output unit status output strings to console, only if we actually are ↵Lennart Poettering2015-01-28
| | | | | | | | | changing unit state Unit _start() and _stop() implementations can fail with -EAGAIN to delay execution temporarily. Thus, we should not output status messages before invoking these calls, but after, and only when we know that the invocation actually made a change.
* core: add new logic for services to store file descriptors in PID 1Lennart Poettering2015-01-06
| | | | | | | | | | | | | | With this change it is possible to send file descriptors to PID 1, via sd_pid_notify_with_fds() which PID 1 will store individually for each service, and pass via the usual fd passing logic on next invocation. This is useful for enable daemon reload schemes where daemons serialize their state to /run, push their fds into PID 1 and terminate, restoring their state on next start from the data in /run and passed in from PID 1. The fds are kept by PID 1 as long as no POLLHUP or POLLERR is seen on them, and the service they belong to are either not dead or failed, or have a job queued.
* core: rework counting of running jobsLennart Poettering2015-01-05
| | | | | | | | | | | | | Let's unify the code that counts the running jobs a bit, in order to make sure we are less likely to miss one. This is related to this bug: https://bugs.freedesktop.org/show_bug.cgi?id=87349 However, it probably won't fix it fully, and I cannot reproduce the issue. The change also adds an explicit assert change when the counter is off.
* tree-wide: spelling fixesVeres Lajos2014-12-30
| | | | | | | https://github.com/vlajos/misspell_fixer https://github.com/torstehu/systemd/commit/b6fdeb618cf2f3ce1645b3315f15f482710c7ffa Thanks to Torstein Husebo <torstein@huseboe.net>.
* Move dropin listing to sharedZbigniew Jędrzejewski-Szmek2014-12-16
| | | | | No functional change. This is in preparation for using this in systemctl in the future.
* unit: handle nicely of certain unit types are not supported on specific systemsLennart Poettering2014-12-15
| | | | | | | | | | | | Containers do not really support .device, .automount or .swap units; Systems compiled without support for swap do not support .swap units; Systems without kdbus do not support .busname units. With this change attempts to start a unsupported unit types will result in an immediate "unsupported" job result, which is a lot more descriptive then before. Also, attempts to start device units in containers will now immediately fail instead of causing jobs to be enqueued that never go away.
* sd-bus: move common errors src/shared/bus-errors.h → ↵Lennart Poettering2014-12-10
| | | | | | src/libsystemd/sd-bus/bus-common-errors.h Stuff in src/shared/ should not use stuff from src/libsystemd/ really.
* unit: update unit dropin paths and time when dropin file is written.WaLyong Cho2014-12-09
| | | | | | | | If a unit is set property by "systemctl set-property", a new dropin file is generated. But the unit's dropin_paths and dropin_mtime are not updated. So the unit is shown as need daemon reload. Update unit dropin_paths and dropin_mtime also when dropin file is written.
* core: rename unit_destroy_cgroup() to unit_destroy_cgroup_if_empty() since ↵Lennart Poettering2014-12-09
| | | | it's not quite as destructive as it sounds nowadays
* systemctl: show unit file preset state in "systemctl status" output"Lennart Poettering2014-12-02
|
* core: convert log_unit_*() to log_unit_*_errno()Michal Schmidt2014-11-28
| | | | | | Using: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_unit_(debug|info|notice|warning|error|emergency)\(([^"]+), "(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_unit_\1_errno(\2, \5, "\3%m"\4);/'
* log: fix order of log_unit_struct() to match other logging callsLennart Poettering2014-11-28
| | | | | Also, while we are at it, introduce some syntactic sugar for creating ERRNO= and MESSAGE= structured logging fields.
* log: rearrange log function namingLennart Poettering2014-11-27
| | | | | | | | | | - Rename log_meta() → log_internal(), to follow naming scheme of most other log functions that are usually invoked through macros, but never directly. - Rename log_info_object() to log_object_info(), simply because the object should be before any other parameters, to follow OO-style programming style.
* core: get rid of condition.c and move the remaining call into util.cLennart Poettering2014-11-06
| | | | | | | That way only one file with condition code remaining, in src/shared/, rather than src/core/. Next step: dropping the "-util" suffix from condition-util.[ch].
* core: introduce the concept of AssertXYZ= similar to ConditionXYZ=, but ↵Lennart Poettering2014-11-06
| | | | fatal for a start job if not met
* Convert the rest to sd_bus_errnomapZbigniew Jędrzejewski-Szmek2014-10-30
| | | | | | I tried to preserve most errno values, but in some cases they were inconsistent (different errno values for the same error name) or just mismatched.
* core: send sigabrt on watchdog timeout to get the stacktraceUmut Tezduyar Lindskog2014-10-28
| | | | | if sigabrt doesn't do the job, follow regular shutdown routine, sigterm > sigkill.
* manager: convert ephemeral to enumZbigniew Jędrzejewski-Szmek2014-10-27
| | | | In preparation for subsequent changes.
* job: optionally, when a job timeout is hit, also execute a failure actionLennart Poettering2014-10-28
|
* unit: adjust for the possibility of set_move() failingMichal Schmidt2014-10-23
|
* unit: place reservations before merging other's dependenciesMichal Schmidt2014-10-23
| | | | | | | | With the hashmap implementation that uses chaining the reservations merely ensure that the merging won't result in long bucket chains. With a future alternative implementation it will additionally reserve memory to make sure the merging won't fail.
* unit: move UnitDependency to unit-nameLukas Nykryn2014-10-08
|
* Rename user_runtime to user_runtime_dirZbigniew Jędrzejewski-Szmek2014-10-02
| | | | | This makes this function name similar to user_config_home() and makes it match the name of the environment variable.
* add a transient user unit directorySteven Allen2014-10-02
| | | | | | | | | This patch adds a transient user unit directory under `$XDG_RUNTIME_DIR/systemd/user/` and stores transient user-instance units (such as those created by `systemd-run --user`) under there instead of putting them in $XDG_CONFIG_HOME/systemd/user/. Fixes https://bugs.freedesktop.org/show_bug.cgi?id=67331
* hashmap: introduce hash_ops to make struct Hashmap smallerMichal Schmidt2014-09-15
| | | | | | | | | It is redundant to store 'hash' and 'compare' function pointers in struct Hashmap separately. The functions always comprise a pair. Store a single pointer to struct hash_ops instead. systemd keeps hundreds of hashmaps, so this saves a little bit of memory.
* Fix a few more typosRuben Kerkhof2014-08-30
|
* core: unify how we generate the prefix string when dumping unit stateLennart Poettering2014-08-21
|
* core: minor modernizationsLennart Poettering2014-08-18
|
* units: fix BindsTo= logic when applied relative to services with Type=oneshotLennart Poettering2014-08-18
| | | | | | | Start jobs for Type=oneshot units are successful when the unit state transition activating → inactive took place. In such a case all units that BindsTo= on it previously would continue to run, even though the unit they dependet on was actually already gone.
* core: warn when merged units have conflicting dependenciesZbigniew Jędrzejewski-Szmek2014-08-07
| | | | | | | | | | | | | | A unit should not Conflict with itself. It also does not make much sense for a unit to be After or Before itself, or to trigger itself in some way. If one of those dependency types is encountered, warn, instead of dropping it silently like other dependency types. % build/systemd-analyze verify test/loopy3.service ... Dependency Conflicts dropped when merging unit loopy4.service into loopy3.service Dependency ConflictedBy dropped when merging unit loopy4.service into loopy3.service
* core: do not add dependencies to selfZbigniew Jędrzejewski-Szmek2014-08-07
| | | | | | | Adds a pair of files which cause a segfault (also with systemd-analyze verify). https://bugzilla.redhat.com/show_bug.cgi?id=1124843
* path-lookup: make SYSTEMD_UNIT_PATH more flexibleZbigniew Jędrzejewski-Szmek2014-07-20
| | | | | It can now contain more than one directory, and can be used to only prepend, not totally override, the normal load path.
* cryptsetup: allow x-systemd.device-timeoutZbigniew Jędrzejewski-Szmek2014-06-30
| | | | https://bugs.freedesktop.org/show_bug.cgi?id=54210
* Move x-systemd-device.timeout handling from core to fstab-generatorZbigniew Jędrzejewski-Szmek2014-06-30
| | | | | | | | | | | | | Instead of adjusting job timeouts in the core, let fstab-generator write out a dropin snippet with the appropriate JobTimeout. x-systemd-device.timeout option is removed from Options= line in the generated unit. The functions to write dropins are moved from core/unit.c to shared/dropin.c, to make them available outside of core. generator.c is moved to libsystemd-label, because it now uses functions defined in dropin.c, which are in libsystemd-label.
* Fix several small typosJonathan Boulle2014-05-24
|
* cgroups: simplify CPUQuota= logicLennart Poettering2014-05-22
| | | | | | | | | Only accept cpu quota values in percentages, get rid of period definition. It's not clear whether the CFS period controllable per-cgroup even has a future in the kernel, hence let's simplify all this, hardcode the period to 100ms and only accept percentage based quota values.
* cgroup: rework startup logicLennart Poettering2014-05-22
| | | | | Introduce a (unsigned long) -1 as "unset" state for cpu shares/block io weights, and keep the startup unit set around all the time.
* core: add startup resource control optionWaLyong Cho2014-05-22
| | | | | | | | | | | Similar to CPUShares= and BlockIOWeight= respectively. However only assign the specified weight during startup. Each control group attribute is re-assigned as weight by CPUShares=weight and BlockIOWeight=weight after startup. If not CPUShares= or BlockIOWeight= be specified, then the attribute is re-assigned to each default attribute value. (default cpu.shares=1024, blkio.weight=1000) If only CPUShares=weight or BlockIOWeight=weight be specified, then that implies StartupCPUShares=weight and StartupBlockIOWeight=weight.