Bug 1941458 - sys-subsystem-net-devices-%i.device not available in systemd-nspawn --network-bridge virbr0
Summary: sys-subsystem-net-devices-%i.device not available in systemd-nspawn --network...
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: systemd
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: systemd-maint
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-03-22 08:00 UTC by Petr Menšík
Modified: 2021-03-23 09:06 UTC (History)
11 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2021-03-23 09:06:47 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Petr Menšík 2021-03-22 08:00:20 UTC
Description of problem:
I recently got dhcpcd package ownership. I tested it inside systemd-nspawn container with systemd. It failed to start there, because not active net device exists there. I have to 

BindsTo=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device

Version-Release number of selected component (if applicable):
systemd-248~rc3-2.fc35.x86_64
systemd-container-245.9-1.fc32.1.x86_64

How reproducible:
reliable

Steps to Reproduce:
1. have a rawhide nspawn chroot prepared and also libvirt network
2. ip a show dev virbr0
3. systemd-nspawn -bD <chroot-path> --network-bridge virbr0
4. ip a show dev host0 # inside container
5. systemctl status sys-subsystem-net-devices-%i.device # inside container

Actual results:
# ip a show dev host0
2: host0@if66: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 3e:cb:e4:52:ca:a8 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 192.168.122.82/24 brd 192.168.122.255 scope global dynamic host0
       valid_lft 2895sec preferred_lft 2895sec
    inet6 fc30:e1c:64cf:2b0a:3ccb:e4ff:fe52:caa8/64 scope global dynamic mngtmpaddr noprefixroute 
       valid_lft 7000sec preferred_lft 3400sec
    inet6 fe80::3ccb:e4ff:fe52:caa8/64 scope link 
       valid_lft forever preferred_lft forever
# systemctl status sys-subsystem-net-devices-host0.device
○ sys-subsystem-net-devices-host0.device - /sys/subsystem/net/devices/host0
     Loaded: loaded
     Active: inactive (dead)


Expected results:
# systemctl status sys-subsystem-net-devices-host0.device
○ sys-subsystem-net-devices-host0.device - /sys/subsystem/net/devices/host0
     Loaded: loaded
     Active: active (plugged)


Additional info:
I have to disable BindTo=, because the net-device is never activated, even when it is configured and working. Not sure problem is on the host (fedora 32) or container (fedora 35).

Comment 1 Petr Menšík 2021-03-22 08:13:54 UTC
It prevents starting on such rawhide container:

# systemctl restart dhcpcd@host0

# journalctl -xe
Mar 22 09:06:50 srawhide systemd[1]: Unnecessary job for /sys/subsystem/net/devices/host0 was removed.
░░ Subject: A start job for unit sys-subsystem-net-devices-host0.device has failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░ 
░░ A start job for unit sys-subsystem-net-devices-host0.device has finished with a failure.
░░ 
░░ The job identifier is 773 and the job result is collected.
Mar 22 09:06:50 srawhide systemd[1]: Created slice system-dhcpcd.slice.
░░ Subject: A start job for unit system-dhcpcd.slice has finished successfully
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░ 
░░ A start job for unit system-dhcpcd.slice has finished successfully.
░░ 
░░ The job identifier is 772.
Mar 22 09:06:50 srawhide systemd[1]: dhcpcd: Bound to unit sys-subsystem-net-devices-host0.device, but unit isn't active.
Mar 22 09:06:50 srawhide systemd[1]: Dependency failed for dhcpcd on host0.
░░ Subject: A start job for unit dhcpcd has failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░ 
░░ A start job for unit dhcpcd has finished with a failure.
░░ 
░░ The job identifier is 717 and the job result is dependency.
Mar 22 09:06:50 srawhide systemd[1]: dhcpcd: Job dhcpcd/start failed with result 'dependency'.

It seems systemctl edit dhcpcd@
[Unit]
Description=dhcpcd on %I
# sys-class-net-%i.device is inactive (
BindsTo=
#BindsTo=sys-class-net-%i.device
After=
#After=sys-class-net-%i.device

Does not help, I have to comment BindsTo in main /usr/lib/systemd/system/dhcpcd@.service. It it possible somehow inside override? It would allow at least simple workaround.

Comment 2 Zbigniew Jędrzejewski-Szmek 2021-03-22 19:20:14 UTC
There is no udev in the container, hence no device units.

Comment 3 Zbigniew Jędrzejewski-Szmek 2021-03-22 20:50:33 UTC
https://github.com/systemd/systemd/pull/19081

Comment 4 Zbigniew Jędrzejewski-Szmek 2021-03-23 09:06:47 UTC
The patch to documentation was merged upstream. While I see how having device units in a container
could be desirable, this would require a major rework. If you want, maybe open up discussion upstream.
Either way, let's close this here as the docs have been improved and this isn't a bug.


Note You need to log in before you can comment on or make changes to this bug.