Commit graph

41229 commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 03909b1e23 man: describe $LESS options more fully
https://bugzilla.redhat.com/show_bug.cgi?id=1655316
2019-07-22 06:58:07 +02:00
Zbigniew Jędrzejewski-Szmek a505166845
Merge pull request #13096 from keszybz/unit-loading
Preparatory work for the unit loading rework
2019-07-19 21:47:10 +02:00
Eric DeVolder 9b4abc69b2 pstore: Tool to archive contents of pstore
This patch introduces the systemd pstore service which will archive the
contents of the Linux persistent storage filesystem, pstore, to other storage,
thus preserving the existing information contained in the pstore, and clearing
pstore storage for future error events.

Linux provides a persistent storage file system, pstore[1], that can store
error records when the kernel dies (or reboots or powers-off). These records in
turn can be referenced to debug kernel problems (currently the kernel stuffs
the tail of the dmesg, which also contains a stack backtrace, into pstore).

The pstore file system supports a variety of backends that map onto persistent
storage, such as the ACPI ERST[2, Section 18.5 Error Serialization] and UEFI
variables[3 Appendix N Common Platform Error Record]. The pstore backends
typically offer a relatively small amount of persistent storage, e.g. 64KiB,
which can quickly fill up and thus prevent subsequent kernel crashes from
recording errors. Thus there is a need to monitor and extract the pstore
contents so that future kernel problems can also record information in the
pstore.

The pstore service is independent of the kdump service. In cloud environments
specifically, host and guest filesystems are on remote filesystems (eg. iSCSI
or NFS), thus kdump relies [implicitly and/or explicitly] upon proper operation
of networking software *and* hardware *and* infrastructure.  Thus it may not be
possible to capture a kernel coredump to a file since writes over the network
may not be possible.

The pstore backend, on the other hand, is completely local and provides a path
to store error records which will survive a reboot and aid in post-mortem
debugging.

Usage Notes:
This tool moves files from /sys/fs/pstore into /var/lib/systemd/pstore.

To enable kernel recording of error records into pstore, one must either pass
crash_kexec_post_notifiers[4] to the kernel command line or enable via 'echo Y
 > /sys/module/kernel/parameters/crash_kexec_post_notifiers'. This option
invokes the recording of errors into pstore *before* an attempt to kexec/kdump
on a kernel crash.

Optionally, to record reboots and shutdowns in the pstore, one can either pass
the printk.always_kmsg_dump[4] to the kernel command line or enable via 'echo Y >
/sys/module/printk/parameters/always_kmsg_dump'. This option enables code on the
shutdown path to record information via pstore.

This pstore service is a oneshot service. When run, the service invokes
systemd-pstore which is a tool that performs the following:
 - reads the pstore.conf configuration file
 - collects the lists of files in the pstore (eg. /sys/fs/pstore)
 - for certain file types (eg. dmesg) a handler is invoked
 - for all other files, the file is moved from pstore

 - In the case of dmesg handler, final processing occurs as such:
   - files processed in reverse lexigraphical order to faciliate
     reconstruction of original dmesg
   - the filename is examined to determine which dmesg it is a part
   - the file is appended to the reconstructed dmesg

For example, the following pstore contents:

 root@vm356:~# ls -al /sys/fs/pstore
 total 0
 drwxr-x--- 2 root root    0 May  9 09:50 .
 drwxr-xr-x 7 root root    0 May  9 09:50 ..
 -r--r--r-- 1 root root 1610 May  9 09:49 dmesg-efi-155741337601001
 -r--r--r-- 1 root root 1778 May  9 09:49 dmesg-efi-155741337602001
 -r--r--r-- 1 root root 1726 May  9 09:49 dmesg-efi-155741337603001
 -r--r--r-- 1 root root 1746 May  9 09:49 dmesg-efi-155741337604001
 -r--r--r-- 1 root root 1686 May  9 09:49 dmesg-efi-155741337605001
 -r--r--r-- 1 root root 1690 May  9 09:49 dmesg-efi-155741337606001
 -r--r--r-- 1 root root 1775 May  9 09:49 dmesg-efi-155741337607001
 -r--r--r-- 1 root root 1811 May  9 09:49 dmesg-efi-155741337608001
 -r--r--r-- 1 root root 1817 May  9 09:49 dmesg-efi-155741337609001
 -r--r--r-- 1 root root 1795 May  9 09:49 dmesg-efi-155741337710001
 -r--r--r-- 1 root root 1770 May  9 09:49 dmesg-efi-155741337711001
 -r--r--r-- 1 root root 1796 May  9 09:49 dmesg-efi-155741337712001
 -r--r--r-- 1 root root 1787 May  9 09:49 dmesg-efi-155741337713001
 -r--r--r-- 1 root root 1808 May  9 09:49 dmesg-efi-155741337714001
 -r--r--r-- 1 root root 1754 May  9 09:49 dmesg-efi-155741337715001

results in the following:

 root@vm356:~# ls -al /var/lib/systemd/pstore/155741337/
 total 92
 drwxr-xr-x 2 root root  4096 May  9 09:50 .
 drwxr-xr-x 4 root root    40 May  9 09:50 ..
 -rw-r--r-- 1 root root  1610 May  9 09:50 dmesg-efi-155741337601001
 -rw-r--r-- 1 root root  1778 May  9 09:50 dmesg-efi-155741337602001
 -rw-r--r-- 1 root root  1726 May  9 09:50 dmesg-efi-155741337603001
 -rw-r--r-- 1 root root  1746 May  9 09:50 dmesg-efi-155741337604001
 -rw-r--r-- 1 root root  1686 May  9 09:50 dmesg-efi-155741337605001
 -rw-r--r-- 1 root root  1690 May  9 09:50 dmesg-efi-155741337606001
 -rw-r--r-- 1 root root  1775 May  9 09:50 dmesg-efi-155741337607001
 -rw-r--r-- 1 root root  1811 May  9 09:50 dmesg-efi-155741337608001
 -rw-r--r-- 1 root root  1817 May  9 09:50 dmesg-efi-155741337609001
 -rw-r--r-- 1 root root  1795 May  9 09:50 dmesg-efi-155741337710001
 -rw-r--r-- 1 root root  1770 May  9 09:50 dmesg-efi-155741337711001
 -rw-r--r-- 1 root root  1796 May  9 09:50 dmesg-efi-155741337712001
 -rw-r--r-- 1 root root  1787 May  9 09:50 dmesg-efi-155741337713001
 -rw-r--r-- 1 root root  1808 May  9 09:50 dmesg-efi-155741337714001
 -rw-r--r-- 1 root root  1754 May  9 09:50 dmesg-efi-155741337715001
 -rw-r--r-- 1 root root 26754 May  9 09:50 dmesg.txt

where dmesg.txt is reconstructed from the group of related
dmesg-efi-155741337* files.

Configuration file:
The pstore.conf configuration file has four settings, described below.
 - Storage : one of "none", "external", or "journal". With "none", this
   tool leaves the contents of pstore untouched. With "external", the
   contents of the pstore are moved into the /var/lib/systemd/pstore,
   as well as logged into the journal.  With "journal", the contents of
   the pstore are recorded only in the systemd journal. The default is
   "external".
 - Unlink : is a boolean. When "true", the default, then files in the
   pstore are removed once processed. When "false", processing of the
   pstore occurs normally, but the pstore files remain.

References:
[1] "Persistent storage for a kernel's dying breath",
    March 23, 2011.
    https://lwn.net/Articles/434821/

[2] "Advanced Configuration and Power Interface Specification",
    version 6.2, May 2017.
    https://www.uefi.org/sites/default/files/resources/ACPI_6_2.pdf

[3] "Unified Extensible Firmware Interface Specification",
    version 2.8, March 2019.
    https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf

[4] "The kernel’s command-line parameters",
    https://static.lwn.net/kerneldoc/admin-guide/kernel-parameters.html
2019-07-19 21:46:07 +02:00
Zbigniew Jędrzejewski-Szmek 170a434c78 journal: emit debug log about settings only once (or when changed)
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=902795
https://bugzilla.redhat.com/show_bug.cgi?id=1715699
report "thousands" of those messages. I think this occurs when journald
rotates files very quickly. Nevertheless, logging this over and over is not
useful, let's do it just once.
2019-07-19 18:11:16 +02:00
Zbigniew Jędrzejewski-Szmek 4293c32b0e fs-util: adjust punctuation in comments 2019-07-19 16:51:14 +02:00
Zbigniew Jędrzejewski-Szmek f20319402a test-fs-util: call test functions in order of declaration 2019-07-19 16:51:14 +02:00
Zbigniew Jędrzejewski-Szmek 5cfa33e0bc Create src/shared/unit-file.[ch] for unit-file related ops
So far we put such functinos in install.[ch], but that is tied too closely
to enable/disable. Let's start moving things to a place with a better name.
2019-07-19 16:51:14 +02:00
Zbigniew Jędrzejewski-Szmek 47a0011186 shared/dropin: rename function for clarity
The caller looks for directories and is called "..._find_dirs()". Here, there
is no "finding" going on, so I found the old name confusing.
2019-07-19 16:51:14 +02:00
Zbigniew Jędrzejewski-Szmek f1b4b94cae shared/dropin: use TAKE_PTR in one more place 2019-07-19 16:51:14 +02:00
Zbigniew Jędrzejewski-Szmek b47aa73a9a basic/path-util: move two path_simplify* functions to be adjacent
No functional change.
2019-07-19 16:51:14 +02:00
Zbigniew Jędrzejewski-Szmek 96cf3ec966 pid1: get rid of unit_supported() helper
Another case where "open code" is easier to read than the helper.
2019-07-19 16:51:14 +02:00
Zbigniew Jędrzejewski-Szmek 3c4e303136 basic/set: constify operations which don't modify Set
No functional change, but it's nicer to the reader.
2019-07-19 16:51:14 +02:00
Zbigniew Jędrzejewski-Szmek f4c43a8115 pid1: do not say "(null)" if no disabled controllers
It looks like we made a mistake. The list is just empty, that's all.
2019-07-19 16:51:14 +02:00
Zbigniew Jędrzejewski-Szmek 8d5e593146 pid1: simplify timestamp buffer declaration 2019-07-19 16:51:14 +02:00
Zbigniew Jędrzejewski-Szmek d556db0372 Rename test-unit-file to test-load-fragment
This file was testing a mix of functions from src/core/load-fragment.c and some
from src/shared/install.c. Let's name it more appropriately. I want to add
tests for the new unit-file.c too.
2019-07-19 16:51:14 +02:00
Zbigniew Jędrzejewski-Szmek cf95bc1dc2 test-unit-file: move some tests to new test-env-file.c 2019-07-19 16:51:14 +02:00
Zbigniew Jędrzejewski-Szmek d578f909ce test-hashmap: move tests which should also apply to ordered hashmaps and add comment
Effectively this does two more tests also for ordered hashmaps.
This setup is a bit confusing, let's add a comment.
2019-07-19 16:51:14 +02:00
Zbigniew Jędrzejewski-Szmek 87da87846d basic/hashmap: add hashops variant that does strdup/freeing on its own
So far, we'd use hashmap_free_free to free both keys and values along with
the hashmap. I think it's better to make this more encapsulated: in this variant
the way contents are freed can be decided when the hashmap is created, and
users of the hashmap can always use hashmap_free.
2019-07-19 16:50:36 +02:00
Zbigniew Jędrzejewski-Szmek 0bf2c5e5ec test-strv: add function headers 2019-07-19 16:49:41 +02:00
Zbigniew Jędrzejewski-Szmek cde7910993 sysusers,strv: export the hash ops to map char* → strv
Also make string_strv_hashmap_put return 0 only if the entry already existed.
2019-07-19 16:49:41 +02:00
Zbigniew Jędrzejewski-Szmek b124d3f2ce basic/unit-name: allow unit_name_to_instance() to be used to classify units
This could already be done by calling unit_name_is_*(), but if we don't know
if the argument is a valid unit name, it is more convenient to have a single
function which returns the type or possibly an error if the unit name is not
valid.

The values in the enum are sorted "by length". Not really important, but it
seems more natural to me.
2019-07-19 16:49:41 +02:00
Zbigniew Jędrzejewski-Szmek 69de5c16ff basic/unit-name: drop unused function 2019-07-19 16:49:41 +02:00
Zbigniew Jędrzejewski-Szmek cc4d7d818d path-util: add path_startswith_strv() 2019-07-19 16:49:41 +02:00
Zbigniew Jędrzejewski-Szmek 771fded37f test-path-util: add function headers 2019-07-19 16:49:41 +02:00
Zbigniew Jędrzejewski-Szmek f7e7bb6546 Merge pull request #13070 from yuwata/network-set-route-to-dhcp-dns 2019-07-19 09:35:22 +02:00
Zbigniew Jędrzejewski-Szmek 217b7b33cc pid1: order jobs that execute processes with lower priority
We can meaningfully compare jobs for units which have cpu weight or nice set.
But non-exec units those have those set.

Starting non-exec jobs first allows us to get them out of the queue quickly,
and consider more jobs for starting.

If we have service A, and socket B, and service C which is after socket B,
and we want to start both A and C, and C has higher cpu weight, if we get
B out of the way first, we'll know that we can start both A and C, and we'll
start C first.

Also invert the comparisons using CMP() so they are always done left vs. right,
and negate when returning instead.

Follow-up for da8e178296.
2019-07-19 14:38:52 +09:00
Dan Streetman 65dd488fe1 test: convert all uses of '|| true' into '|| :'
No change in functionality; just use the shorter || :
2019-07-19 13:47:21 +09:00
Yu Watanabe 0161f0ca36
Merge pull request #13100 from 1848/neigh_ipv6
networkd: Neighbor IPv6 support for LinkLayerAddress
2019-07-19 09:48:49 +09:00
Anita Zhang 27e64442f8 docs: typo in arg name replace-irreversible -> replace-irreversibly 2019-07-19 07:17:40 +09:00
Yu Watanabe fb2ba3305b test-network: add test for neighbor with ipv6 lladdr 2019-07-19 07:14:58 +09:00
Yu Watanabe 1647f24100 sd-netlink: update comment 2019-07-19 07:14:58 +09:00
1848 f9ab224eb8 network: Added neighbor lladdr support for IPv6 2019-07-19 07:14:58 +09:00
Zbigniew Jędrzejewski-Szmek 34d2f9204c meson: update hint in man/rules/ 2019-07-19 07:09:34 +09:00
Luca Boccassi a637d0f9ec core: set shutdown watchdog on kexec too
At the moment the shutdown watchdog is set only when rebooting.
The set of "things that can go wrong" is not too far off when kexec'ing
and in fact we have a use case where it would be useful - moving to a
new kernel image.
2019-07-18 22:31:43 +02:00
Yu Watanabe 195a18c17d test-network: add tests for routes to DNS servers provided by DHCPv4 2019-07-19 01:56:14 +09:00
Yu Watanabe a24e12f020 network: add DHCPv4.RoutesToDNS= setting 2019-07-19 01:49:39 +09:00
Yu Watanabe 854a1ccfc2 network: set routes to dns servers provided by DHCPv4 2019-07-19 01:44:44 +09:00
Yu Watanabe d4c52ee5b5 network: store routes provided by DHCPv4 in Set
This re-writes d03073ddcd.
2019-07-19 01:44:44 +09:00
Yu Watanabe 01aaa3df16 network: introduce route_full_hash_ops
Will be used later.
2019-07-19 01:44:44 +09:00
Zbigniew Jędrzejewski-Szmek deeabb45ae
Merge pull request #13097 from poettering/mount-state-fix
Scan /proc/self/mountinfo before waitid() handling
2019-07-18 17:33:20 +02:00
Zbigniew Jędrzejewski-Szmek f4c961169c
Merge pull request #13102 from mbiebl/nologin-path
meson: make nologin path build time configurable
2019-07-18 17:17:23 +02:00
Lennart Poettering 9ddaa3e459 mount: rename update_parameters_proc_self_mount_info() → update_parameters_proc_self_mountinfo()
let's name the call like the file in /proc is actually called.
2019-07-18 17:03:11 +02:00
Lennart Poettering bcce581d65 swap: scan /proc/swaps before processing waitid() results
Similar to the previous commit, but for /proc/swaps, where the same
logic and rationale applies.
2019-07-18 17:03:11 +02:00
Lennart Poettering 350804867d mount: rescan /proc/self/mountinfo before processing waitid() results
(The interesting bits about the what and why are in a comment in the
patch, please have a look there instead of looking here in the commit
msg).

Fixes: #10872
2019-07-18 17:03:11 +02:00
Lennart Poettering fcd8e119c2 mount: simplify /proc/self/mountinfo handler
Our IO handler is only installed for one fd, hence there's no reason to
conditionalize on it again.

Also, split out the draining into a helper function of its own.
2019-07-18 17:03:10 +02:00
Lennart Poettering a5ac2021da
Merge pull request #12639 from michaelolbrich/job-order
make the run queue order deterministic
2019-07-18 16:53:32 +02:00
Lennart Poettering e8d1d6e76b vconsole-setup: rename toggle_utf8() → toggle_utf8_vc()
Let's make clearer that toggle_utf8_sysfs() is about sysfs, and
toggle_utf8_vc() about VC access
2019-07-18 16:21:02 +02:00
Lennart Poettering 26382cab1b Revert "Move verify_vc_kbmode() to terminal-util.c as vt_verify_kbmode()"
This reverts commit bb5ac84d79.
2019-07-18 16:21:02 +02:00
Lennart Poettering 15bba61325 Revert "Add check to switch VTs only between K_XLATE or K_UNICODE"
This reverts commit 13a43c73d8.
2019-07-18 16:21:02 +02:00
Zbigniew Jędrzejewski-Szmek 4f0acdb366 man: add note about systemctl stop return value
Fixes #13104.

(I know a lot more could be added to that  man page. This patch only addresses that
once specific complaint.)
2019-07-18 16:20:38 +02:00