From: Alyssa Ross <hi@alyssa.is>
To: devel@spectrum-os.org
Cc: Demi Marie Obenour <demiobenour@gmail.com>,
Yureka Lilian <yureka@cyberchaos.dev>
Subject: [PATCH 2/2] host/rootfs: /etc/mdev/net/add: make idempotent
Date: Sun, 2 Nov 2025 16:00:18 +0100 [thread overview]
Message-ID: <20251102150018.1242022-2-hi@alyssa.is> (raw)
In-Reply-To: <20251102150018.1242022-1-hi@alyssa.is>
udev actions needs to be idempotent, so when we switch to udev, we
have the choice of making this script idempotent, or doing goto hacks
to stop udev running it more than once. I like this better.
assign-devices is already idempotent, so all we need to do to achieve
idempotency is avoid unbinding and rebinding the driver if it's
already the right one.
Link: https://spectrum-os.org/lists/archives/spectrum-devel/87ikgxwq0v.fsf@alyssa.is
Signed-off-by: Alyssa Ross <hi@alyssa.is>
---
host/rootfs/image/etc/mdev/net/add | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/host/rootfs/image/etc/mdev/net/add b/host/rootfs/image/etc/mdev/net/add
index f343779..62c152e 100755
--- a/host/rootfs/image/etc/mdev/net/add
+++ b/host/rootfs/image/etc/mdev/net/add
@@ -1,6 +1,6 @@
#!/bin/execlineb -P
# SPDX-License-Identifier: EUPL-1.2+
-# SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
+# SPDX-FileCopyrightText: 2021, 2025 Alyssa Ross <hi@alyssa.is>
# Assign the whole IOMMU group containing this device to the network
# VM.
@@ -12,6 +12,13 @@ importas -i devpath DEVPATH
foreground {
pipeline { ls -1 /sys${devpath}/iommu_group/devices }
forstdin -pE device
+ if -t {
+ backtick -E driver_name {
+ backtick -E driver_path { readlink /sys/bus/pci/devices/${device}/driver }
+ basename -- $driver_path
+ }
+ test $driver_name != vfio-pci
+ }
foreground {
redirfd -w 2 /dev/null
redirfd -w 1 /sys/bus/pci/devices/${device}/driver/unbind
--
2.51.0
next prev parent reply other threads:[~2025-11-02 15:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-02 15:00 [PATCH 1/2] host/rootfs: assign-devices: silence errors Alyssa Ross
2025-11-02 15:00 ` Alyssa Ross [this message]
2025-11-02 20:08 ` [PATCH 2/2] host/rootfs: /etc/mdev/net/add: make idempotent Demi Marie Obenour
2025-11-02 20:49 ` Alyssa Ross
2025-11-02 20:09 ` [PATCH 1/2] host/rootfs: assign-devices: silence errors Demi Marie Obenour
2025-11-02 20:49 ` 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=20251102150018.1242022-2-hi@alyssa.is \
--to=hi@alyssa.is \
--cc=demiobenour@gmail.com \
--cc=devel@spectrum-os.org \
--cc=yureka@cyberchaos.dev \
/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).