insert vfio modules in the correct location
This commit is contained in:
parent
0512d438cd
commit
3f0c99a2ba
1 changed files with 39 additions and 18 deletions
|
@ -1,26 +1,47 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
function insert_MODULES () {
|
||||||
|
# Get the header and enabled modules separately from the /etc/modules file
|
||||||
|
MODULES_HEADER=$(head -n $1 "$2" | grep -P "^#" | grep -v "# Added by quickpassthrough")
|
||||||
|
MODULES_ENABLED=$(cat "$2" | grep -vP "^#" | grep -v "vendor-reset")
|
||||||
|
VENDOR_RESET=0
|
||||||
|
|
||||||
|
# If vendor-reset is present
|
||||||
|
if grep -q "vendor-reset" "$2" ;
|
||||||
|
then
|
||||||
|
VENDOR_RESET=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Write header
|
||||||
|
echo "$MODULES_HEADER" > "$2"
|
||||||
|
|
||||||
|
# If vendor-reset existed from before
|
||||||
|
if [ $VENDOR_RESET == 1 ];
|
||||||
|
then
|
||||||
|
# Write vendor-reset as the first module!
|
||||||
|
echo "vendor-reset" >> "$2"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Append vfio
|
||||||
|
printf "
|
||||||
|
# Added by quickpassthrough #
|
||||||
|
vfio
|
||||||
|
vfio_iommu_type1
|
||||||
|
vfio_pci
|
||||||
|
vfio_virqfd
|
||||||
|
#############################
|
||||||
|
" >> "$2"
|
||||||
|
|
||||||
|
# Write the previously enabled modules under vfio in the load order
|
||||||
|
echo "$MODULES_ENABLED" >> "$2"
|
||||||
|
}
|
||||||
|
|
||||||
function set_MODULES () {
|
function set_MODULES () {
|
||||||
# Get the config paths
|
# Get the config paths
|
||||||
source "$SCRIPTDIR/lib/paths.sh"
|
source "$SCRIPTDIR/lib/paths.sh"
|
||||||
|
|
||||||
# Write "/etc/modules"
|
insert_MODULES 4 "$SCRIPTDIR/$MODULES"
|
||||||
printf "
|
insert_MODULES 11 "$SCRIPTDIR/$INITRAMFS/modules"
|
||||||
# Generated by vfio-setup
|
|
||||||
vfio
|
|
||||||
vfio_iommu_type1
|
|
||||||
vfio_pci
|
|
||||||
vfio_virqfd
|
|
||||||
" >> "$SCRIPTDIR/$MODULES"
|
|
||||||
|
|
||||||
# Write "/etc/initramfs-tools/modules"
|
|
||||||
printf "
|
|
||||||
# Generated by vfio-setup
|
|
||||||
vfio
|
|
||||||
vfio_iommu_type1
|
|
||||||
vfio_pci
|
|
||||||
vfio_virqfd
|
|
||||||
" >> "$SCRIPTDIR/$INITRAMFS/modules"
|
|
||||||
|
|
||||||
# Assign the GPU device ids to a variable
|
# Assign the GPU device ids to a variable
|
||||||
GPU_DEVID="$1"
|
GPU_DEVID="$1"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue