Commit graph

265 commits

Author SHA1 Message Date
Lennart Poettering 03a7b521e3 core: add support for the "pids" cgroup controller
This adds support for the new "pids" cgroup controller of 4.3 kernels.
It allows accounting the number of tasks in a cgroup and enforcing
limits on it.

This adds two new setting TasksAccounting= and TasksMax= to each unit,
as well as a gloabl option DefaultTasksAccounting=.

This also updated "cgtop" to optionally make use of the new
kernel-provided accounting.

systemctl has been updated to show the number of tasks for each service
if it is available.

This patch also adds correct support for undoing memory limits for units
using a MemoryLimit=infinity syntax. We do the same for TasksMax= now
and hence keep things in sync here.
2015-09-10 18:41:06 +02:00
Lennart Poettering 525d3cc746 tree-wide: take benefit of the fact that hashmap_free() returns NULL
And set_free() too.

Another Coccinelle patch.
2015-09-09 23:12:07 +02:00
Daniel Mack 01da201420 Merge pull request #1218 from poettering/safe-fclose
util: introduce safe_fclose() and port everything over to it
2015-09-09 15:45:03 +02:00
Lennart Poettering 74ca738f6a util: introduce safe_fclose() and port everything over to it
Adds a coccinelle script to port things over automatically.
2015-09-09 15:26:11 +02:00
Daniel Mack d7acddde05 Merge pull request #1216 from poettering/coccinelle-fixes-2
Coccinelle fixes 2
2015-09-09 15:12:28 +02:00
Lennart Poettering 1f6b411372 tree-wide: update empty-if coccinelle script to cover empty-while and more
Let's also clean up single-line while and for blocks.
2015-09-09 14:59:51 +02:00
Daniel Mack bcce71873b core: freeze execution if /etc/mtab exists
The mount monitor that was added to libmount v2.27 requires /etc/mtab to be
non-existant. As systemd now uses that functionality, we cannot monitor any
mounts anymore, and hence not support .mount units.

Systems that have /etc/mtab around as regular file are unsupported by
systemd since a long time.

This patch makes that condition fatal, so we do not boot up with
non-working mount monitor support.
2015-09-09 14:00:23 +02:00
Lennart Poettering ece174c543 tree-wide: drop {} from one-line if blocks
Patch via coccinelle.
2015-09-09 08:20:20 +02:00
Lennart Poettering a1e58e8ee1 tree-wide: use coccinelle to patch a lot of code to use mfree()
This replaces this:

        free(p);
        p = NULL;

by this:

        p = mfree(p);

Change generated using coccinelle. Semantic patch is added to the
sources.
2015-09-09 08:19:27 +02:00
Lennart Poettering 75f86906c5 basic: rework virtualization detection API
Introduce a proper enum, and don't pass around string ids anymore. This
simplifies things quite a bit, and makes virtualization detection more
similar to architecture detection.
2015-09-07 13:42:47 +02:00
Lennart Poettering b85ec419cb Merge pull request #1098 from filbranden/cpuaffinity2
Getting rid of FOREACH_WORD_QUOTED and some more cleanup in config_parse_cpu_affinity2
2015-09-01 20:52:52 +02:00
Filipe Brandenburger 5cc623e644 core: Log parse errors in config_parse_cpu_affinity2 2015-09-01 11:10:09 -07:00
Tom Gundersen fc94c32605 Merge pull request #1111 from poettering/more-cgroup-fixes
More cgroup fixes
2015-09-01 19:48:04 +02:00
Lennart Poettering e155a0aa04 cgroup: small cleanups and coding style fixes
A number of simplications and adjustments to brings things closer to our
coding style.
2015-09-01 18:37:01 +02:00
Filipe Brandenburger 1592ec21b3 core: add OOM check in config_parse_join_controllers 2015-09-01 08:35:54 -07:00
Filipe Brandenburger 3875c85bae core: Log parse errors in config_parse_join_controllers 2015-09-01 08:35:54 -07:00
Filipe Brandenburger d4ebeb4fb3 core: Use extract_first_word in config_parse_join_controllers
Related to the TODO item to replace FOREACH_WORD_QUOTED with it.

Tested by setting `JoinControllers=cpu,cpuacct,memory net_cls,blkio' in
/etc/systemd/system.conf, rebooting the system with the patched binaries
and checking that the desired setup was created by inspecting the
entries under /sys/fs/cgroup.

No regressions observed in test cases.
2015-08-31 17:33:35 -07:00
Filipe Brandenburger 4b40bc38b4 util: Declare a cleanup routine for a cpu_set_t
Make use of it in config_parse_cpu_affinity2.

Tested by tweaking the `CPUAffinity' setting in /etc/systemd/system.conf
and reloading the daemon to confirm it is working as expected.

No regressions observed in test cases.
2015-08-31 17:15:56 -07:00
Filipe Brandenburger 4457c2279e core: Use extract_first_word in config_parse_cpu_affinity2
Related to the TODO item to replace FOREACH_WORD_QUOTED with it.

Tested by setting `CPUAfinity=0 1' (and other similar settings) in
/etc/systemd/system.conf, booting the system with the patched binaries
(and also using `systemctl daemon-reload` to reconfigure) and checking
that /proc/1/status indicates only CPUs 0 and 1 are allowed for PID 1.

No regressions observed in test cases.
2015-08-31 17:15:56 -07:00
Lennart Poettering 6513d561ce core: use DUAL_TIMESTAMP_NULL where we can 2015-08-31 13:20:43 +02:00
Jan Pokorný 6b9af96321
core: s/reexection/reexecution/ typo fix
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2015-08-07 17:13:15 +02:00
David Herrmann 97b11eedff tree-wide: introduce mfree()
Pretty trivial helper which wraps free() but returns NULL, so we can
simplify this:
        free(foobar);
        foobar = NULL;
to this:
        foobar = mfree(foobar);
2015-07-31 19:56:38 +02:00
Thomas Blume 06af2a04fb Reload manager defaults at daemon-reload
"systemctl daemon-reload" should also update the manager defaults from
/etc/systemd/system.conf.
For details, see:
http://lists.freedesktop.org/archives/systemd-devel/2015-June/033062.html

Amended to use  manager_set_defaults() as common function.
2015-07-09 10:22:30 +02:00
Daniel Mack 4c1fc3e404 fileio: consolidate write_string_file*()
Merge write_string_file(), write_string_file_no_create() and
write_string_file_atomic() into write_string_file() and provide a flags mask
that allows combinations of atomic writing, newline appending and automatic
file creation. Change all users accordingly.
2015-07-06 19:19:25 -04:00
Iago López Galeiras 10f00ff17b core: handle --log-target=null when calling systemd-shutdown
When shutting down, if systemd was started with --log-target=null,
systemd-shutdown was being called with --log-target=console.
2015-06-30 15:13:57 +02:00
Lennart Poettering ce30c8dcb4 tree-wide: whenever we fork off a foreign child process reset signal mask/handlers
Also, when the child is potentially long-running make sure to set a
death signal.

Also, ignore the result of the reset operations explicitly by casting
them to (void).
2015-06-10 01:28:58 +02:00
Cristian Rodríguez 61b9b203fe core: Remove "old kernel" warning if PR_SET_CHILD_SUBREAPER fails
This made sense when systemd ran on older kernels, nowdays not so much.
2015-06-05 04:06:39 -03:00
Lennart Poettering 24882e06c1 util: split out signal-util.[ch] from util.[ch]
No functional changes.
2015-05-29 20:14:11 +02:00
Jonathan Boulle d250afe73d fix extraneous space in equality check 2015-05-27 23:36:29 +02:00
Dimitri John Ledkov 304b3079a2 core: Execute first boot presets in an enable-only preset-mode.
This means any existing enabled units well be preserved and no
pre-created symlinks will be removed. This is done on first boot, when
the assumption is that /etc is not populated at all (no machine-id
setup). For minimal containers that gives a significant first boot
speed up, approximately ~20ms / ~16% in my trials.
2015-05-15 12:49:33 +02:00
Lennart Poettering b2c23da8ce core: rename SystemdRunningAs to ManagerRunningAs
It's primarily just a property of the Manager object after all, and we
try to refer to PID 1 as "manager" instead of "systemd", hence let's to
stick to this here too.
2015-05-11 22:51:49 +02:00
Lennart Poettering f2341e0a87 core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.

Also contains a couple of other logging improvements:

- Drops a couple of strerror() invocations in favour of using %m.

- Not only .mount units now warn if a symlinks exist for the mount
  point already, .automount units do that too, now.

- A few invocations of log_struct() that didn't actually pass any
  additional structured data have been replaced by simpler invocations
  of log_unit_info() and friends.

- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
  that works like LOG_MESSAGE() but prefixes the message with the unit
  name. Similar, there's now LOG_LINK_MESSAGE() and
  LOG_NETDEV_MESSAGE().

- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
  LOG_NETDEV_INTERFACE() macros have been added that generate the
  necessary per object fields. The old log_unit_struct() call has been
  removed in favour of these new macros used in raw log_struct()
  invocations. In addition to removing one more function call this
  allows generated structured log messages that contain two object
  fields, as necessary for example for network interfaces that are
  joined into another network interface, and whose messages shall be
  indexed by both.

- The LOG_ERRNO() macro has been removed, in favour of
  log_struct_errno(). The latter has the benefit of ensuring that %m in
  format strings is properly resolved to the specified error number.

- A number of logging messages have been converted to use
  log_unit_info() instead of log_info()

- The client code in sysv-generator no longer #includes core code from
  src/core/.

- log_unit_full_errno() has been removed, log_unit_full() instead takes
  an errno now, too.

- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
  avoid double evaluation of their parameters
2015-05-11 22:24:45 +02:00
Torstein Husebø ff9b60f38b treewide: Correct typos and spell plural of bus consistent 2015-05-11 15:51:30 +02:00
Ronny Chevalier 288a74cce5 shared: add terminal-util.[ch] 2015-04-11 00:34:02 +02:00
Ronny Chevalier 0b452006de shared: add process-util.[ch] 2015-04-10 23:54:49 +02:00
Ronny Chevalier 6482f6269c shared: add formats-util.h 2015-04-10 23:54:48 +02:00
Jasper St. Pierre 031886edfc core: Remove explicit Plymouth integration
Even if plymouth is running, it might have not displayed the splash yet,
so we'll see a few lines on fbcon when we should have otherwise had
nothing.

Plymouth integration was added to systemd in commit
6faa11140b. That same day, Plymouth got
systemd integration [0]. As such, the Plymouth integration has always
been obsolete, and was probably only for older Plymouth's. But I can't
imagine anybody running a Plymouth from 2011 with a systemd from 2015.

Remove the Plymouth/systemd integration, and let Plymouth's code tell
systemd to print the details.

[0] http://cgit.freedesktop.org/plymouth/commit/?id=537c16422cd49f1beeaab1ad39846a00018faec1

Signed-off-by: Jasper St. Pierre <jstpierre@mecheye.net>
Cc: Daniel Drake <dsd@endlessm.com>
Cc: Ray Strode <rstrode@redhat.com>
2015-03-16 17:47:27 +01:00
Zbigniew Jędrzejewski-Szmek e62d9b8192 Add (void) where we don't care about return value 2015-03-15 17:26:58 -04:00
Zbigniew Jędrzejewski-Szmek d3f8667978 core: do not use quotes around virt and arch
Quotes are useful when the string can contain spaces or be otherwise
confusing. Not possible with those two.
2015-03-14 23:03:21 -04:00
Thomas Hindoe Paaboel Andersen 2eec67acbb remove unused includes
This patch removes includes that are not used. The removals were found with
include-what-you-use which checks if any of the symbols from a header is
in use.
2015-02-23 23:53:42 +01:00
Lennart Poettering d5d8429a12 everywhere: remove configurability of sysv runlevel to target mapping
With this change runlevel 2, 3, 4 are mapped to multi-user.target for
good, and 5 to graphical.target. This was already the previous mapping
but is now no longer reconfigurable, but hard-coded into the core.

This should generally simplify things, but also fix one bug: the
sysv-generator previously generated symlinks to runlevel[2-5].target
units, which possibly weren't picked up if these aliases were otherwise
only referenced by the real names "multi-user.target" and
"graphical.target".

We keep compat aliases "runlevel[2345].target" arround for cases where
this target name is explicitly requested.
2015-02-18 20:20:14 +01:00
Lennart Poettering c2cc6b9aef core: disarm shutdown watchdog if we fail to set timeout
Better safe than sorry, if drivers are stupid, and reset immediately on
device closing if the timeout could not be initialized.

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=777735
2015-02-12 12:28:48 +01:00
Lennart Poettering 5e07a79e84 core: don't reset log level to NOTICE if we get quiet on the kernel cmdline
quiet should really just have an effect on the stuff we dump on the
console, not what we log elsewhere.

Hence:

        debug on kernel cmdline → interpreted by every tool, turns up
        log levels to "debug" everywhere.

        quiet on kernel cmdline → interpreted only by PID 1 (and
        obviously the kernel) no alteration of the max log level, but
        turns off status output.

http://lists.freedesktop.org/archives/systemd-devel/2014-December/026271.html
2015-02-04 01:47:31 +01:00
Lennart Poettering 86caf09519 core: use some nice macros where appropriate 2015-02-03 18:16:35 +01:00
Zbigniew Jędrzejewski-Szmek 5ffa8c8181 Add a snprinf wrapper which checks that the buffer was big enough
If we scale our buffer to be wide enough for the format string, we
should expect that the calculation was correct.

char_array_0() invocations are removed, since snprintf nul-terminates
the output in any case.

A similar wrapper is used for strftime calls, but only in timedatectl.c.
2015-02-01 17:21:39 -05:00
Maxim Mikityanskiy 81f5fc2d43 core: make setting the shutdown watchdog configuration via dbus work
https://bugs.freedesktop.org/show_bug.cgi?id=88284
2015-01-30 18:48:18 -05:00
Kay Sievers 82c28f5621 Revert "core: make setting the shutdown watchdog configuration via dbus work"
This reverts commit df6e44c4af.

systemd --version segfaults.

Starting program: /usr/lib/systemd/systemd --version
Missing separate debuginfos, use: debuginfo-install systemd-216-16.fc21.x86_64
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
systemd 218
+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ -LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN

Program received signal SIGSEGV, Segmentation fault.
0x000055555557c9be in main (argc=2, argv=0x7fffffffe4d8) at src/core/main.c:1832
1832            arg_shutdown_watchdog = m->shutdown_watchdog;
(gdb) bt
(gdb) bt full
        m = 0x0
2015-01-30 10:59:47 +01:00
Maxim Mikityanskiy df6e44c4af core: make setting the shutdown watchdog configuration via dbus work
https://bugs.freedesktop.org/show_bug.cgi?id=88284
2015-01-29 01:23:50 +01:00
Lennart Poettering 297d563de4 core: explain why failing to set up the crash handler is not a real problem
http://lists.freedesktop.org/archives/systemd-devel/2015-January/027428.html
2015-01-27 01:49:09 +01:00
Michael Biebl 8b173b5e8c core: fix typo in log message 2015-01-05 14:13:45 +01:00