From: Alyssa Ross <hi@alyssa.is>
To: Demi Marie Obenour <demiobenour@gmail.com>
Cc: Spectrum OS Development <devel@spectrum-os.org>
Subject: Re: [PATCH v4 2/2] host/rootfs: Switch to systemd-udevd
Date: Tue, 28 Oct 2025 17:02:13 +0100 [thread overview]
Message-ID: <87jz0f3th6.fsf@alyssa.is> (raw)
In-Reply-To: <20251003-udev-v4-2-7d7344b14d11@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 8174 bytes --]
Demi Marie Obenour <demiobenour@gmail.com> writes:
> This replaces the mdevd uevent daemon with systemd-udevd, which supports
> much more hardware and is therefore to be preferred for a full desktop
> environment. Various Wayland compositors integrate with systemd-udevd,
> allowing them to discover devices as they appear rather than having to
> only use devices plugged in when the compositor is started.
> Additionally, systemd-udevd has quirks for various devices that are
> needed to support the wide variety of hardware end-users have.
>
> The dependency on /dev/dri/card0 being present is eliminated, and
> whatever devices the user has are now picked up by the compositor. New
> dependencies are added to ensure that udev coldplug has finished before
> any non-trivial services are started. systemd-udev-trigger.service runs
> 'udevadm trigger' and has Before=sysinit.target, so anything that is not
> an early boot service can assume 'udevadm trigger' has run.
>
> systemd-udevd unsets PATH before it runs programs. Therefore, manually
> set it to /usr/bin before invoking any scripts.
>
> systemd-udevd provides the 'udevadm wait' command to wait for a device
> to appear and be processed. This replaces all uses of /etc/mdev/wait,
> so this script is removed. /etc/mdev/listen and /run/wait only existed
> to wake up /etc/mdev/wait, so they are also removed.
>
> The command-line options to 'udevadm trigger' are taken from
> systemd-udev-trigger.service on my Arch machine. Using the wrong
> arguments leads to problems that take a very long time to debug.
>
> Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
> ---
> LICENSES/LGPL-2.1-or-later.txt | 502 +++++++++++++++++++++
> host/rootfs/Makefile | 2 +-
> host/rootfs/default.nix | 118 ++---
> host/rootfs/file-list.mk | 33 +-
> host/rootfs/image/etc/mdev.conf | 7 -
> host/rootfs/image/etc/mdev/listen | 11 -
> host/rootfs/image/etc/mdev/wait | 14 -
> host/rootfs/image/etc/s6-rc/card0/type.license | 2 -
> host/rootfs/image/etc/s6-rc/card0/up | 4 -
> host/rootfs/image/etc/s6-rc/kvm/timeout-up | 1 -
> host/rootfs/image/etc/s6-rc/kvm/timeout-up.license | 2 -
> host/rootfs/image/etc/s6-rc/kvm/type | 1 -
> host/rootfs/image/etc/s6-rc/kvm/type.license | 2 -
> host/rootfs/image/etc/s6-rc/kvm/up | 4 -
> host/rootfs/image/etc/s6-rc/mdevd-coldplug/type | 1 -
> host/rootfs/image/etc/s6-rc/mdevd-coldplug/up | 4 -
> .../image/etc/s6-rc/mdevd/notification-fd.license | 2 -
> host/rootfs/image/etc/s6-rc/mdevd/run | 5 -
> .../contents.d/systemd-udevd-coldplug} | 0
> .../dependencies.d/systemd-udevd} | 0
> .../s6-rc/{card0 => systemd-udevd-coldplug}/type | 0
> .../type.license | 0
> .../image/etc/s6-rc/systemd-udevd-coldplug/up | 6 +
> .../s6-rc/{mdevd => systemd-udevd}/notification-fd | 0
> .../s6-rc/systemd-udevd/notification-fd.license | 2 +
> host/rootfs/image/etc/s6-rc/systemd-udevd/run | 15 +
> .../image/etc/s6-rc/{mdevd => systemd-udevd}/type | 0
> .../s6-rc/{mdevd => systemd-udevd}/type.license | 0
> .../contents.d/systemd-udevd-coldplug} | 0
> .../contents.d/systemd-udevd-coldplug} | 0
> .../weston/dependencies.d/systemd-udevd-coldplug | 0
> host/rootfs/image/etc/s6-rc/weston/run | 7 +-
> .../image/etc/udev/rules.d/99-spectrum.rules | 15 +
> host/rootfs/image/usr/bin/run-vmm | 1 +
> host/rootfs/image/usr/bin/systemd-udevd | 1 +
> .../{etc/mdev/net/add => usr/libexec/net-add} | 0
> 36 files changed, 604 insertions(+), 158 deletions(-)
Also looking good, and again if you'd prefer I just make my suggested
changes myself when I apply it that's fine by me.
> diff --git a/host/rootfs/image/etc/s6-rc/systemd-udevd-coldplug/up b/host/rootfs/image/etc/s6-rc/systemd-udevd-coldplug/up
> new file mode 100644
> index 0000000000000000000000000000000000000000..f4bfe58d1219218ba486050e4de0f949df8f2058
> --- /dev/null
> +++ b/host/rootfs/image/etc/s6-rc/systemd-udevd-coldplug/up
> @@ -0,0 +1,6 @@
> +# SPDX-License-Identifier: LGPL-2.1-or-later
> +# SPDX-FileCopyrightText: systemd is free software; you can redistribute it and/or modify it
> +# under the terms of the GNU Lesser General Public License as published by
> +# the Free Software Foundation; either version 2.1 of the License, or
> +# (at your option) any later version.
This is a statement of the license and is covered by the
SPDX-License-Identifier metadata. SPDX-FileCopyrightText is for
identifying copyright owners. For a project that doesn't provide a
copyright notice, we'd typically attribute copyright to e.g. "The
systemd Authors".
In this case though, I don't think there's anything copyrightable here,
so CC0-1.0 and your name should be fine.
> +udevadm trigger --type=all --action=add --prioritized-subsystem=module,block,tpmrm,net,tty,input
> diff --git a/host/rootfs/image/etc/s6-rc/systemd-udevd/run b/host/rootfs/image/etc/s6-rc/systemd-udevd/run
> new file mode 100644
> index 0000000000000000000000000000000000000000..98d1aa83153c99f32afb4d27a97cf39fcadb2968
> --- /dev/null
> +++ b/host/rootfs/image/etc/s6-rc/systemd-udevd/run
> @@ -0,0 +1,15 @@
> +#!/bin/execlineb -P
> +# SPDX-License-Identifier: EUPL-1.2+
> +# SPDX-FileCopyrightText: 2025 Demi Marie Obenour <demiobenour@gmail.com>
> +s6-setlock /run/sd-notify-wrapper/systemd-udevd.lock
> +# Save stdin to restore it later.
> +fdmove -c 4 0
stdin will always be /dev/null, so instead of this dance you can just
redirfd -r 0 /dev/null after the background.
> +s6-ipcserver-socketbinder -b0 -m -a 0600 /run/sd-notify-wrapper/systemd-udevd.sock
> +background {
> + fdmove 1 3
> + sd-notify-adapter
> +}
> +fdclose 3
> +fdmove 0 4
> +export NOTIFY_SOCKET /run/sd-notify-wrapper/systemd-udevd.sock
> +systemd-udevd
> diff --git a/host/rootfs/image/etc/s6-rc/weston/run b/host/rootfs/image/etc/s6-rc/weston/run
> index 7dca0dab095569c9e7d49df9d245533a7265283e..8276e7eed45ab8155e21a3e11f86c57c03d66cc4 100644
> --- a/host/rootfs/image/etc/s6-rc/weston/run
> +++ b/host/rootfs/image/etc/s6-rc/weston/run
> @@ -4,9 +4,9 @@
>
> unexport WAYLAND_DISPLAY
>
> -foreground {
> - umask 077
> - mkdir /run/user/0
> +if {
> + umask 0022
> + mkdir -p -m 0700 /run/user/0
What's the point in continuing to umask when you explicitly provide the mode?
> }
> unexport ?
>
> @@ -20,4 +20,5 @@ redirfd -r 0 /dev/tty1
>
> importas -i home HOME
> cd $home
> +if { udevadm wait /dev/dri/card0 }
> weston
> diff --git a/host/rootfs/image/etc/udev/rules.d/99-spectrum.rules b/host/rootfs/image/etc/udev/rules.d/99-spectrum.rules
> new file mode 100644
> index 0000000000000000000000000000000000000000..c65829419de3516d6ec8e95e7928a69c308507aa
> --- /dev/null
> +++ b/host/rootfs/image/etc/udev/rules.d/99-spectrum.rules
> @@ -0,0 +1,15 @@
> +# SPDX-License-Identifier: EUPL-1.2+
> +# SPDX-FileCopyrightText: 2025 Demi Marie Obenour <demiobenour@gmail.com>
> +
> +# systemd-udevd unsets PATH, so fix that.
Stray copy of comment.
> +ACTION=="remove", GOTO="spectrum-end"
> +ENV{PCI_CLASS}!="2????", GOTO="spectrum-end"
> +
> +# net-add unbinds and rebinds the driver, so avoid calling
> +# it more than once.
> +IMPORT{db}="SPECTRUM_DRIVER_ASSIGNED"
> +ENV{SPECTRUM_DRIVER_ASSIGNED}=="yes", GOTO="spectrum-end"
> +# systemd-udevd unsets PATH, so fix that.
> +RUN+="/usr/bin/env PATH=/usr/bin /usr/libexec/net-add"
> +ENV{SPECTRUM_DRIVER_ASSIGNED}="yes"
> +LABEL="spectrum-end"
Again, I'd much rather this was taken care of in net-add. I'll post a
patch to make it re-entrant, I guess.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]
next prev parent reply other threads:[~2025-10-28 16:02 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-14 3:16 [PATCH 0/3] Switch from mdevd to systemd-udevd in root filesystem Demi Marie Obenour
2025-09-14 3:16 ` [PATCH 1/3] host/rootfs: Add early serial output Demi Marie Obenour
2025-09-17 11:45 ` Alyssa Ross
2025-09-18 2:44 ` Demi Marie Obenour
2025-09-19 14:21 ` Alyssa Ross
2025-09-19 14:49 ` Alyssa Ross
2025-09-14 3:16 ` [PATCH 2/3] tools: Add adapter tool for services using sd_notify Demi Marie Obenour
2025-09-14 3:16 ` [PATCH 3/3] host/rootfs: switch to systemd-udevd Demi Marie Obenour
2025-09-19 14:12 ` Alyssa Ross
2025-09-19 19:32 ` Demi Marie Obenour
2025-09-21 12:18 ` Alyssa Ross
2025-09-21 17:02 ` Demi Marie Obenour
2025-09-21 16:27 ` Demi Marie Obenour
2025-09-21 16:28 ` Demi Marie Obenour
2025-09-23 18:39 ` Alyssa Ross
2025-09-23 19:18 ` Demi Marie Obenour
2025-09-24 10:32 ` [PATCH v2 0/3] Switch from mdevd to systemd-udevd in root filesystem Demi Marie Obenour
2025-09-24 10:32 ` [PATCH v2 1/3] tools: Add adapter tool for services using sd_notify Demi Marie Obenour
2025-09-25 10:29 ` Alyssa Ross
2025-09-25 16:54 ` Demi Marie Obenour
2025-09-24 10:32 ` [PATCH v2 2/3] host/rootfs: Switch to systemd-udevd Demi Marie Obenour
2025-09-25 10:53 ` Alyssa Ross
2025-09-25 17:53 ` Demi Marie Obenour
2025-09-26 14:56 ` Alyssa Ross
2025-09-28 22:51 ` [PATCH v3 0/2] Switch from mdevd to systemd-udevd in root filesystem Demi Marie Obenour
2025-09-28 22:51 ` [PATCH v3 1/2] tools: Add adapter tool for services using sd_notify Demi Marie Obenour
2025-10-01 16:06 ` Alyssa Ross
2025-09-28 22:51 ` [PATCH v3 2/2] host/rootfs: Switch to systemd-udevd Demi Marie Obenour
2025-10-01 14:24 ` Alyssa Ross
2025-10-01 14:39 ` Alyssa Ross
2025-10-01 17:40 ` Demi Marie Obenour
2025-10-02 9:53 ` Alyssa Ross
2025-10-02 10:34 ` Alyssa Ross
2025-10-02 10:36 ` [PATCH v3 0/2] Switch from mdevd to systemd-udevd in root filesystem Alyssa Ross
2025-10-03 21:42 ` [PATCH v4 " Demi Marie Obenour
2025-10-03 21:42 ` [PATCH v4 1/2] tools: Add adapter tool for services using sd_notify Demi Marie Obenour
2025-10-28 15:38 ` Alyssa Ross
2025-10-28 22:56 ` Demi Marie Obenour
2025-10-29 11:26 ` Alyssa Ross
2025-10-31 4:34 ` Demi Marie Obenour
2025-10-31 8:54 ` Alyssa Ross
2025-11-01 18:23 ` Demi Marie Obenour
2025-10-03 21:42 ` [PATCH v4 2/2] host/rootfs: Switch to systemd-udevd Demi Marie Obenour
2025-10-28 16:02 ` Alyssa Ross [this message]
2025-10-28 22:56 ` Demi Marie Obenour
2025-10-29 9:31 ` Alyssa Ross
2025-10-29 9:55 ` Demi Marie Obenour
2025-09-24 10:32 ` [PATCH v2 3/3] host/rootfs: Simplify s6-rc dependencies Demi Marie Obenour
2025-09-25 11:07 ` Alyssa Ross
2025-09-25 15:50 ` Demi Marie Obenour
2025-10-02 10:37 ` Alyssa Ross
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87jz0f3th6.fsf@alyssa.is \
--to=hi@alyssa.is \
--cc=demiobenour@gmail.com \
--cc=devel@spectrum-os.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://spectrum-os.org/git/crosvm
https://spectrum-os.org/git/doc
https://spectrum-os.org/git/mktuntap
https://spectrum-os.org/git/nixpkgs
https://spectrum-os.org/git/spectrum
https://spectrum-os.org/git/ucspi-vsock
https://spectrum-os.org/git/www
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).