patches and low-level development discussion
 help / color / mirror / code / Atom feed
From: Demi Marie Obenour <demiobenour@gmail.com>
To: Alyssa Ross <hi@alyssa.is>
Cc: Spectrum OS Development <devel@spectrum-os.org>
Subject: Re: [PATCH v2 2/3] host/rootfs: Switch to systemd-udevd
Date: Thu, 25 Sep 2025 13:53:08 -0400	[thread overview]
Message-ID: <5e6bd5d5-a6b3-43f4-8cfd-dc68b432d2ea@gmail.com> (raw)
In-Reply-To: <87zfaiby79.fsf@alyssa.is>


[-- Attachment #1.1.1: Type: text/plain, Size: 5588 bytes --]

On 9/25/25 06:53, Alyssa Ross wrote:
> 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 doesn't set PATH to anything useful, presumably because
>> under NixOS this is handled some other way.  Therefore, explicitly set
>> it to /usr/bin in the scripts systemd-udevd calls.
>>
>> The /etc/mdev/listen and /etc/mdev/wait scripts are replaced by
>> 'udevadm wait', so they are deleted.  The whole static-nodes target also
>> goes away, as Linux handles that itself and systemd-udevd deals with
>> autoloading.
> 
> Not quite right.  Linux does not create static nodes.  Userspace has to.
> That's why we had a service for it.  (It sucks.)
> 
>> diff --git a/host/rootfs/image/etc/s6-rc/kvm/up b/host/rootfs/image/etc/s6-rc/kvm/up
>> index c02e3f90245e005b98b4de8245a1863fb49c1158..a8436de58580f2a2a6f42bb69418a319f967df47 100644
>> --- a/host/rootfs/image/etc/s6-rc/kvm/up
>> +++ b/host/rootfs/image/etc/s6-rc/kvm/up
>> @@ -1,4 +1,3 @@
>>  # SPDX-License-Identifier: EUPL-1.2+
>> -# SPDX-FileCopyrightText: 2023 Alyssa Ross <hi@alyssa.is>
>> -
>> -/etc/mdev/wait kvm
>> +# SPDX-FileCopyrightText: 2025 Demi Marie Obenour <demiobenour@gmail.com>
>> +udevadm wait /dev/kvm
> 
> Any reason now not to just inline this into the services that need to wait?

Avoiding redundant calls I guess?  I'm not
sure how expensive 'udevadm wait' is.

>> 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..2501680b69eb0060b651146dffb6b3a99640c6fb
>> --- /dev/null
>> +++ b/host/rootfs/image/etc/s6-rc/systemd-udevd/run
>> @@ -0,0 +1,11 @@
>> +#!/bin/execlineb -P
>> +# SPDX-License-Identifier: EUPL-1.2+
>> +# SPDX-FileCopyrightText: 2025 Demi Marie Obenour <demiobenour@gmail.com>
>> +if { rm -f /run/sd-notify-wrapper/systemd-udevd }
>> +background {
>> +   s6-ipcserver-socketbinder -b0 -m -a 0600 /run/sd-notify-wrapper/systemd-udevd
>> +   fdmove 1 3
>> +   sd-notify-adapter
>> +}
>> +export NOTIFY_SOCKET /run/sd-notify-wrapper/systemd-udevd
>> +exec -a systemd-udevd udevadm
> 
> How does systemd expect this to normally work?

/usr/lib/systemd/systemd-udevd is a symlink to ../../bin/udevadm

>> diff --git a/host/rootfs/image/etc/s6-rc/vm-env/contents b/host/rootfs/image/etc/s6-rc/vm-env/contents
>> index 580795b1b02bb7a8dff7f872723c678141d4bb70..ed8b5c410adfc17f5bbc33932ac79d97bd7b3115 100644
>> --- a/host/rootfs/image/etc/s6-rc/vm-env/contents
>> +++ b/host/rootfs/image/etc/s6-rc/vm-env/contents
>> @@ -2,4 +2,5 @@
>>  # SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
>>  #
>>  static-nodes
>> +systemd-udevd-coldplug
>>  weston
> 
> Shouldn't static-nodes be removed here as well, and the static-nodes
> files deleted?

Nope.  systemd-udevd doesn't create them.  However,
one can use kmod and systemd-tmpfiles to do that.

systemd-tmpfiles actually has no dependency on PID 1
*at all*, so we can use it as much as we want.

>> 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..ca91367529f39eebe009cc8acef782cf6a4516c1
>> --- /dev/null
>> +++ b/host/rootfs/image/etc/udev/rules.d/99-spectrum.rules
>> @@ -0,0 +1,9 @@
>> +# SPDX-License-Identifier: EUPL-1.2+
>> +# SPDX-FileCopyrightText: 2025 Demi Marie Obenour <demiobenour@gmail.com>
>> +
>> +# systemd-udevd has a built-in module loading feature,
>> +# but it seems to not work for some reason or another.
>> +# This works.
>> +ACTION!="remove", ENV{MODALIAS}!="", RUN+="/usr/bin/modprobe -q $env{MODALIAS}"
>> +# systemd-udevd unsets PATH, so fix that.
>> +ACTION!="remove", ENV{PCI_CLASS}=="2????", RUN+="/usr/bin/env PATH=/usr/bin /usr/libexec/net-add"
> 
> This is such a weird behavior.  Do we know why it does that?

I don't at least.

>> diff --git a/host/rootfs/image/usr/bin/vm-start b/host/rootfs/image/usr/bin/vm-start
>> index 67480e5215d8a8260ce3f03c67f71ba8f210c291..9725ef5ec549ff191606282a7b0ae56838f53f03 100755
>> --- a/host/rootfs/image/usr/bin/vm-start
>> +++ b/host/rootfs/image/usr/bin/vm-start
>> @@ -2,7 +2,7 @@
>>  # SPDX-License-Identifier: EUPL-1.2+
>>  # SPDX-FileCopyrightText: 2022-2023, 2025 Alyssa Ross <hi@alyssa.is>
>>  
>> -foreground { s6-rc -bu change vm-env }
>> +foreground { s6-rc -bu change weston }
>>  
>>  foreground {
>>    redirfd -w 2 /dev/null
> 
> Why?

Will revert.
-- 
Sincerely,
Demi Marie Obenour (she/her/hers)

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 7253 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2025-09-25 17:53 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 [this message]
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
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=5e6bd5d5-a6b3-43f4-8cfd-dc68b432d2ea@gmail.com \
    --to=demiobenour@gmail.com \
    --cc=devel@spectrum-os.org \
    --cc=hi@alyssa.is \
    /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).