Add pci subcommand for rebinding to vfio
This commit is contained in:
parent
5813e4d4e3
commit
76419c8eaf
1 changed files with 22 additions and 0 deletions
22
pci
Executable file
22
pci
Executable file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
BASE_PATH=/sys/bus/pci/
|
||||||
|
|
||||||
|
# sanitize variables
|
||||||
|
if [[ "${BASE_PATH: -1}" = '/' ]]; then
|
||||||
|
BASE_PATH="${BASE_PATH::${#BASE_PATH}-1}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
vfio_rebind_device() {
|
||||||
|
local pci_id
|
||||||
|
|
||||||
|
pci_id="$1"
|
||||||
|
if [[ -e "$BASE_PATH/devices/$pci_id" ]]; then
|
||||||
|
echo "$pci_id" | sudo tee "$BASE_PATH/devices/$pci_id/driver/unbind"
|
||||||
|
echo "$pci_id" | sudo tee "$BASE_PATH/drivers/vfio-pci/bind"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
"$@"
|
Loading…
Add table
Reference in a new issue