Add driver_override possibility in pci script.

This commit is contained in:
redxef 2022-01-21 10:17:17 +01:00
parent fc4166251c
commit 55ed77c9a3
3 changed files with 25 additions and 11 deletions

19
pci
View file

@ -11,13 +11,22 @@ fi
vfio_rebind_device() {
local pci_id
local override
pci_id="$1"
override="$2"
if [[ "$override" != 'true' ]]; then
override=false
fi
if [[ -e "$BASE_PATH/devices/$pci_id" ]]; then
echo "$pci_id" | sudo tee \
"$BASE_PATH/devices/$pci_id/driver/unbind" >/dev/null
echo "$pci_id" | sudo tee \
"$BASE_PATH/drivers/vfio-pci/bind" > /dev/null
if "$override"; then
echo "vfio-pci" | sudo tee \
"$BASE_PATH/devices/$pci_id/driver_override" > /dev/null
fi
[[ -e "$BASE_PATH/devices/$pci_id/driver/unbind" ]] \
&& echo "$pci_id" | sudo tee \
"$BASE_PATH/devices/$pci_id/driver/unbind" >/dev/null
echo "$pci_id" | sudo tee \
"$BASE_PATH/drivers/vfio-pci/bind" > /dev/null
fi
}

9
start
View file

@ -49,9 +49,14 @@ NET_CONF_FILE="$NET_CONF_FILE" $DEBUG $SUDO --preserve-env=NET_CONF_FILE \
./net create
# rebind devices
for device in $(< vfio_devices.txt); do
$DEBUG $SUDO ./pci vfio_rebind_device "$device"
old_IFS="$IFS"
IFS=$'\n'
for device_override in $(< vfio_devices.txt); do
device="$(echo "$device_override" | awk '{print $1}')"
override="$(echo "$device_override" | awk '{print $2}')"
$DEBUG $SUDO ./pci vfio_rebind_device "$device" "$override"
done
IFS="$old_IFS"
# efi variables
EFI_VARS="$(mktemp)"

View file

@ -1,4 +1,4 @@
0000:02:00.0
0000:07:00.0
0000:65:00.0
0000:65:00.1
0000:02:00.0 false
0000:07:00.0 false
0000:65:00.0 false
0000:65:00.1 false