Commit Graph
1523 Commits
Author SHA1 Message Date
Mike Yuan bc9e592c4f systemctl: configure boot loader options only when going through firmware
Fixes #30497
2023-12-21 01:35:55 +09:00
Matteo Croce b408d46b83 systemctl: show success messages when showing transaction
Extend `--show-transaction` so it shows a success message when an unit
is successfully started.
2023-12-19 04:52:41 -08:00
Matteo Croce e22ad53d5c dbus-wait-for-jobs: change 'quiet' flag to enum
Change the 'quiet' flag to `bus_wait_for_jobs()` to an enum, so we can
select with more granularity the type of information logged.
2023-12-19 04:52:41 -08:00
Yu Watanabe f1e89cb9b1 Merge pull request #30399 from YHNdnzj/memory-accounting-always-peak
systemctl-show: always show memory peak if available
2023-12-10 14:11:05 +09:00
Luca Boccassi fc9d7ddbac systemctl: fix copy/paste
on_circle is set twice to the same value

CID#1529418
2023-12-09 13:17:02 +00:00
Mike Yuan 2747cd6d17 systemctl-show: always show memory peak if available 2023-12-09 20:42:48 +08:00
Zbigniew Jędrzejewski-Szmek 34f4fcb59f Merge pull request #30302 from keszybz/systemd-edit-stdin
systemctl edit --stdin
2023-12-06 22:28:02 +01:00
Zbigniew Jędrzejewski-Szmek d1f9a39ef4 Merge pull request #29853 from YHNdnzj/sleep-automated
logind: support Sleep() that automatically choose a sleep operation
2023-12-06 22:25:13 +01:00
Mike Yuan fb45185d98 systemctl-whoami: use pidfd to refer to processes
While at it, rephrase the output a bit. Before this commit, if
the pid doesn't exist, we output something hard to interpret -
"Failed to get unit for ourselves".
2023-12-06 21:15:38 +00:00
Lennart Poettering cbc51d0cf4 Merge pull request #30101 from poettering/underline-rework
systemctl: "list-units" table tweaks
2023-12-06 22:13:12 +01:00
Zbigniew Jędrzejewski-Szmek 329050c5e2 systemctl: add "edit --stdin"
This is a fancy wrapper around "cat <<EOF", but:
- the user doesn't need to figure out the file name,
- parent directories are created automatically,
- daemon-reload is implied,
so it's a convenient way to create units or drop-ins.

Closes https://github.com/systemd/systemd/issues/21862.
2023-12-05 18:47:19 +01:00
Mike Yuan 5b3562898a systemctl: add support for Sleep() logind call 2023-12-05 22:18:32 +08:00
Frantisek Sumsal 538291b0d8 systemctl: include unit ID in the property map
Otherwise we get a not very nice message when trying to display a
non-existent man page:

~# systemctl cat test.service
[Unit]
Description=Hello
[Service]
ExecStart=true
~# systemctl help test.service
Documentation for (null) not known.
2023-11-25 21:36:10 +01:00
Christian Hesse 0f1dcf9d79 systemctl: distinguish reload and reexec
This used to log about reload, for reload and reexecution. Let's
distinguish the two cases.
2023-11-22 17:45:04 +00:00
Yu Watanabe b6d669d5af systemctl: fix typo
Follow-up for f380473edf.
2023-11-22 04:44:52 +09:00
Florian Schmaus f380473edf systemctl-show: only show available memory if it was artifically limited
Systemd 255 changed the semantic of MemoryAvailable with 3565c709f5 ("cgroup:
Fix MemoryAvailable= by considering physical memory"). If there is no
artificial constraint, it will hold the amount of available physical memory,
while it previously contained UINT64_MAX.

While the change in MemoryAvailable's semantic is sensible, it causes
`systemctl status` to always display the available physical memory. This
creates a lot of noise, especially since systemd recently started to also show
the "peak" memory. For example

$ systemctl status foo
…
Memory: 3.9G (available: 21.2G peak: 5.4G)
…

However, while peak memory is a unit specific value, the available memory, when
not derived from artificial memory limits, is a generic property that holds the
same value for all units that are not under memory accounting
constraints. Displaying it under those circumstances can therefore be
considered being noisy.

Before 3565c709f5 ("cgroup: Fix MemoryAvailable= by considering physical
memory") "systemctl status" would only show the available memory if it was
caused by a explicit memory limitation due to MemoryHigh or MemoryMax.

This commit restores this behavior by supressing displaying the available
memory if is is merely the available phyiscal memory. For example

$ systemctl status foo
…
Memory: 3.9G (peak: 5.4G)
…

Fixes #30102.
2023-11-21 12:50:07 +00:00
Lennart Poettering 9b8b1d8b6b systemctl: also grey out useful hints in output, since no primary contents shown here 2023-11-20 13:05:50 +01:00
Lennart Poettering 891abc9cf1 systemctl: port to the new underline cell attribute
And be more careful when adding color to log lines:

1. Apply color derived from load state only to load state (and in
   special cases to the circle at the beginning of the line)

2. Apply color derived from active/sub states only to active/sub states
   (and in special cases to the circle at the beginning of the line)

3. Special case the "exited" state of services, i.e. make the substate
   grey, as in this case the service is active, yet consumes no
   resources.

4. Cover the "inactive" state properly, by greying it our too

5. Downgrade the load state of "not-found" from red to yellow, since
   it's not really a case one needs to be come active on.
2023-11-20 13:05:50 +01:00
Lennart Poettering 1a292659f2 Merge pull request #29995 from keszybz/voidify-timestamp-getters
Rename and voidify timestamp getters
2023-11-13 14:41:42 +01:00
Yu Watanabe 58cde42f65 core: rename MemoryZswapCurrent -> MemoryZSwapCurrent
Follow-up for 26caa66867.
2023-11-13 13:54:56 +01:00
Zbigniew Jędrzejewski-Szmek fa5a025167 Rename {dual,triple}_timestamp_get to {dual,triple}_timestamp_now
Those functions take a pointer to a timestamp and return a timestamp pointer,
so the reader would be justified to think that those are just getters. Rename
them to avoid confusion.
2023-11-13 13:27:07 +01:00
Florian Schmaus 7bf87a6477 systemctl-show: merge subsequent swap printf() blocks 2023-11-12 21:12:02 +01:00
Florian Schmaus 26caa66867 cgroup: add support for memory.zswap.current 2023-11-12 21:10:40 +01:00
Florian Schmaus 37533c9432 cgroup: add support for memory.swap.current
In systemctl-show we only show current swap if ever swapped or non-zero. This
reduces the noise on swapless systems, that would otherwise always show a swap
value that never has the chance to become non-zero. It further reduces the
noise for services that never swapped.
2023-11-11 12:16:29 +01:00
Florian Schmaus aac3384e56 cgroup: add support for memory.swap.peak 2023-11-11 12:14:07 +01:00
Lennart Poettering a338ccaa98 systemctl: grey out legend
The legend is not the primary information, but simply explanatory, hence
grey it out a bit.

This mimics what we do for pcrlock.
2023-11-07 20:07:43 +00:00
Florian Schmaus 6c71db763c cgroup: add support for memory.peak
Linux's Control Group v2 interfaces exposes memory.peak, which contains the
"max memory usage recorded for the cgroup and its descendants since the
creation of the cgroup."

This commit adds a new property "MemoryPeak" for units and makes "systemctl
show" display this value if it is available.

Fixes #29878.

Signed-off-by: Florian Schmaus <flo@geekplace.eu>
2023-11-06 18:08:33 +01:00
Lennart Poettering e9ccae3135 process-util: add new FORK_DEATHSIG_SIGKILL flag, rename FORK_DEATHSIG → FORK_DEATHSIG_SIGTERM
Sometimes it makes sense to hard kill a client if we die. Let's hence
add a third FORK_DEATHSIG flag for this purpose: FORK_DEATHSIG_SIGKILL.

To make things less confusing this also renames FORK_DEATHSIG to
FORK_DEATHSIG_SIGTERM to make clear it sends SIGTERM. We already had
FORK_DEATHSIG_SIGINT, hence this makes things nicely symmetric.

A bunch of users are switched over for FORK_DEATHSIG_SIGKILL where we
know it's safe to abort things abruptly. This should make some kernel
cases more robust, since we cannot get confused by signal masks or such.

While we are at it, also fix a bunch of bugs where we didn't take
FORK_DEATHSIG_SIGINT into account in safe_fork()
2023-11-02 14:09:23 +01:00
Lennart Poettering b71a721fbc parse-util: add parse_tristate() and use it everywhere
We parse tristates all the time, let's add an explicit parser for them.
2023-11-02 04:52:16 +09:00
Luca Boccassi 7470e161cf Merge pull request #29553 from keszybz/analyze-cat-config-tldr
analyze/cat-config: add switch to print only "interesting" parts of conffiles
2023-10-25 09:53:19 +01:00
Zbigniew Jędrzejewski-Szmek 063c838206 analyze/cat-config: add switch to print only "interesting" parts of config files
When looking at configuration, often a user wants to suppress the comments and
just look at the parts that actually configure something, roughly equivalent to
  systemd-analyze cat-config … | rg -v '^(#|;|$)
This switch implements this natively, skipping lines that start with a comment
character or only contain whitespace.

For formats that have section headers, section headers are skipped, if only
followed by stuff that would be skipped. (The last section header is printed
when we're about to print some actual output.)

Note that the caller doesn't know if the format has headers or not. We do format
type detection in pretty-print.c. So the caller only specifies tldr=true|false, and
conf_files_cat() figures out if the format has headers and whether those should
be handled specially.

The comments that show the file name are always printed, even if all of the file
is suppressed.

This is a partial answer to the discussions in
https://github.com/systemd/systemd/pull/28919,
https://github.com/systemd/systemd/pull/29248. If the default config is shown in
config files, the user can conveniently use '--tldr' to show the relevant parts.
2023-10-24 15:59:34 +02:00
Luca Boccassi d334c1211f systemctl: fallback if logind doesn't support new flag
Follow-up for 665a3d6d15
2023-10-23 19:43:15 +01:00
Luca Boccassi 665a3d6d15 systemctl: automatically softreboot/kexec if set up on reboot
Automatically softreboot if the nextroot has been set up with an OS
tree, or automatically kexec if a kernel has been loaded with kexec
--load.

Add SYSTEMCTL_SKIP_AUTO_KEXEC and SYSTEMCTL_SKIP_AUTO_SOFT_REBOOT to
skip the automated switchover.
2023-10-20 11:45:37 +01:00
Luca Boccassi 1ca8cc9fb6 Merge pull request #29595 from YHNdnzj/systemctl-failed-system
systemctl: is-failed: check if system is degraded when no unit given
2023-10-19 12:07:37 +01:00
Frantisek Sumsal 4820c9d417 fuzz: unify logging setup
Make sure we don't log anything when running in "fuzzing" mode. Also,
when at it, unify the setup logic into a helper, pretty similar to
the test_setup_logging() one.

Addresses:
  - https://github.com/systemd/systemd/pull/29558#pullrequestreview-1676060607
  - https://github.com/systemd/systemd/pull/29558#discussion_r1358940663
2023-10-19 10:05:20 +01:00
Mike Yuan 2ee346160c systemctl: is-failed: check if system is degraded when no unit given
Closes #3335
2023-10-19 00:12:28 +08:00
Mike Yuan def1e20a18 systemctl: minor modernization 2023-10-19 00:12:27 +08:00
Lennart Poettering d7d748548b process-util: add pidref_get_comm() and rename get_process_comm() to pid_get_comm() 2023-10-18 14:39:33 +02:00
G2-Games 4919967720 Fix a typo in systemctl-enable.c 2023-10-06 09:10:43 +02:00
Mike Yuan 4146960ee9 systemctl-show: align "Cntrl PID" correctly 2023-10-05 19:37:44 +01:00
Mike Yuan d708bb7c02 systemctl-enable: warn if disabled/masked units has active triggering units
Closes #311
2023-09-28 05:24:51 +08:00
Mike Yuan 0b675f97d6 systemctl-start: suppress the triggering unit warning when --no-warn 2023-09-28 05:24:51 +08:00
Mike Yuan 002db03f54 systemctl: clean up check_triggering_units
Preparation for #311
2023-09-28 05:24:51 +08:00
Mike Yuan 6ea32f61f3 systemctl: make unit_is_masked always query manager 2023-09-28 05:24:51 +08:00
Mike Yuan c36c81e467 systemctl: don't duplicate string needlessly 2023-09-28 05:14:42 +08:00
Mike Yuan 1f998158a9 systemctl: reflect that statically enabled units can be in .upholds/
Follow-up for 38f901791f
2023-09-28 05:14:42 +08:00
Zbigniew Jędrzejewski-Szmek 67bc612cbc systemctl: link to all non-man-page files in help
For file:// links, we urlify the link so that the user can click and either
open the file in a editor or some viewer. The detection is chosen via some
mechanism implemented by the terminal emulator. This seems too DTRT for text
files and PDFs, which should cover the majority of realistic cases. If the file
is not viable, the terminal emulator will say
  "Could not open file://…. No application is registered to view this file type."
or similar.

For all other links, which are primarily http:// and https://, we just show the
link, letting the terminal handle the hyperlinking. The user can then ctrl-click
and open the file it their browser. If we tried to open the files automatically,
we'd would need to open many pages, and we'd need to figure out what browser to
use, etc. When the user picks whether to open the file, this leads to a nicer
user experience.

Man pages are separated by an empty line from preceding in and following output.
In my testing, this makes the output easier to read. A bit of explicit flushing
is needed to make sure that various outputs are not interleaved.

Fixes https://github.com/systemd/systemd/issues/29061.
2023-09-21 18:09:48 +02:00
Joerg Behrmann 7c52d5236a treewide: split commandline into command line 2023-09-20 16:37:23 +01:00
Mike Yuan e22c60a9d5 io-util: introduce loop_write_full that takes a timeout
Also drop do_poll as the use case is covered
by timeout.
2023-09-07 20:30:44 +08:00
Mike Yuan 11da61658f systemctl: drop unnecessary else
Follow-up for 8a826a979a
2023-09-05 12:55:45 +08:00