summaryrefslogtreecommitdiff
path: root/src/core/unit.c
AgeCommit message (Collapse)Author
2015-08-06core: unit: remove bus slot after calling unit_done()Daniel Mack
The ->done callback in the unit's vtable might call into unit_unwatch_bus_name() and corrupt memory by that. Move the call down, and clean up the bus slot in case it hasn't been done yet.
2015-08-06core: dbus: track bus names per unitDaniel Mack
Currently, PID1 installs an unfiltered NameOwnerChanged signal match, and dispatches the signals itself. This does not scale, as right now, PID1 wakes up every time a bus client connects. To fix this, install individual matches once they are requested by unit_watch_bus_name(), and remove the watches again through their slot in unit_unwatch_bus_name(). If the bus is not available during unit_watch_bus_name(), just store name in the 'watch_bus' hashmap, and let bus_setup_api() do the installing later.
2015-07-21core: unit_get_status_message_format() never returns NULLMichal Schmidt
unit_get_status_message_format() is used only with one of JOB_START, JOB_STOP, JOB_RELOAD, all of which have fallback message strings defined, so the function may never return NULL.
2015-07-21core: always try harder to get unit status message format stringMichal Schmidt
The starting/stopping messages are printed to the console only if the corresponding format string is defined in the unit's vtable. To avoid excessive messages on the console, the unit types whose start/stop jobs are instantaneous had the format strings intentionally undefined. When logging the same event to the journal, a fallback to generic Starting/Stopping/Reloading messages is used. The problem of excessive console messages with instantaneous jobs is already resolved in a nicer way ("core: fix confusing logging of instantaneous jobs"), so there's no longer a need to have two ways of getting the format strings. Let's fold them into one function with the fallback to generic message strings.
2015-07-21core: fix confusing logging of instantaneous jobsMichal Schmidt
For instantaneous jobs (e.g. starting of targets, sockets, slices, or Type=simple services) the log shows the job completion before starting: systemd[1]: Created slice -.slice. systemd[1]: Starting -.slice. systemd[1]: Created slice System Slice. systemd[1]: Starting System Slice. systemd[1]: Listening on Journal Audit Socket. systemd[1]: Starting Journal Audit Socket. systemd[1]: Reached target Timers. systemd[1]: Starting Timers. ... The reason is that the job completes before the ->start() method returns and only then does unit_start() print the "Starting ..." message. The same thing happens when stopping units. Rather than fixing the order of the messages, let's just not emit the Starting/Stopping message at all when the job completes instantaneously. The job completion message is sufficient in this case.
2015-06-23core: fix reversed dependency check in unit_check_unneededAbdo Roig-Maranges
This was introduced by commit be7d9ff730cb88d7c6a8 and breaks StopWhenUnneeded=true in the presence of a Requisite dependency.
2015-06-11core: Let two more booleans survive a daemon-reloadWerner Fink
Without the boolean bus_name_good services as well as cgroup_realized for units a unit of Type=dbus and ExecReload sending SIGHUP to $MAINPID will be terminated if systemd will be daemon reloaded. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=746151 https://bugs.freedesktop.org/show_bug.cgi?id=78311 https://bugzilla.opensuse.org/show_bug.cgi?id=934077
2015-05-19unit: drop support for pre-v44 job serializationLennart Poettering
No distro ships that old systemd versions anyway, hence let's drop support for live-upgrades for them. Offline updates are still supported. And live-upgrades will only lose the job queue, hence basically still work...
2015-05-19core: also enforce ratelimiter if we stop a unit due to BindsTo=Lennart Poettering
This extends on bea355dac94e82697aa98e25d80ee4248263bf92, and extends the ratelimiter to not only be used for StopWhenUnneeded=1 units but also for units that have BindsTo= on a unit that is dead. http://lists.freedesktop.org/archives/systemd-devel/2015-April/030224.html
2015-05-19core: enforce a ratelimiter when stopping units due to StopWhenUnneeded=1Lennart Poettering
Otherwise we might end up in an endless stop loop. http://lists.freedesktop.org/archives/systemd-devel/2015-April/030224.html
2015-05-19unit: fix unit_check_unneeded() dependency iterationLennart Poettering
Fixes a regression introduced in be7d9ff730cb88d7c6a869dd5c47754c78ceaef2.
2015-05-19core: introduce seperate reverse dependencies for Requires= and Requisite=Lennart Poettering
This allows us to ensure that Requisite= dependencies never cause propagation between units, while Requires= dependencies might. http://lists.freedesktop.org/archives/systemd-devel/2015-May/031742.html
2015-05-11core: rename SystemdRunningAs to ManagerRunningAsLennart Poettering
It's primarily just a property of the Manager object after all, and we try to refer to PID 1 as "manager" instead of "systemd", hence let's to stick to this here too.
2015-05-11unit: move unit_warn_if_dir_nonempty() and friend to unit.cLennart Poettering
The call is only used by the mount and automount unit types, but that's already enough to consider it generic unit functionality, hence move it out of mount.c and into unit.c.
2015-05-11core,network: major per-object logging reworkLennart Poettering
This changes log_unit_info() (and friends) to take a real Unit* object insted of just a unit name as parameter. The call will now prefix all logged messages with the unit name, thus allowing the unit name to be dropped from the various passed romat strings, simplifying invocations drastically, and unifying log output across messages. Also, UNIT= vs. USER_UNIT= is now derived from the Manager object attached to the Unit object, instead of getpid(). This has the benefit of correcting the field for --test runs. Also contains a couple of other logging improvements: - Drops a couple of strerror() invocations in favour of using %m. - Not only .mount units now warn if a symlinks exist for the mount point already, .automount units do that too, now. - A few invocations of log_struct() that didn't actually pass any additional structured data have been replaced by simpler invocations of log_unit_info() and friends. - For structured data a new LOG_UNIT_MESSAGE() macro has been added, that works like LOG_MESSAGE() but prefixes the message with the unit name. Similar, there's now LOG_LINK_MESSAGE() and LOG_NETDEV_MESSAGE(). - For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(), LOG_NETDEV_INTERFACE() macros have been added that generate the necessary per object fields. The old log_unit_struct() call has been removed in favour of these new macros used in raw log_struct() invocations. In addition to removing one more function call this allows generated structured log messages that contain two object fields, as necessary for example for network interfaces that are joined into another network interface, and whose messages shall be indexed by both. - The LOG_ERRNO() macro has been removed, in favour of log_struct_errno(). The latter has the benefit of ensuring that %m in format strings is properly resolved to the specified error number. - A number of logging messages have been converted to use log_unit_info() instead of log_info() - The client code in sysv-generator no longer #includes core code from src/core/. - log_unit_full_errno() has been removed, log_unit_full() instead takes an errno now, too. - log_unit_info(), log_link_info(), log_netdev_info() and friends, now avoid double evaluation of their parameters
2015-05-05core: rework unit name validation and manipulation logicLennart Poettering
A variety of changes: - Make sure all our calls distuingish OOM from other errors if OOM is not the only error possible. - Be much stricter when parsing escaped paths, do not accept trailing or leading escaped slashes. - Change unit validation to take a bit mask for allowing plain names, instance names or template names or an combination thereof. - Refuse manipulating invalid unit name
2015-04-30core: simplify unit type detection logicLennart Poettering
Introduce a new call unit_type_supported() and make use of it everywhere. Also, drop Manager parameter from per-type supported method prototype.
2015-04-28unit: Drop unused variablesMartin Pitt
src/core/unit.c: In function 'unit_coldplug': src/core/unit.c:2884:18: warning: unused variable 'i' [-Wunused-variable] Iterator i; ^ src/core/unit.c:2883:15: warning: unused variable 'other' [-Wunused-variable] Unit *other; ^
2015-04-27core: coldplug all units which participate in jobs during coldpluggingIvan Shapovalov
This is yet another attempt to fix coldplugging order (more especially, the problem which happens when one creates a job during coldplugging and it references a not-yet-coldplugged unit). Now we forcibly coldplug all units which participate in jobs. This is a superset of previously implemented handling of the UNIT_TRIGGERS dependencies, so that handling is removed. http://lists.freedesktop.org/archives/systemd-devel/2015-April/031212.html https://bugs.freedesktop.org/show_bug.cgi?id=88401 (once again)
2015-04-24core: minor simplificationLennart Poettering
2015-04-24unit: don't add automatic dependencies on device units if they aren't supportedLennart Poettering
http://lists.freedesktop.org/archives/systemd-devel/2015-April/031187.html
2015-04-24core: always coldplug units that are triggered by other units before thoseLennart Poettering
Let's make sure that we don't enqueue triggering jobs for units before those units are actually fully loaded. http://lists.freedesktop.org/archives/systemd-devel/2015-April/031176.html https://bugs.freedesktop.org/show_bug.cgi?id=88401
2015-04-24Revert "core: do not spawn jobs or touch other units during coldplugging"Lennart Poettering
This reverts commit 6e392c9c45643d106673c6643ac8bf4e65da13c1. We really shouldn't invent external state keeping hashmaps, if we can keep this state in the units themselves.
2015-04-21core: make unit deserialization more defensiveLennart Poettering
2015-04-16core: fix spurious warning about cpuacct-usage-base deserializationZbigniew Jędrzejewski-Szmek
The key was parsed properly, but the warning was still generated.
2015-04-10shared: add process-util.[ch]Ronny Chevalier
2015-04-10shared: add formats-util.hRonny Chevalier
2015-04-10core: set_put never returns -EEXISTRonny Chevalier
When the value is already there it returns 0. Also add a test to ensure this
2015-03-13tree-wide: there is no ENOTSUP on linuxDavid Herrmann
Replace ENOTSUP by EOPNOTSUPP as this is what linux actually uses.
2015-03-07core: do not spawn jobs or touch other units during coldpluggingIvan Shapovalov
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
2015-03-02core: expose consumed CPU time per unitLennart Poettering
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.
2015-02-28core: rework device state logicLennart Poettering
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.
2015-02-26core: emit changes for NFailedUnits propertyLucas De Marchi
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.
2015-02-26unit: When stopping due to BindsTo=, log which unit caused itColin Walters
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.
2015-02-25unit: use weaker dependencies between mount and device units in --user modeLennart Poettering
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.
2015-02-23remove unused includesThomas Hindoe Paaboel Andersen
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.
2015-02-12include <poll.h> instead of <sys/poll.h>Thomas Hindoe Paaboel Andersen
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.
2015-02-12core: don't fail to run services in --user instances if $HOME is missingLennart Poettering
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
2015-02-11core: correct a log messageLennart Poettering
The log message talks specifically about services, though it actually applies to any kind of unit.
2015-02-03util: rework strappenda(), and rename it strjoina()Lennart Poettering
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.
2015-02-01Add a snprinf wrapper which checks that the buffer was big enoughZbigniew Jędrzejewski-Szmek
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.
2015-01-28core: output unit status output strings to console, only if we actually are ↵Lennart Poettering
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.
2015-01-06core: add new logic for services to store file descriptors in PID 1Lennart Poettering
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.
2015-01-05core: rework counting of running jobsLennart Poettering
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.
2014-12-30tree-wide: spelling fixesVeres Lajos
https://github.com/vlajos/misspell_fixer https://github.com/torstehu/systemd/commit/b6fdeb618cf2f3ce1645b3315f15f482710c7ffa Thanks to Torstein Husebo <torstein@huseboe.net>.
2014-12-16Move dropin listing to sharedZbigniew Jędrzejewski-Szmek
No functional change. This is in preparation for using this in systemctl in the future.
2014-12-15unit: handle nicely of certain unit types are not supported on specific systemsLennart Poettering
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.
2014-12-10sd-bus: move common errors src/shared/bus-errors.h → ↵Lennart Poettering
src/libsystemd/sd-bus/bus-common-errors.h Stuff in src/shared/ should not use stuff from src/libsystemd/ really.
2014-12-09unit: update unit dropin paths and time when dropin file is written.WaLyong Cho
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.
2014-12-09core: rename unit_destroy_cgroup() to unit_destroy_cgroup_if_empty() since ↵Lennart Poettering
it's not quite as destructive as it sounds nowadays