summaryrefslogtreecommitdiff
path: root/src/core/swap.c
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #14505 from poettering/refuse-on-failureZbigniew Jędrzejewski-Szmek2020-01-141-0/+2
|\ | | | | refuse OnFailure= deps on units that have no failure state
| * core: clearly refuse OnFailure= deps on units that can't failLennart Poettering2020-01-091-0/+2
| | | | | | | | | | | | | | | | | | Similar, refuse triggering deps on units that cannot trigger. And rework how we ignore After= dependencies on device units, to work the same way. See: #14142
* | core: set error value correctlyLennart Poettering2020-01-091-1/+3
| |
* | core: use unit-based logging instead of generic logging where appropriateLennart Poettering2020-01-091-5/+4
| |
* | core: no need to initialize swap structure fields if all zeroes anywayLennart Poettering2020-01-091-4/+0
|/
* core: swap priority can be negativeTopi Miettinen2019-12-041-4/+6
| | | | | Negative priorities are useful for swap targets which should be only used as last resort.
* tree-wide: drop double newlineYu Watanabe2019-11-041-2/+0
|
* core: drop 'wants' parameter from unit_add_node_dependency()Franck Bui2019-10-281-1/+1
| | | | | Since Wants dependency is no more automagically added to swap and mount units, this parameter is no more used hence this patch drops it.
* swap: do not make swap units wanted by its device unit anymoreFranck Bui2019-10-281-6/+5
| | | | | | It was done for mount units already (see commit 142b8142d7bb84f07). For the same reasons and for consistency we should also stop activating automagically swaps when their device is hot-plugged.
* core: adjust load functions for other unit types to be more like serviceZbigniew Jędrzejewski-Szmek2019-10-111-7/+6
| | | | | | | No functional change, just adjusting code to follow the same pattern everywhere. In particular, never call _verify() on an already loaded unit, but return early from the caller instead. This makes the code a bit easier to follow.
* core: turn unit_load_fragment_and_dropin_optional() into a flagZbigniew Jędrzejewski-Szmek2019-10-111-4/+2
| | | | | | | | | | unit_load_fragment_and_dropin() and unit_load_fragment_and_dropin_optional() are really the same, with one minor difference in behaviour. Let's drop the second function. "_optional" in the name suggests that it's the "dropin" part that is optional. (Which it is, but in this case, we mean the fragment to be optional.) I think the new version with a flag is easier to understand.
* cgroup: analyze: Report memory configurations that deviate from systemdChris Down2019-10-031-1/+1
| | | | | | This is the most basic consumer of the new systemd-vs-kernel checker, both acting as a reasonable standalone exerciser of the code, and also as a way for easy inspection of deviations from systemd internal state.
* core: add support for RestartKillSignal= to override signal used for restart ↵Zbigniew Jędrzejewski-Szmek2019-10-021-6/+17
| | | | | | | | jobs v2: - if RestartKillSignal= is not specified, fall back to KillSignal=. This is necessary to preserve backwards compatibility (and keep KillSignal= generally useful).
* Merge pull request #13439 from yuwata/core-support-systemctl-clean-moreZbigniew Jędrzejewski-Szmek2019-09-131-3/+83
|\ | | | | core: support systemctl clean more
| * core/swap: support "systemctl clean" for swap unitsYu Watanabe2019-08-281-3/+83
| |
* | core: make RuntimeDirectoryPreserve= works with non-service unitsYu Watanabe2019-08-231-1/+3
|/
* pid1: always log successfull process termination quietlyZbigniew Jędrzejewski-Szmek2019-08-221-1/+2
| | | | Fixes #13372.
* swap: scan /proc/swaps before processing waitid() resultsLennart Poettering2019-07-181-3/+15
| | | | | Similar to the previous commit, but for /proc/swaps, where the same logic and rationale applies.
* core: reduce the number of stalled PIDs from the watched processes list when ↵Franck Bui2019-03-201-3/+2
| | | | | | | | | | | | | | | | | possible Some PIDs can remain in the watched list even though their processes have exited since a long time. It can easily happen if the main process of a forking service manages to spawn a child before the control process exits for example. However when a pid is about to be mapped to a unit by calling unit_watch_pid(), the caller usually knows if the pid should belong to this unit exclusively: if we just forked() off a child, then we can be sure that its PID is otherwise unused. In this case we take this opportunity to remove any stalled PIDs from the watched process list. If we learnt about a PID in any other form (for example via PID file, via searching, MAINPID= and so on), then we can't assume anything.
* core: rename unit_{start_limit|condition|assert}_test() to unit_test_xyz()Lennart Poettering2019-03-181-1/+1
| | | | | | | Just some renaming, no change in behaviour. Background: I'd like to add more functions unit_test_xyz() that test various things, hence let's streamline the naming a bit.
* swap: always add in extras when we load a swap unitLennart Poettering2018-12-071-9/+11
| | | | | | | | Much like for the mount units we need fields such as the slice initialized by the time we activate the swap, hence when the kernel let's us know about a new swap that appeared we need to initialize the slice in any Swap object we allocated for that right-away, even if we can't read the real unit file for the swap device.
* swap: drop return valueLennart Poettering2018-12-071-1/+1
| | | | | We don't actually return any valid 'r' here, let's explicitly return 0 here hence instead.
* swap: don't propagate issues with processing /proc/swapsLennart Poettering2018-12-071-5/+2
| | | | | This follows similar recent changes in mount.c: error should be consider local, and not be propagated.
* swap: when loading a unit from /proc/swaps, mark its load state as goodLennart Poettering2018-12-071-1/+7
| | | | This follows similar logic in the mount unit.
* swap: split out code adding in additional unit props into a function of its ownLennart Poettering2018-12-071-50/+63
| | | | | | This adds swap_add_extras() similar to mount_add_extras(). No change in behaviour, just some refactoring.
* swap: fix misplaced commentLennart Poettering2018-12-071-1/+1
|
* swap: flush out state when activating a unit, not when deactivating itLennart Poettering2018-12-071-6/+11
| | | | | This is similar to the previous commit which did the same change for mount units.
* core: whenever we change state of a unit, force out PropertiesChanged bus signalLennart Poettering2018-12-011-0/+4
| | | | | | | | | | | | | | | | | This allows clients to follow our internal state changes safely. Previously, quick state changes (for example, when we restart a unit due to Restart= after it quickly transitioned through DEAD/FAILED states) would be coalesced into one bus signal event, with this change there's the guarantee that all state changes after the unit was announced ones are reflected on th bus. Note we only do this kind of guaranteed flushing only for unit state changes, not for other unit property changes, where clients still have to expect coalescing. This is because the unit state is a very important, high-level concept. Fixes: #10185
* coccinelle: make use of SYNTHETIC_ERRNOZbigniew Jędrzejewski-Szmek2018-11-221-4/+4
| | | | | | | | | | | Ideally, coccinelle would strip unnecessary braces too. But I do not see any option in coccinelle for this, so instead, I edited the patch text using search&replace to remove the braces. Unfortunately this is not fully automatic, in particular it didn't deal well with if-else-if-else blocks and ifdefs, so there is an increased likelikehood be some bugs in such spots. I also removed part of the patch that coccinelle generated for udev, where we returns -1 for failure. This should be fixed independently.
* core: introduce a helper function to wrap unit_log_{success,failure}Zbigniew Jędrzejewski-Szmek2018-11-161-5/+1
| | | | | It's inline so that the compiler can easily optimize away the call to get status string.
* core: log a recognizable message when a unit succeeds, tooLennart Poettering2018-11-161-1/+3
| | | | | | We already are doing it on failure, let's do it on success, too. Fixes: #10265
* core: make log messages about unit processes exiting recognizableLennart Poettering2018-11-161-2/+5
|
* core: make log messages about units entering a 'failed' state recognizableLennart Poettering2018-11-161-1/+1
| | | | | Let's make this recognizable, and carry result information in a structure fashion.
* core: introduce exec_params_clear()Yu Watanabe2018-11-081-1/+1
| | | | | | Follow-up for 1ad6e8b302e87b6891a2bfc35ad397b0afe3d940. Fixes #10677.
* core: split environment block mantained by PID 1's Manager object in twoLennart Poettering2018-10-311-1/+3
| | | | | | | | | | | | | | | | | | | | | | | This splits the "environment" field of Manager into two: transient_environment and client_environment. The former is generated from configuration file, kernel cmdline, environment generators. The latter is the one the user can control with "systemctl set-environment" and similar. Both sets are merged transparently whenever needed. Separating the two sets has the benefit that we can safely flush out the former while keeping the latter during daemon reload cycles, so that env var settings from env generators or configuration files do not accumulate, but dynamic API changes are kept around. Note that this change is not entirely transparent to users: if the user first uses "set-environment" to override a transient variable, and then uses "unset-environment" to unset it again things will revert to the original transient variable now, while previously the variable was fully removed. This change in behaviour should not matter too much though I figure. Fixes: #9972
* core: rework serializationLennart Poettering2018-10-261-4/+5
| | | | | | | | | | | | | | | | | Let's be more careful with what we serialize: let's ensure we never serialize strings that are longer than LONG_LINE_MAX, so that we know we can read them back with read_line(…, LONG_LINE_MAX, …) safely. In order to implement this all serialization functions are move to serialize.[ch], and internally will do line size checks. We'd rather skip a serialization line (with a loud warning) than write an overly long line out. Of course, this is just a second level protection, after all the data we serialize shouldn't be this long in the first place. While we are at it also clean up logging: while serializing make sure to always log about errors immediately. Also, (void)ify all calls we don't expect errors in (or catch errors as part of the general fflush_and_check() at the end.
* pid1: drop unused path parameter to add_two_dependencies_by_name()Zbigniew Jędrzejewski-Szmek2018-09-151-1/+1
|
* pid1: drop now-unused path parameter to add_dependency_by_name()Zbigniew Jędrzejewski-Szmek2018-09-151-2/+2
|
* core: replace udev_device by sd_deviceYu Watanabe2018-08-231-38/+30
|
* Merge pull request #9624 from poettering/service-state-flushZbigniew Jędrzejewski-Szmek2018-08-021-0/+1
|\ | | | | flush out ExecStatus structures when a new service cycle begins
| * core: properly reset all ExecStatus structures when entering a new unit cycleLennart Poettering2018-07-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Whenever a unit is started fresh we should flush out any runtime data from the previous cycle. We are pretty good at that already, but what so far we missed was the ExecStart=/ExecStop=/… command exit status data. Let's fix that, and properly flush out that stuff too. Consider this service: [Service] ExecStart=/bin/sleep infinity ExecStop=/bin/false When this service is started, then stopped and then started again "systemctl status" would show the ExecStop= results of the previous run along with the ExecStart= results of the current one, which is very confusing. With this patch this is corrected: the data is kept right until the moment the new service cycle starts, and then flushed out. Hence "systemctl status" in that case will only show the ExecStart= data, but no ExecStop= data, like it should be. This should fix part of the confusion of #9588
* | core: introduce new Type=exec service typeLennart Poettering2018-07-251-0/+1
|/ | | | | | | | | | | | | | | | | | | | Users are often surprised that "systemd-run" command lines like "systemd-run -p User=idontexist /bin/true" will return successfully, even though the logs show that the process couldn't be invoked, as the user "idontexist" doesn't exist. This is because Type=simple will only wait until fork() succeeded before returning start-up success. This patch adds a new service type Type=exec, which is very similar to Type=simple, but waits until the child process completed the execve() before returning success. It uses a pipe that has O_CLOEXEC set for this logic, so that the kernel automatically sends POLLHUP on it when the execve() succeeded but leaves the pipe open if not. This means PID 1 waits exactly until the execve() succeeded in the child, and not longer and not shorter, which is the desired functionality. Making use of this new functionality, the command line "systemd-run -p User=idontexist -p Type=exec /bin/true" will now fail, as expected.
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-3/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* core: add a couple of more error cases that should result in "bad-setting"Lennart Poettering2018-06-111-2/+2
| | | | | This changes a number of EINVAL cases to ENOEXEC, so that we enter "bad-setting" state if they fail.
* swap: trivial log message improvementsLennart Poettering2018-06-071-4/+2
|
* udev: add helper udev_device_new_from_stat_rdev()Lennart Poettering2018-06-071-4/+11
| | | | | | This is a simple wrapper around udev_device_new_from_devnum(), and uses the data from a struct stat's .st_rdev field to derive the udev_device object.
* core: rework device_found_node() prototypeLennart Poettering2018-06-071-2/+2
| | | | | | | | | | | | | | let's drop the "now" argument, it's exactly what MANAGER_IS_RUNNING() returns, hence let's use that instead to simplify things. Moreover, let's change the add/found argument pair to become found/mask, which allows us to change multiple flags at the same time into opposing directions, which will be useful later on. Also, let's change the return type to void. It's a notifier call where callers will ignore the return value anyway as it is nothing actionable. Should not change behaviour.
* Merge pull request #9158 from poettering/notify-auto-reloadZbigniew Jędrzejewski-Szmek2018-06-051-1/+1
|\ | | | | trigger OnFailure= only if Restart= is not in effect
| * core: don't trigger OnFailure= deps when a unit is going to restartLennart Poettering2018-06-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | This adds a flags parameter to unit_notify() which can be used to pass additional notification information to the function. We the make the old reload_failure boolean parameter one of these flags, and then add a new flag that let's unit_notify() if we are configured to restart the service. Note that this adjusts behaviour of systemd to match what the docs say. Fixes: #8398