-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Explicitly remove wireless PCI devices on shutdown.
The guest operating system has to release the devices that were shared via PCI pass-through otherwise they might get stuck and can eventually bring down the entire host. Relates to pgj/freebsd-wifibox#60
- Loading branch information
Showing
2 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/sbin/openrc-run | ||
|
||
description="Explicitly removes wireless devices." | ||
|
||
depend() { | ||
before firewall | ||
after logger | ||
} | ||
|
||
find_pci_wireless() { | ||
local iface= | ||
for iface in /sys/bus/pci/devices/*/net/*; do | ||
if [ -e "$iface"/wireless -o -e "$iface"/phy80211 ]; then | ||
echo "${iface%/net/*}" | ||
fi | ||
done | ||
} | ||
|
||
start() { | ||
: | ||
} | ||
|
||
stop() { | ||
ebegin "Triggering remove for PCI wireless devices" | ||
eindent | ||
for device in $(find_pci_wireless); do | ||
veinfo "Processing $device" | ||
echo 1 > "$device"/remove | ||
done | ||
eoutdent | ||
|
||
eend $? | ||
} |