diff --git a/emhttp/plugins/dynamix/include/SriovHelpers.php b/emhttp/plugins/dynamix/include/SriovHelpers.php index 5ad88aa7ac..1ea7fc0799 100644 --- a/emhttp/plugins/dynamix/include/SriovHelpers.php +++ b/emhttp/plugins/dynamix/include/SriovHelpers.php @@ -58,10 +58,10 @@ function getSriovInfoJson(bool $includeVfDetails = true): string { foreach ($paths as $totalvfFile) { $devdir = dirname($totalvfFile); $pci = basename($devdir); + $numVfsFile = "$devdir/sriov_numvfs"; $total_vfs = (int) @file_get_contents($totalvfFile); - $num_vfs = (int) @file_get_contents("$devdir/sriov_numvfs"); - + $num_vfs = (int) @file_get_contents($numVfsFile); // Driver/module detection $driver = $module = $vf_param = null; $driver_link = "$devdir/driver"; @@ -141,6 +141,7 @@ function getSriovInfoJson(bool $includeVfDetails = true): string { return json_encode($results, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); } +// Rebind VF to original or vfio-pci driver. function rebindVfDriver($vf, $sriov, $target = 'original') { $res = ['pci'=>$vf,'success'=>false,'error'=>null,'details'=>[]]; diff --git a/emhttp/plugins/dynamix/include/SysDevs.php b/emhttp/plugins/dynamix/include/SysDevs.php index 23b8e60c5c..8f3d980b31 100644 --- a/emhttp/plugins/dynamix/include/SysDevs.php +++ b/emhttp/plugins/dynamix/include/SysDevs.php @@ -387,7 +387,17 @@ function createIOMMUCheckBox($pciaddress,$vd,$iommu,$line) { break; } - if (array_key_exists($pciaddress,$sriov) && in_array(substr($sriov[$pciaddress]['class_id'],0,4),$allowedPCIClass)) { + static $i915SriovPluginInstalled = null; + if ($i915SriovPluginInstalled === null) { + $i915SriovPluginInstalled = is_file('/boot/config/plugins/i915-sriov.plg') + || is_file('/var/log/plugins/i915-sriov.plg'); + } + $isI915SriovPci = (substr($pciaddress, -7) === '00:02.0'); + $showI915SriovOptions = $i915SriovPluginInstalled && $isI915SriovPci; + $isAllowedSriovDevice = array_key_exists($pciaddress,$sriov) + && in_array(substr($sriov[$pciaddress]['class_id'],0,4),$allowedPCIClass); + + if ($isAllowedSriovDevice && (!$isI915SriovPci || $showI915SriovOptions)) { echo "