[systemd-devel] /sys/subsystem device dependency not working

Albert Strasheim fullung at gmail.com
Thu Aug 18 13:03:14 PDT 2011


Hello all

I am trying to use systemd-26 to configure a network device.

I've decided to try this instead of the standard Fedora init scripts
because I want the network configuration to depend on a kernel command
line argument (which should be possible as soon as
ConditionKernelCommandLine=foo=bar gets fixed) and some files that are
generated during bootup.

I spotted the following in /lib/udev/rules.d/99-systemd.rules:

SUBSYSTEM=="net", KERNEL!="lo", TAG+="systemd",
ENV{SYSTEMD_ALIAS}="/sys/subsystem/net/devices/%k"

I understood this and the comment above it to mean that I could add a
dependency on sys-subsystem-net-devices-em2.device to my service that
configures the device.

I have a foo-configure.service that runs to generate some files:

[Unit]
Description=Configure the Next system
DefaultDependencies=no
Conflicts=shutdown.target
Wants=foo-net.target
Before=foo-net.target multi-user.target shutdown.target
After=local-fs.target

[Service]
ExecStart=/opt/foo/systemd/foo-configure
ExecStart=/bin/hostname --file /etc/hostname
Type=oneshot
TimeoutSec=0
RemainAfterExit=yes

[Install]
WantedBy=basic.target

foo-configure writes /etc/hostname and
/etc/sysconfig/network-scripts/foo based on IPMI configuration of the
machine.

foo-net.target contains:

[Unit]
Wants=foo-net-em2.service

[Install]
WantedBy=network.target

foo-net-em2.service contains:

[Unit]
ConditionKernelCommandLine=foo=bar
Conflicts=shutdown.target
Before=network.target shutdown.target
Requires=sys-subsystem-net-devices-em2.device foo-configure.service
After=sys-subsystem-net-devices-em2.device foo-configure.service

[Service]
EnvironmentFile=/etc/sysconfig/network-scripts/foo
ExecStart=/bin/true
#eventually: ExecStart=/sbin/ifconfig ... $FOO ...
Type=oneshot
TimeoutSec=0
RemainAfterExit=yes

When the system boots, I see that eth1 is renamed to em2 and I see a

sys-devices-pci0000:00-0000:00:09.0-0000:03:00.0-0000:04:02.0-0000:07:00.0-net-em2.device

go from dead to plugged.

However, the startup of foo-net-em2.service fails because the startup
of sys-subsystem-net-devices-em2.device times out.

Did I misunderstand how the udev rule is supposed to work?

Is the udev 167 that ships with FC15 too old perhaps?

Thanks.

Regards

Albert


More information about the systemd-devel mailing list