Commit Graph

1022 Commits

Author SHA1 Message Date
Kevin Kuehler 3a77f9fb4c systemctl: Default suffixes for timer and socket
* use .timer suffix by default for systemctl list-timers
* use .socket suffix by default for systemctl list-sockets
2019-10-04 08:27:56 +02:00
Pavel Hrdina 047f5d63d7 cgroup: introduce support for cgroup v2 CPUSET controller
Introduce support for configuring cpus and mems for processes using
cgroup v2 CPUSET controller.  This allows users to limit which cpus
and memory NUMA nodes can be used by processes to better utilize
system resources.

The cgroup v2 interfaces to control it are cpuset.cpus and cpuset.mems
where the requested configuration is written.  However, it doesn't mean
that the requested configuration will be actually used as parent cgroup
may limit the cpus or mems as well.  In order to reflect the real
configuration cgroup v2 provides read-only files cpuset.cpus.effective
and cpuset.mems.effective which are exported to users as well.
2019-09-24 15:16:07 +02:00
Anita Zhang 898fc00e79 core: add ExecXYZEx= bus hook ups to all exec command properties
The "Ex" variant was originally only added for ExecStartXYZ= but it makes
sense to have feature parity for the rest of the exec command properties
as well (e.g. ExecReload=, ExecStop=, etc).
2019-09-17 15:48:44 +00:00
Zbigniew Jędrzejewski-Szmek 4c70211c5a systemctl: use unicode in one more place 2019-08-19 10:17:49 +02:00
Ronan Pigott 46ff70ca69 systemctl: Add unit file states to state help message 2019-08-06 08:38:43 +02:00
Lennart Poettering 5756bff6f1
Merge pull request #13119 from keszybz/unit-loading-2
Rework unit loading to take into account all aliases
2019-07-30 17:55:37 +02:00
Zbigniew Jędrzejewski-Szmek 91e0ee5f16 pid1: drop unit caches only based on mtime
v2:
- do not watch mtime of transient and generated dirs

  We'd reload the map after every transient unit we created, which we don't
  need to do, since we create those units ourselves and know their fragment
  path.
2019-07-30 14:01:46 +02:00
Zbigniew Jędrzejewski-Szmek e8630e6952 pid1: use a cache for all unit aliases
This reworks how we load units from disk. Instead of chasing symlinks every
time we are asked to load a unit by name, we slurp all symlinks from disk
and build two hashmaps:
1. from unit name to either alias target, or fragment on disk
   (if an alias, we put just the target name in the hashmap, if a fragment
    we put an absolute path, so we can distinguish both).
2. from a unit name to all aliases

Reading all this data can be pretty costly (40 ms) on my machine, so we keep it
around for reuse.

The advantage is that we can reliably know what all the aliases of a given unit
are. This means we can reliably load dropins under all names. This fixes #11972.
2019-07-30 14:01:46 +02:00
Lennart Poettering e04ed6db6b exit-status: rename EXIT_STATUS_GLIBC → EXIT_STATUS_LIBC
After all these two exit codes are defined by ISO C as part of the C
library, and it's not the GNU implementation defines them.
2019-07-29 19:05:25 +02:00
Zbigniew Jędrzejewski-Szmek 148ffa2e4d systemctl: do print all statuses/signals received from pid1
If for some reason we do not know some signal, instead of silently
skipping it, let's print it numerically. Likewise, 'show' is not the
right place to do value filtering for exit codes. If pid1 accepted it,
let's just print it with no fuss.
2019-07-29 15:54:53 +02:00
Zbigniew Jędrzejewski-Szmek 62b21e2e89 shared/bus-util: fix dbus serialization of {RestartPrevent,RestartForce,Success}ExitStatus
We were passing 1/4th of the size in bytes as argument. So depending
on the size of the array, either we'd only transfer a subset of values,
or we'd get an alignment error.
2019-07-29 15:54:53 +02:00
Zbigniew Jędrzejewski-Szmek e1714f0250 shared/exit-status: turn status level into a bitmask, add "test"
The "test" doesn't really test much automatically, but it is still useful
to look at the mappings.
2019-07-29 15:54:45 +02:00
Anita Zhang e5c8524447 [systemctl] Don't print ExecXYZEx= when doing 'systemctl status'
The info printed in this function is the same as the non-Ex version of the
property so there's no point double printing.

Other places that print ExecXYZEx= properties are left alone since the
displayed information is different.
2019-07-24 09:00:57 +02:00
Zbigniew Jędrzejewski-Szmek 6176e89c20 systemctl: call the unit dbus path dbus_path everywhere
Similar variables had differing names: unit, path, unit_path. We also
have file system paths in surrounding code. Let's make this easier for
the reader and use "dbus_path" consistently.
2019-07-17 14:35:35 +02:00
Zbigniew Jędrzejewski-Szmek 043fdc4010 pid1: kill unit_file_find_dropin_paths() helper
It had two users, but it is just a very thin wrapper around
unit_file_find_dropin_paths(), so using it seems more complicated than directly
invoking unit_file_find_dropin_paths() twice.
2019-07-17 14:27:23 +02:00
Zbigniew Jędrzejewski-Szmek 3151b668c2
Merge pull request #13076 from keszybz/pr/13062
Timer formatting fixes
2019-07-16 20:02:26 +02:00
Zbigniew Jędrzejewski-Szmek 860f2be059 systemctl: print non-elapsing timers as "n/a" not "(null)"
TimersCalendar={ OnCalendar=1970-01-01 00:00:00 UTC ; next_elapse=(null) }
 ↓
TimersCalendar={ OnCalendar=1970-01-01 00:00:00 UTC ; next_elapse=n/a }
2019-07-16 14:29:04 +02:00
Lennart Poettering f200a3564c
Merge pull request #13063 from keszybz/cgroup-path-fixes
Cgroup path fixes
2019-07-16 11:53:31 +02:00
Yu Watanabe 8cec0a5c32 tree-wide: drop duplicated blank lines
```
$ for i in */*.[ch] */*/*.[ch]; do sed -e '/^$/ {N; s/\n$//g}' -i $i; done
$ git checkout HEAD -- basic/linux shared/linux
```
2019-07-15 18:41:27 +02:00
Zbigniew Jędrzejewski-Szmek 107c20518b systemctl: emit warning when we get an invalid process entry from pid1 and continue
Output looks like this:
Invalid process description in GetUnitProcesses reply: cgroup="machine.slice/machine-rawhide.scope/payload/system.slice/systemd-journald.service" pid=638367 command="/usr/lib/systemd/systemd-journald", ignoring: Invalid argument
2019-07-15 18:39:05 +02:00
Alan Jenkins 8eb0cafeb0 systemctl: do not suggest passing --all if the user passed --state=
"systemctl --failed" suggested I pass "--all" to see units in the inactive
state as well.  I thought this was not very useful.  If you explicitly
asked for units in a specific state, then you already know you have
narrowed it down.  And if you ran "systemctl --state=inactive", it is even
more strange to see this message.

@keszybz suggests we probably don't want to suggest "list-unit-files"
either :-).  Let's only suggest that if the user passed "--state=inactive".

Finally, this means the output for "systemctl --failed" could be just
"0 loaded units listed".  In this case, we don't need any highlight on that
text, to distinguish it from the hint.  This matches "list-unit-files".
This also means we happen to avoid using red highlight, when there are zero
failed units, as if that itself was a failure.  @kesbyz pointed out that
old behaviour was a bit weird.
2019-07-15 13:37:29 +02:00
Lennart Poettering 2caa38e99f tree-wide: some more [static] related fixes
let's add [static] where it was missing so far

Drop [static] on parameters that can be NULL.

Add an assert() around parameters that have [static] and can't be NULL
hence.

Add some "const" where it was forgotten.
2019-07-12 16:40:10 +02:00
Lennart Poettering b910cc72c0 tree-wide: get rid of strappend()
It's a special case of strjoin(), so no need to keep both. In particular
as typing strjoin() is even shoert than strappend().
2019-07-12 14:31:12 +09:00
Lennart Poettering a7056cde56 systemctl: port "systemctl start --wait" logic to new bus-wait-for-units.c API 2019-07-11 12:18:51 +02:00
Lennart Poettering d81bc51fe3 systemctl: add new "clean" operation to systemctl
This exposes the CleanUnit() bus calls in systemctl, i.e. makes all the
infrastructure we previously added useful to people.
2019-07-11 12:18:51 +02:00
Lennart Poettering ba40f0399e
Merge pull request #12939 from yuwata/lgtm-fixes
make LGTM quiet
2019-07-10 14:57:14 +02:00
Zbigniew Jędrzejewski-Szmek e04df06f58 systemctl: allow "cat" on units with bad settings
That's precisely the state where 'cat' is particularly useful ;).
2019-07-10 12:32:52 +02:00
Yu Watanabe 4bbccb02ea tree-wide: introduce strerror_safe() 2019-07-05 02:43:56 +09:00
Zbigniew Jędrzejewski-Szmek 1f65fd4926 basic/time-util: add helper function to check if timestamp is set
No functional change.
2019-07-04 19:12:47 +02:00
Lennart Poettering 05b2ace147
Merge pull request #12870 from yuwata/tree-wide-further-path-join-cleanups
tree-wide: further path_join() and path_joina() cleanups
2019-06-25 09:27:01 +02:00
Yu Watanabe 270384b2d4 tree-wide: replace strjoina() with prefix_roota() 2019-06-25 01:31:26 +09:00
Michal Sekletar b070c7c0e1 core: introduce NUMAPolicy and NUMAMask options
Make possible to set NUMA allocation policy for manager. Manager's
policy is by default inherited to all forked off processes. However, it
is possible to override the policy on per-service basis. Currently we
support, these policies: default, prefer, bind, interleave, local.
See man 2 set_mempolicy for details on each policy.

Overall NUMA policy actually consists of two parts. Policy itself and
bitmask representing NUMA nodes where is policy effective. Node mask can
be specified using related option, NUMAMask. Default mask can be
overwritten on per-service level.
2019-06-24 16:58:54 +02:00
Yu Watanabe 657ee2d82b tree-wide: replace strjoin() with path_join() 2019-06-21 03:26:16 +09:00
Chris Down aa91d5925a systemctl: Prevent state_missing from being used uninit 2019-06-07 06:33:35 +01:00
Yu Watanabe 042526868a
Merge pull request #12508 from keszybz/no-root-checks
Drop many root checks
2019-06-06 21:31:19 +09:00
Anita Zhang b3d593673c core: add ExecStartXYZEx= with dbus support for executable prefixes
Closes #11654
2019-05-30 20:41:42 -07:00
Frantisek Sumsal 4eb5312079 systemctl: process all units matched by a glob in the cat verb by default
Originally, `systemctl cat` would match only active units, for example:

$ systemctl cat sshd.service

would cat the sshd.service unit file even if the service was inactive.
However:

$ systemctl cat ssh*

would show it only if it was active.

Let's unify the behavior and cat all unit files regardless of a state,
if no state was given explicitly to filter.
2019-05-30 21:11:44 +02:00
Michal Sekletar a047f4f10e systemctl: present CPUAffinity mask as a list of CPU index ranges 2019-05-29 17:02:24 +02:00
Zbigniew Jędrzejewski-Szmek 4bea24696a systemctl: show a hint if root privileges might yield more information 2019-05-08 11:51:51 +02:00
Zbigniew Jędrzejewski-Szmek a004cb75c0 systemctl: drop one must_be_root_check()
(before)
$ build/systemctl list-machines
Need to be root.
$ sudo build/systemctl list-machines
NAME          STATE   FAILED JOBS
krowka (host) running      0    0
rawhide       running      0    0

2 machines listed.

(after)
$ build/systemctl list-machines
NAME          STATE   FAILED JOBS
krowka (host) running      0    0
rawhide       n/a          0    0

2 machines listed.

The output for non-root is missing some bits of information, but we display
what information is missing nicely, and e.g. in the case when no machines are
running at all, or only VMs are running, the unprivileged output would be the
same as the privileged one.
2019-05-08 11:51:51 +02:00
Ben Boeckel 5238e95759 codespell: fix spelling errors 2019-04-29 16:47:18 +02:00
Zbigniew Jędrzejewski-Szmek c5b7ae0edb
Merge pull request #12074 from poettering/io-acct
expose IO stats on the bus and in "systemctl status" and "systemd-run --wait"
2019-04-25 11:59:37 +02:00
Chris Down 7ad5439e06 unit: Add DefaultMemoryMin 2019-04-16 18:45:04 +01:00
Chris Down c52db42b78 cgroup: Implement default propagation of MemoryLow with DefaultMemoryLow
In cgroup v2 we have protection tunables -- currently MemoryLow and
MemoryMin (there will be more in future for other resources, too). The
design of these protection tunables requires not only intermediate
cgroups to propagate protections, but also the units at the leaf of that
resource's operation to accept it (by setting MemoryLow or MemoryMin).

This makes sense from an low-level API design perspective, but it's a
good idea to also have a higher-level abstraction that can, by default,
propagate these resources to children recursively. In this patch, this
happens by having descendants set memory.low to N if their ancestor has
DefaultMemoryLow=N -- assuming they don't set a separate MemoryLow
value.

Any affected unit can opt out of this propagation by manually setting
`MemoryLow` to some value in its unit configuration. A unit can also
stop further propagation by setting `DefaultMemoryLow=` with no
argument. This removes further propagation in the subtree, but has no
effect on the unit itself (for that, use `MemoryLow=0`).

Our use case in production is simplifying the configuration of machines
which heavily rely on memory protection tunables, but currently require
tweaking a huge number of unit files to make that a reality. This
directive makes that significantly less fragile, and decreases the risk
of misconfiguration.

After this patch is merged, I will implement DefaultMemoryMin= using the
same principles.
2019-04-12 17:23:58 +02:00
Lennart Poettering 7a5de3f951 systemctl: show IO stats in 'status' output 2019-04-12 14:25:44 +02:00
Lennart Poettering d2e1b2fd67 systemctl: print a more accurate error message when we can 2019-04-02 05:44:12 +09:00
Lennart Poettering 8a016c746e util-lib: when copying files make sure to apply some chattrs early, some late
Some chattrs only work sensible if you set them right after opening a
file for create (think: FS_NOCOW_FL). Others only work when they are
applied when the file is fully written (think: FS_IMMUTABLE_FL). Let's
take that into account when copying files and applying a chattr to them.
2019-03-28 18:43:04 +01:00
Lennart Poettering 85d9b5981b systemctl: add new --show-transaction switch
This new switch uses the new method call EnqueueUnitJob() for enqueuing
a job and showing the jobs it enqueued.

Fixes: #2297
2019-03-27 12:37:37 +01:00
Lennart Poettering 94369fc066 systemctl: split out extra args generation into helper function of its own 2019-03-27 12:37:37 +01:00
Lennart Poettering 5fd77930ad systemctl: reindent table 2019-03-27 12:37:37 +01:00