diff options
author | Franck Bui <fbui@suse.com> | 2018-04-17 15:12:06 +0200 |
---|---|---|
committer | Franck Bui <fbui@suse.com> | 2018-04-20 17:49:28 +0200 |
commit | 036d2eefaee2b64e7946ef19de9b0b94b60e8955 (patch) | |
tree | dfcc517362bf25c3643b19618266c7461fca59ee /src/core/device.c | |
parent | device: make sure to always retroactively start device dependencies (diff) | |
download | systemd-036d2eefaee2b64e7946ef19de9b0b94b60e8955.tar.xz systemd-036d2eefaee2b64e7946ef19de9b0b94b60e8955.zip |
device: skip deserialization of device units when udevd is not running
Do not try to party initialize a device during deserialization if it's not
known by udev (anymore) and therefore hasn't been seen during device
enumeration.
The device unit in this case has not been initialized properly and setting it
in the "plugged" state can be confusing.
Actually this happens during every boots when PID switches to the new rootfs:
PID is reexecuted and enumerates devices but since udev is not running, the
list of enumerated devices is empty.
Diffstat (limited to 'src/core/device.c')
-rw-r--r-- | src/core/device.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/core/device.c b/src/core/device.c index aafc97ffd4..12dccdb975 100644 --- a/src/core/device.c +++ b/src/core/device.c @@ -173,6 +173,18 @@ static int device_deserialize_item(Unit *u, const char *key, const char *value, assert(value); assert(fds); + /* The device was known at the time units were serialized but it's not + * anymore at the time units are deserialized. This happens when PID1 is + * re-executed after having switched to the new rootfs: devices were + * enumerated but udevd wasn't running yet thus the list of devices + * (handled by systemd) to initialize was empty. In such case we wait + * for the device events to be re-triggered by udev so device units are + * properly re-initialized. */ + if (d->found == DEVICE_NOT_FOUND) { + assert(d->sysfs == NULL); + return 0; + } + if (streq(key, "state")) { DeviceState state; |