diff options
author | Lennart Poettering <lennart@poettering.net> | 2020-04-21 13:04:39 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2020-04-21 16:31:06 +0200 |
commit | 33b58dfb41a0c0db8110f1fc6dd0fc54e0d9cd4a (patch) | |
tree | 0b9c6cf2eba761ea80e64452cfb63835a4a8d300 | |
parent | Merge pull request #15508 from keszybz/add-dbus-entities-to-index (diff) | |
download | systemd-33b58dfb41a0c0db8110f1fc6dd0fc54e0d9cd4a.tar.xz systemd-33b58dfb41a0c0db8110f1fc6dd0fc54e0d9cd4a.zip |
core: automatically add udev dependency for units using RootImage=
We use udev to wait for /dev/loopX devices to be fully proped hence we
need an implicit ordering dependency on it, for RootImage= to work
reliably in early boot, too.
Fixes: #14972
-rw-r--r-- | man/systemd.exec.xml | 3 | ||||
-rw-r--r-- | src/basic/special.h | 1 | ||||
-rw-r--r-- | src/core/unit.c | 9 |
3 files changed, 13 insertions, 0 deletions
diff --git a/man/systemd.exec.xml b/man/systemd.exec.xml index 54b07e3004..4d85b6aec0 100644 --- a/man/systemd.exec.xml +++ b/man/systemd.exec.xml @@ -139,6 +139,9 @@ <varname>PrivateDevices=</varname> below, as it may change the setting of <varname>DevicePolicy=</varname>.</para> + <para>Units making use of <varname>RootImage=</varname> automatically gain an + <varname>After=</varname> dependency on <filename>systemd-udevd.service</filename>.</para> + <xi:include href="system-only.xml" xpointer="singular"/></listitem> </varlistentry> diff --git a/src/basic/special.h b/src/basic/special.h index 0eb3f3a368..19ee30cd41 100644 --- a/src/basic/special.h +++ b/src/basic/special.h @@ -82,6 +82,7 @@ #define SPECIAL_QUOTAON_SERVICE "quotaon.service" #define SPECIAL_REMOUNT_FS_SERVICE "systemd-remount-fs.service" #define SPECIAL_VOLATILE_ROOT_SERVICE "systemd-volatile-root.service" +#define SPECIAL_UDEVD_SERVICE "systemd-udevd.service" /* Services systemd relies on */ #define SPECIAL_DBUS_SERVICE "dbus.service" diff --git a/src/core/unit.c b/src/core/unit.c index f8fb01e3b1..242309e47f 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -1079,6 +1079,15 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) { return r; } + if (c->root_image) { + /* We need to wait for /dev/loopX to appear when doing RootImage=, hence let's add an + * implicit dependency on udev */ + + r = unit_add_dependency_by_name(u, UNIT_AFTER, SPECIAL_UDEVD_SERVICE, true, UNIT_DEPENDENCY_FILE); + if (r < 0) + return r; + } + if (!IN_SET(c->std_output, EXEC_OUTPUT_JOURNAL, EXEC_OUTPUT_JOURNAL_AND_CONSOLE, EXEC_OUTPUT_KMSG, EXEC_OUTPUT_KMSG_AND_CONSOLE, |