On 11/2/25 10:00, Alyssa Ross wrote:
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.... Signed-off-by: Alyssa Ross <hi@alyssa.is>
Reviewed-by: Demi Marie Obenour <demiobenour@gmail.com>
--- 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 -- Sincerely, Demi Marie Obenour (she/her/hers)