summaryrefslogtreecommitdiffstats
path: root/src/sleep (follow)
Commit message (Collapse)AuthorAgeFilesLines
* sleep: add HibernateOnACPower= option (#33846)Marc Reisner2024-08-052-1/+10
| | | * Add HibernateOnACPower= systemd-sleep configuration option
* sleep,home: always initialize UnitFreezer if usedMike Yuan2024-07-171-3/+7
| | | | | | | | | | | | | | | | Previously, unit_freezer_new_freeze() would only return UnitFreezer object if FreezeUnit() succeeds. This is not ideal though, as a failed bus call doesn't mean the action actually failed. E.g. a timeout might occur because pid1 is waiting for cgroup event from kernel, while the bus call timeout was exceeded (#33269). In such a case, ThawUnit() will never be called, resulting in frozen units remain that way after resuming from sleep. Therefore, let's get rid of unit_freezer_new_freeze(), and make sure as long as unit freezer is involved, we'll call ThawUnit() when we're done. This should make things a lot more robust.
* sleep: also log about errno when getenv_bool failsMike Yuan2024-07-171-1/+1
|
* sleep: explicitly list valid sleep operations in switchMike Yuan2024-07-171-1/+4
| | | | To follow our usual coding style.
* tree-wide: port over to new builder apisLennart Poettering2024-06-191-8/+9
|
* libsystemd: turn json.[ch] into a public APILennart Poettering2024-06-121-11/+11
| | | | | | | | | | | | | | | This is preparation for making our Varlink API a public API. Since our Varlink API is built on top of our JSON API we need to make that public first (it's a nice API, but JSON APIs there are already enough, this is purely about the Varlink angle). I made most of the json.h APIs public, and just placed them in sd-json.h. Sometimes I wasn't so sure however, since the underlying data structures would have to be made public too. If in doubt I didn#t risk it, and moved the relevant API to src/libsystemd/sd-json/json-util.h instead (without any sd_* symbol prefixes). This is mostly a giant search/replace patch.
* sleep,home: clean up logs for session freezer a bitMike Yuan2024-05-301-4/+3
|
* bus-unit-util: rework UnitFreezer, explicitly thaw unitMike Yuan2024-05-301-8/+7
| | | | | | | | | | | | | | | | | | | Currently, we don't explicitly call unit_freezer_thaw(), but rely on the destructor to thaw the frozen unit on return. This has several problems though, one of them being that we ignore the return value of ThawUnit(), which is something we really shouldn't do here, since such failure can easily leave the whole system in unusable state. Moreover, the logging is kinda messy, e.g. homed might log "Everything completed" yet immediately followed by "Failed to thaw unit". Instead, we should log consistently and at higher level, to make things more debuggable. Therefore, let's step away from the practice. Plus, make UnitFreezer object heap-allocated, to match with existing unit_freezer_new() and allow us to use NULL to denote that the freezer is disabled.
* tree-wise: several cleanups for loggingYu Watanabe2024-04-301-2/+2
| | | | | | | | | | | - drop unnecessary SYNTHETIC_ERRNO() when the logger does not propagate error code, - drop unnecessary '%m' in error message when the error code is specified with SYNTHETIC_ERRNO(), - add missing full stop at the end of log message, - use RET_GATHER(), - add missing ", ignoring.", - upeercase the first letter, etc., etc...
* sleep: rename SleepMemMode= to MemorySleepMode=Mike Yuan2024-04-051-1/+1
| | | | Addresses https://github.com/systemd/systemd/pull/31986#discussion_r1554053623
* hibernate-util: make clear_efi_hibernate_location_and_warn return 1 ifMike Yuan2024-04-031-1/+1
| | | | actually cleared the variable
* sleep: add SleepMemMode= setting for configuring /sys/power/mem_sleepMike Yuan2024-03-282-0/+7
| | | | | | | | The setting is used when /sys/power/state is set to 'mem' (common for suspend) or /sys/power/disk is set to 'suspend' (hybrid-sleep). We default to kernel choice here, i.e. respect what's set through 'mem_sleep_default=' kernel cmdline option.
* sleep: make write_mode take a pathMike Yuan2024-03-281-10/+10
| | | | | Similar to the previous commit, preparation for adding support for /sys/power/mem_sleep.
* sleep-config: make sleep_operation_is_hibernation uppercaseMike Yuan2024-03-281-2/+2
|
* sleep: fix typo (sysupend -> suspend)Mike Yuan2024-03-071-1/+1
|
* sleep: Always freeze user.sliceAdrian Vovk2024-03-051-27/+19
| | | | | | | | | | | | | | | | Previously, we'd only freeze user.slice in the case of s2h, because we didn't want the user session to resume while systemd was transitioning from suspend to hibernate. This commit extends this freezing behavior to all sleep modes. We also have an environment variable to disable the freezing behavior outright. This is a necessary workaround for someone that has hooks in /usr/lib/systemd/system-sleep/ which communicate with some process running under user.slice, or if someone is using the proprietary NVIDIA driver which breaks when user.slice is frozen (issue #27559) Fixes #27559
* extract-word: modernize extract_many_wordsMike Yuan2024-03-031-1/+1
|
* sleep: upgrade fatal log message to LOG_ERRLennart Poettering2024-01-301-1/+1
|
* sleep: upgrade some unexpected errors to LOG_WARNING log messagesLennart Poettering2024-01-301-3/+3
|
* sleep: remove redundant debug log messageLennart Poettering2024-01-301-3/+1
|
* sleep: add mising error messageLennart Poettering2024-01-301-1/+1
|
* sleep: don't log duplicate errorMike Yuan2023-12-271-3/+1
| | | | write_resume_config() logs error on its own.
* sleep: connect to correct bus when locking homed-managed homesMike Yuan2023-12-261-1/+1
| | | | | | Partially reverts 122f6f1eaa4447449c7054793f6497eb9e4d03c6 Fixes https://github.com/systemd/systemd/issues/29938#issuecomment-1869508708
* siphash24: introduce siphash24_compress_typesafe() macroYu Watanabe2023-12-251-1/+1
| | | | | | | | To prevent copy-and-paste mistake. This also introduce in_addr_hash_func(). No functional change, just refactoring.
* hibernate-util: de-duplicate clear_efi_hibernate_locationMike Yuan2023-12-101-2/+2
|
* sleep: reduce the scope of hibernation_deviceMike Yuan2023-12-051-1/+1
|
* sleep: make sure we clear HibernateLocation on all error pathsMike Yuan2023-10-271-63/+64
| | | | | Also, let's say "sleep operation" rather than "sleep state", the latter of which creates ambiguity with /sys/power/state.
* sleep: minor modernization for lock_all_homesMike Yuan2023-10-271-2/+2
|
* sleep: rework write_state and write_modeMike Yuan2023-10-271-31/+29
|
* sleep: update help text for suspend-then-hibernateMike Yuan2023-10-271-1/+2
|
* sleep: log about errnoMike Yuan2023-10-271-1/+1
|
* sleep: drop unneeded includesMike Yuan2023-10-271-4/+5
|
* sleep: introduce sleep_operation_is_hibernationMike Yuan2023-10-271-1/+1
|
* sleep-config: make hybrid sleep always use 'suspend' disk modeMike Yuan2023-10-241-1/+0
| | | | | | | | | If user requests hybrid sleep, we should always use 'suspend' disk mode. If that's not supported, let's correctly report it so they can choose plain hibernation instead. HybridSleepMode= serves no purpose in this case and should be removed. Addresses https://github.com/systemd/systemd/pull/29681#discussion_r1369812785
* sleep-config: remove HibernateState= & HybridSleepState=, restrictMike Yuan2023-10-231-3/+0
| | | | | | | | | | SuspendState= not to include "disk" I don't know why these existed in the first place, but as I justified in the comments, it's simply not sensible to allow HibernateState= or HybridSleepState= to take values other than 'disk'. So let's just remove those options. Also, SuspendState= should not contain 'disk'.
* hibernate-util: rework find_hibernate_locationMike Yuan2023-10-201-20/+11
| | | | | | | | | | | | | | * "HibernateLocation" struct is renamed to HibernationDevice to avoid ambiguity with the EFI variable. Also, it no longer takes the reference to a SwapEntry object, since it's really unnecessary (only SwapEntry.path is used), but increases complexity. * SwapEntry is no longer used externally. * find_hibernate_location is split into read_swap_entries and find_suitable_hibernation_device. The former reads all swap entries into SwapEntries object for later use. * Make use of btrfs_get_file_physical_offset_fd Closes #25130
* meson: add build option for install path of main config filesFranck Bui2023-10-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows distros to install configuration file templates in /usr/lib/systemd for example. Currently we install "empty" config files in /etc/systemd/. They serve two purposes: - The file contains commented-out values that show the default settings. - It is easier to edit the right file if it is already there, the user doesn't have to type in the path correctly, and the basic file structure is already in place so it's easier to edit. Things that have happened since this approach was put in place: - We started supporting drop-ins for config files, and drop-ins are the recommended way to create local configuration overrides. - We have systemd-analyze cat-config which takes care of iterating over all possible locations (/etc, /run, /usr, /usr/local) and figuring out the right file. - Because of the first two points, systemd-analyze cat-config is much better, because it takes care of finding all the drop-ins and figuring out the precedence. Looking at files manually is still possible of course, but not very convenient. The disadvantages of the current approach with "empty" files in /etc: - We clutter up /etc so it's harder to see what the local configuration actually is. - If a user edits the file, package updates will not override the file (e.g. systemd.rpm uses %config(noreplace). This means that the "documented defaults" will become stale over time, if the user ever edits the main config file. Thus, I think that it's reasonable to: - Install the main config file to /usr/lib so that it serves as reference for syntax and option names and default values and is properly updated on package upgrades. - Recommend to users to always use drop-ins for configuration and systemd-analyze cat-config to view the documentation. This setting makes this change opt-in. Fixes #18420. [zjs: add more text to the description]
* Merge pull request #29242 from fbuihuu/update-main-config-file-headersZbigniew Jędrzejewski-Szmek2023-10-171-3/+5
|\ | | | | config files: update their header to reflect that they can be install…
| * config files: update their header to reflect that they can be installed in /usrFranck Bui2023-09-211-3/+5
| | | | | | | | Follow-up for c76f2fb0e59340222ce21f85c17d384c114db9de.
* | sleep-config: several cleanupsMike Yuan2023-09-271-1/+1
| | | | | | | | | | | | | | | | * Rename free_sleep_config to sleep_config_free * Rearrange functions * Make SleepConfig.modes and .states only contain operations that needs configuration * Add missing assert
* | sleep/battery-capacity: rearrange functionsMike Yuan2023-09-272-61/+63
| |
* | sleep/battery-capacity: drop unused error-handlingMike Yuan2023-09-271-12/+15
| |
* | sleep/battery-capacity: don't report we have trip alarm if no battery is foundMike Yuan2023-09-272-8/+14
| |
* | sleep-util: split into sleep-config and hibernate-utilMike Yuan2023-09-271-1/+2
| |
* | sleep-util: split battery-capacity into sleep/Mike Yuan2023-09-275-1/+447
| | | | | | | | | | This is only used by sleep.c. Let's start shrinking down the "mixed" sleep-util.
* | sleep: rebreak lines in check_wakeup_typeMike Yuan2023-09-271-2/+5
| |
* | sleep-util: move check_wakeup_type to sleep/sleepMike Yuan2023-09-271-0/+34
|/
* config files: more recommendations of `systemd-analyze cat-config`Franck Bui2023-09-191-0/+2
| | | | Follow-up for 3b0754b16c5.
* sleep: clear EFI HibernateLocation if writing kernel config failsMike Yuan2023-08-131-1/+5
| | | | Follow-up for f1f331a252d22c15f37d03524cce967664358c5c
* meson: move declarations of ac-power, detect-virt, sysctl, and sleepYu Watanabe2023-08-011-0/+13
|