]> ### 2023.11.22 - Only apply patch for libvirt.php on Unraid versions lower than 6.13 - thanks SimonF for implementing that ### 2023.11.21 - Updated plugin from community developer zhtengw to make sure community is able to use SRIOV - Use GitHub Releases for plugin package downloads - Be a bit more verbose on plugin installation - Add Plugin Update Helper - A little bit of code cleanup - Please use the original support thread for questions related to the plugin ### 2023.04.06 - Make change VFs number work; - Add option for saving to config file only; - Add support for unRAID 6.10.x ### 2023.04.01 - Make tools.sh work with multiple Intel Graphic Cards; - Restore libvirt.php when module download failed; - Make slot of PCI address to 0 when machine type is q35 ### 2023.03.30 - Add plugin page in Settings; - Fix HW transcode not work for PF on linux-5.19 ### 2023.03.28 - Change PCI address of VF to 0000:06:10.0 ### 2023.03.21 - Initial unRAID V6.11 release. rm -f $(ls &plugin;/unraid-&name;*.txz 2>/dev/null|grep -v '&version;') **Intel Graphics SR-IOV** This package contains a modified i915 driver with SR-IOV support for Intel 12Gen+ CPUs. ATTENTION: This package is highly experimental and you should only install it if you know what you are doing! You can get more details here: https://github.com/strongtz/i915-sriov-dkms &gitURL;/packages/unraid-&name;-&version;.txz &md5; #Download i915-sriov module Package download() { # Download sriov package if wget -q -nc --show-progress --progress=bar:force:noscroll -O "&packages;/${KERNEL_V%%-*}/${LAT_PACKAGE}" "${DL_URL}/${LAT_PACKAGE}" ; then wget -q -nc --show-progress --progress=bar:force:noscroll -O "&packages;/${KERNEL_V%%-*}/${LAT_PACKAGE}.md5" "${DL_URL}/${LAT_PACKAGE}.md5" if [ "$(md5sum &packages;/${KERNEL_V%%-*}/${LAT_PACKAGE} | awk '{print $1}')" != "$(cat &packages;/${KERNEL_V%%-*}/${LAT_PACKAGE}.md5 | awk '{print $1}')" ]; then echo echo "-----ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR------" echo "--------------------------------CHECKSUM ERROR!---------------------------------" removepkg unraid-&name;-&version; rm -rf &plugin; &emhttp; exit 1 fi echo echo "-----------Successfully downloaded SR-IOV package, please wait...!------------" else echo echo "-----ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR-----" echo "-----------------------Can't download SR-IOV package---------------------------" removepkg unraid-&name;-&version; rm -rf &plugin; &emhttp; exit 1 fi } check() { if ! ls -1 &packages;/${KERNEL_V%%-*}/ | grep -q "${PACKAGE}" ; then LAT_PACKAGE="$(wget -qO- https://api.github.com/repos/ich777/unraid-i915-sriov/releases/tags/${KERNEL_V} | jq -r '.assets[].name' | grep "${PACKAGE}" | grep -E -v '\.md5$' | sort -V | tail -1)" echo echo "------------------Downloading SR-IOV package, please wait...!-----------------" echo "----------This could take some time, please don't close this window!----------" download else echo echo "------------------------SR-IOV package found locally!-------------------------" fi } # Installation install() { /sbin/installpkg "&packages;/${KERNEL_V%%-*}/${PACKAGE}*.txz" depmod -a } enable_module() { modprobe i915 enable_guc=3 max_vfs=7 } #Create settings file if not found if [ ! -f "&plugin;/&name;.cfg" ]; then FIRST_INSTALL="true" echo 'vfnumber=2' > "&plugin;/&name;.cfg" fi #Check if i915 module is already blacklisted and let the plugin handle the activation from module if [ ! "$(grep "blacklist" /boot/config/modprobe.d/i915.conf 2>/dev/null)" ]; then if [ ! -d /boot/config/modprobe.d ]; then mkdir -p /boot/config/modprobe.d fi echo "blacklist i915" >> /boot/config/modprobe.d/i915.conf fi #Patch libverit.php on Unraid versions below 6.13.0 TARGET_V="6.12.99" COMPARE="$(cat /etc/unraid-version | cut -d '=' -f2 | cut -d '"' -f2) $TARGET_V" if [ "$TARGET_V" == "$(echo "$COMPARE" | sort -V | tail -1)" ]; then if [ ! -f /usr/local/emhttp/plugins/dynamix.vm.manager/include/libvirt.php.orig ]; then cp /usr/local/emhttp/plugins/dynamix.vm.manager/include/libvirt.php /usr/local/emhttp/plugins/dynamix.vm.manager/include/libvirt.php.orig else cp /usr/local/emhttp/plugins/dynamix.vm.manager/include/libvirt.php.orig /usr/local/emhttp/plugins/dynamix.vm.manager/include/libvirt.php fi # Fix PCI address error when iGPU VF assigned to VM cd / ; patch -p1 <<EOF --- a/usr/local/emhttp/plugins/dynamix.vm.manager/include/libvirt.php +++ b/usr/local/emhttp/plugins/dynamix.vm.manager/include/libvirt.php @@ -780,7 +780,15 @@ \$strSpecialAddress = ''; if (\$gpu_bus == '00' && \$gpu_slot == '02') { \$strXVGA = ''; - \$strSpecialAddress = "<address type='pci' domain='0x0000' bus='0x".\$gpu_bus."' slot='0x".\$gpu_slot."' function='0x".\$gpu_function."'/>"; + if (\$gpu_function == '00') { + \$strSpecialAddress = "<address type='pci' domain='0x0000' bus='0x".\$gpu_bus."' slot='0x".\$gpu_slot."' function='0x".\$gpu_function."'/>"; + } else { + if (\$machine_type == 'q35'){ + \$strSpecialAddress = "<address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/>"; + } else { + \$strSpecialAddress = "<address type='pci' domain='0x0000' bus='0x06' slot='0x10' function='0x0'/>"; + } + } } \$strRomFile = ''; EOF fi #Define Variables KERNEL_V="$(uname -r)" PACKAGE="i915-sriov" DL_URL="https://github.com/ich777/unraid-i915-sriov/releases/download/$KERNEL_V" if [ ! -d "&packages;/${KERNEL_V%%-*}" ]; then mkdir -p "&packages;/${KERNEL_V%%-*}" fi #Check for old packages rm -rf $(ls -d &packages;/* | grep -v "${KERNEL_V%%-*}") #Execute functions check if ! ls -1 /var/log/packages/ | grep -q "^${PACKAGE}" ; then echo "---------------------------Installing SR-IOV package---------------------------" install else echo "----------------SR-IOV package already installed, nothing to do----------------" fi if ! lsmod | grep -q "^i915" ; then echo "-------------------------Loading Kernel Module 'i915'--------------------------" enable_module else echo "---------------------Kernel Module 'i915' already enabled----------------------" fi if [ -f "/sys/devices/pci0000:00/0000:00:02.0/sriov_numvfs" ]; then VF_NUM="$(cat &plugin;/&name;.cfg | grep "vfnumber=" | cut -d '=' -f2 | sed "s/\"//g")" CUR_VF_NUM="$(cat /sys/devices/pci0000:00/0000:00:02.0/sriov_numvfs)" sleep 2 if [ "$VF_NUM" != "$CUR_VF_NUM" ]; then echo "---Setting VFs to: ${VF_NUM}---" echo ${VF_NUM} > /sys/devices/pci0000:00/0000:00:02.0/sriov_numvfs /usr/local/sbin/vfio-pci >/dev/null 2>&1 else echo "---VFs already set to: ${VF_NUM}---" /usr/local/sbin/vfio-pci >/dev/null 2>&1 fi fi if [ "$FIRST_INSTALL" == "true" ]; then echo echo "--------------------------------------------------------------------------------------------------" echo "---Installation from SR-IOV plugin successful, please reboot your server to start using SR-IOV!---" echo "--------------------------------------------------------------------------------------------------" echo else echo echo "-------------------------------------------------" echo "---Installation from SR-IOV plugin successful!---" echo "-------------------------------------------------" echo fi #Check if Plugin Update Helper is downloaded and up-to-date if [ ! -f &plugin;/plugin_update_helper ]; then wget -q -T 5 -O &plugin;/plugin_update_helper "https://raw.githubusercontent.com/ich777/unraid-plugin_update_helper/master/plugin_update_helper" else CUR_V="$(grep -E "Plugin-Update-Helper version:" &plugin;/plugin_update_helper | awk '{print $4}')" if [ ! -s /tmp/update-helper ]; then echo "$(wget -T5 -qO- https://raw.githubusercontent.com/ich777/unraid-plugin_update_helper/master/plugin_update_helper | grep -E "Plugin-Update-Helper version:" | awk '{print $4}')" > /tmp/update-helper AVAIL_V="$(cat /tmp/update-helper)" else AVAIL_V="$(cat /tmp/update-helper)" fi if [ ! -z "$AVAIL_V" ]; then COMPARE="$(sort -V <(echo -e "${AVAIL_V}\n$CUR_V") | tail -1)" if [ "$CUR_V" != "$COMPARE" ]; then wget -q -T 5 -O &plugin;/plugin_update_helper "https://raw.githubusercontent.com/ich777/unraid-plugin_update_helper/master/plugin_update_helper" fi fi fi #Check if Plugin Update Helper is installed and up to date if [ ! -f /usr/bin/plugin_update_helper ]; then cp &plugin;/plugin_update_helper /usr/bin/plugin_update_helper chmod +x /usr/bin/plugin_update_helper else PLUGIN_V="$(grep -E "Plugin-Update-Helper version:" &plugin;/plugin_update_helper | awk '{print $4}')" INST_V="$(grep -E "Plugin-Update-Helper version:" /usr/bin/plugin_update_helper | awk '{print $4}')" COMPARE="$(sort -V <(echo -e "${PLUGIN_V}\n$INST_V") | tail -1)" if [ "$INST_V" != "$COMPARE" ]; then kill $(ps aux | grep -E "inotifywait -q /boot/changes.txt -e move_self,delete_self" | grep -v "grep -E inotifywait" | awk '{print $2}') 2>/dev/null sleep 1 cp &plugin;/plugin_update_helper /usr/bin/plugin_update_helper chmod +x /usr/bin/plugin_update_helper fi fi #Start Plugin Update Helper if [ -z "$(ps aux | grep -E "inotifywait -q /boot/changes.txt -e move_self,delete_self" | grep -v "grep -E inotifywait" | awk '{print $2}')" ]; then echo "/usr/bin/plugin_update_helper" | at now -M > /dev/null 2>&1 fi echo echo "--------------------------------" echo "---Uninstalling SR-IOV plugin---" echo "--------------------------------" removepkg unraid-&name;-&version; rm -rf &plugin; &emhttp; # Restore libvirt.php if [ -f /usr/local/emhttp/plugins/dynamix.vm.manager/include/libvirt.php.orig ]; then cp /usr/local/emhttp/plugins/dynamix.vm.manager/include/libvirt.php.orig /usr/local/emhttp/plugins/dynamix.vm.manager/include/libvirt.php rm /usr/local/emhttp/plugins/dynamix.vm.manager/include/libvirt.php.orig fi # Remove blacklist if [ "$(grep -v "blacklist" /boot/config/modprobe.d/i915.conf 2>/dev/null)" ]; then sed -i '/blacklist i915/d' /boot/config/modprobe.d/i915.conf 2>/dev/null else rm -rf /boot/config/modprobe.d/i915.conf 2>/dev/null fi echo echo "-----------------------------------------------------------" echo "---SR-IOV plugin uninstalled, please reboot your server!---" echo "-----------------------------------------------------------"