Tags: lowRISC/container-hotplug
Tags
fix: detach cloned sysfs mounts from the host propagation group
`bind_sysfs` clones a device's sysfs directory with `open_tree(OPEN_TREE_CLONE)`,
which is the new-mount-API equivalent of `mount --bind`. Cloning a *shared* mount
yields a peer of the source rather than a private mount, and `/sys` is shared on
a systemd host (`mount --make-rshared /` at boot).
Device syspaths nest inside each other, so the clone for a device ends up being
the parent mount of the clones for its children. Mounting under a shared mount
propagates the new mount to every peer of the group, which includes the host's
own `/sys`. Those copies live in the host's mount namespace, so unlike the
container's own mounts they survive the container exiting, and `unbind_sysfs`
does not reach them -- it acts inside the container's namespace, and only when a
device is unplugged.
On a CI machine where the boards stay plugged in and containers come and go,
the host's mount table therefore grows by roughly one entry per device per
container start. One host reached ~98000 of the default `fs.mount-max` of
100000, past which every mount attempt failed:
Cannot make sysfs writable: Cannot mount sysfs directory
/sys/devices/.../usb7/7-2/7-2.4/7-2.4.1/7-2.4.1.1:
No space left on device (os error 28)
Devices still attached and the container still started, so this degraded
silently until a job tried to write a sysfs attribute.
Make the detached clone private before attaching it. Verified with the same
syscall sequence that the clone goes from `private,slave master:12` (the
propagation group of `/sys`) to `private`, and that a mount made underneath it
then creates one mount rather than one per peer.
Nothing is lost by this: sysfs device directories are dentries within a single
superblock rather than submounts, so nothing under `/sys/devices` relies on
propagation to become visible.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ci: add github pages deployement of the rustdocs Signed-off-by: David James McCorrie <james.mccorrie@lowrisc.org>
Propagate udev messages into the container By default, in terms of kobject uevent messages, containers will: * Without userns: see kernel messages but not udev messages * With userns: see no messages at all And this creates trouble for libraries such as libusb, which relies on these netlink messages to detect device updates. We fix this by filling the gap for systemd and send out our own udev messages.
Remount /dev when user namespace is used to allow accessing device nodes
Fix cgroup.events error when cgroup is gone before reading events If cgroup is gone before reading the cgroup.events file then it will return an error. Treat errors as unpopulated to account for it.
Apply README suggestions from code review Co-authored-by: James Wainwright <james.wainwright@lowrisc.org>
PreviousNext