From 1266a3dfe49cb3a2bed04f07f846dadadefaeaad Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sun, 9 Nov 2025 08:58:50 +0000 Subject: [PATCH] WIP Progress updates. --- emhttp/plugins/dynamix/SysDevs.page | 128 ++++++++- .../plugins/dynamix/include/SriovHelpers.php | 254 ++++++++++++++++++ emhttp/plugins/dynamix/include/SysDevs.php | 253 +---------------- .../dynamix/include/apply.sriov-cfg.php | 94 +++++++ .../dynamix/include/update.sriov-cfg.php | 1 + sbin/sriov | 9 +- sbin/{sriov-setmac.sh => sriov-vfsettings.sh} | 0 7 files changed, 475 insertions(+), 264 deletions(-) create mode 100644 emhttp/plugins/dynamix/include/SriovHelpers.php create mode 100644 emhttp/plugins/dynamix/include/apply.sriov-cfg.php rename sbin/{sriov-setmac.sh => sriov-vfsettings.sh} (100%) mode change 100755 => 100644 diff --git a/emhttp/plugins/dynamix/SysDevs.page b/emhttp/plugins/dynamix/SysDevs.page index a0bdd651d..a2f4ca80b 100644 --- a/emhttp/plugins/dynamix/SysDevs.page +++ b/emhttp/plugins/dynamix/SysDevs.page @@ -25,22 +25,15 @@ $(function(){ function applyCfg() { var message = "_(System Devices)_: _(A reboot is required to apply changes)_"; var string = "BIND="; - var vfstring = "BIND="; var elements = document.getElementById("vfiopci").elements; for (var i = 0, element; element = elements[i++];) { if (element.type === "checkbox" && element.checked === true && element.className.substring(0, 5) === "iommu") string = string + element.value + " "; - if (element.type === "checkbox" && element.checked === true && element.className.substring(0, 7) === "vfiommu") - vfstring = vfstring + element.value + " "; } string = string.trim(); if (string === "BIND=") { string = ""; } - vfstring = vfstring.trim(); - if (vfstring === "BIND=") { - vfstring = ""; - } $.post( "/plugins/dynamix/include/update.vfio-pci-cfg.php", { cfg: string } ) .done(function(d) { if (d==1) { @@ -54,24 +47,24 @@ function applyCfg() { }); } -function saveVFSettingsConfig(pciId,vd) { +function saveVFSettingsConfig(pciId,vd,interactive=1) { var message = "_(System Devices)_: _(A reboot is required to apply changes)_"; var mac = document.getElementById("vfmac" + pciId).value; - var vfio = document.getElementById("vfio" + pciId).value; + var vfio = document.getElementById("vfvfio" + pciId).checked; - $.post( "/plugins/dynamix/include/update.sriov-cfg.php", { type:"sriovmac", pciid: pciId, vd:vd, vfio:vfio, mac:mac } ) + $.post( "/plugins/dynamix/include/update.sriov-cfg.php", { type:"sriovsettings", pciid: pciId, vd:vd, vfio:vfio, mac:mac } ) .done(function(d) { if (d==1) { addRebootNotice(message); document.getElementById("warning").innerHTML = "_(ALERT)_: _(Changes saved)_. _(Reboot to take effect)_."; - swal("MACs Saved", "success"); + if (interactive == 1) swal("MACs Saved","", "success"); } else { removeRebootNotice(message); document.getElementById("warning").innerHTML = "_(No changes)_."; } }); } -function saveVFsConfig(pciId,vd) { +function saveVFsConfig(pciId,vd,interactive=1) { var message = "_(System Devices)_: _(A reboot is required to apply changes)_"; var numvfs = document.getElementById("vf" + pciId).value; @@ -80,13 +73,14 @@ function saveVFsConfig(pciId,vd) { if (d==1) { addRebootNotice(message); document.getElementById("warning").innerHTML = "_(ALERT)_: _(Changes saved)_. _(Reboot to take effect)_."; - swal("VFs Saved ","success"); - docum + if (interactive == 1) swal("VFs Saved ","","success"); } else { removeRebootNotice(message); document.getElementById("warning").innerHTML = "_(No changes)_."; } + $('#t1').load('/webGui/include/SysDevs.php', { table: 't1' }); }); + } function generateMAC(pciId) { @@ -148,6 +142,112 @@ function generateMAC(pciId) { }); } +function applyVFSettings(pciId,vd) { + saveVFSettingsConfig(pciId,vd,0); + var message = "_(System Devices)_: _(A reboot is required to apply changes)_"; + var mac = document.getElementById("vfmac" + pciId).value; + var vfio = document.getElementById("vfvfio" + pciId).checked; + + $.post( "/plugins/dynamix/include/apply.sriov-cfg.php", { type:"sriovsettings", pciid: pciId, vd:vd, vfio:vfio, mac:mac } ) + .done(function(d) { + if (d==1) { + addRebootNotice(message); + document.getElementById("warning").innerHTML = "_(ALERT)_: _(Changes saved)_. _(Reboot to take effect)_."; + swal("VFs Saved ","","success"); + } else { + removeRebootNotice(message); + document.getElementById("warning").innerHTML = "_(No changes)_."; + } + }); + +} + +function applyVFsConfig(pciId, vd, vfs) { + saveVFsConfig(pciId,vd,0); + var message = "_(System Devices)_: _(A reboot is required to apply changes)_"; + var numvfs = document.getElementById("vf" + pciId).value; + + // Case 1: VFs will be removed + if (vfs != 0 && numvfs == 0) { + swal({ + title: "VFs will be removed", + text: "Card will reset.", + type: "warning", + showCancelButton: false, + confirmButtonColor: "#3085d6", + confirmButtonText: "OK", + closeOnConfirm: true + }, function() { + doApply(pciId, vd, numvfs, message); + }); + return; + } + + // Case 2: Number of VFs changed + if (vfs != numvfs && numvfs != 0) { + swal({ + title: "Number of VFs changed", + text: "Will need to remove and re-add VFs.", + type: "warning", + showCancelButton: false, + confirmButtonColor: "#3085d6", + confirmButtonText: "OK", + closeOnConfirm: true + }, function() { + doApply(pciId, vd, numvfs, message); + }); + } +} + +function doApply(pciId, vd, numvfs, message) { + // Show "updating" alert immediately + swal({ + title: "Updating...", + text: "Please wait while configuration is applied.", + type: "info", + showConfirmButton: false, + allowOutsideClick: false + }); + + // Perform the POST + $.post("/plugins/dynamix/include/apply.sriov-cfg.php", { + type: "sriov", + pciid: pciId, + vd: vd, + numvfs: numvfs + }) + .done(function (d) { + // Update UI based on server response + if (d == 1) { + addRebootNotice(message); + document.getElementById("warning").innerHTML = + "_(ALERT)_: _(Changes saved)_. _(Reboot to take effect)_."; + } else { + removeRebootNotice(message); + document.getElementById("warning").innerHTML = "_(No changes)_."; + } + + // Replace the "updating" alert with "done" + swal({ + title: "Update Complete", + text: "Configuration successfully applied.", + type: "success", + timer: 3000, // show for 3 seconds + showConfirmButton: false // hide OK button + }); + + // Reload table + $('#t1').load('/webGui/include/SysDevs.php', { table: 't1' }); + }) + .fail(function () { + swal({ + title: "Error", + text: "Failed to apply configuration.", + type: "error", + showConfirmButton: true + }); + }); +} function formatFullInput(input) { return input diff --git a/emhttp/plugins/dynamix/include/SriovHelpers.php b/emhttp/plugins/dynamix/include/SriovHelpers.php new file mode 100644 index 000000000..332c2829a --- /dev/null +++ b/emhttp/plugins/dynamix/include/SriovHelpers.php @@ -0,0 +1,254 @@ + + $vf_pci]; + + if ($includeVfDetails) { + // Network interface info + $net = glob("/sys/bus/pci/devices/{$vf_pci}/net/*"); + if ($net && isset($net[0])) { + $iface = basename($net[0]); + $vf_entry['iface'] = $iface; + $macFile = "/sys/class/net/{$iface}/address"; + if (is_readable($macFile)) { + $vf_entry['mac'] = trim(file_get_contents($macFile)); + } + } + + // IOMMU group + $iommu_link = "/sys/bus/pci/devices/{$vf_pci}/iommu_group"; + if (is_link($iommu_link)) { + $vf_entry['iommu_group'] = basename(readlink($iommu_link)); + } else { + $vf_entry['iommu_group'] = null; + } + + // --- Current driver --- + $driver_link = "/sys/bus/pci/devices/{$vf_pci}/driver"; + if (is_link($driver_link)) { + $vf_entry['driver'] = basename(readlink($driver_link)); + } else { + $vf_entry['driver'] = null; // no driver bound + } + } + $vfs[] = $vf_entry; + } + + $results[$pci] = [ + 'class' => $class, + 'class_id' => $class_id, + 'name' => $name, + 'driver' => $driver, + 'module' => $module, + 'vf_param' => $vf_param, + 'total_vfs' => $total_vfs, + 'num_vfs' => $num_vfs, + 'vfs' => $vfs + ]; + } + + ksort($results, SORT_NATURAL); + return json_encode($results, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); +} + +function detectVfParam(string $driver): ?string { + if (!function_exists('shell_exec')) return null; + $out = @shell_exec('modinfo ' . escapeshellarg($driver) . ' 2>/dev/null'); + if (!$out) return null; + + $lines = explode("\n", strtolower($out)); + $params = []; + foreach ($lines as $line) { + if (preg_match('/^parm:\s+(\S+)/', $line, $m)) $params[] = $m[1]; + } + + foreach (['max_vfs', 'num_vfs', 'sriov_numvfs', 'sriov_vfs'] as $key) + if (in_array($key, $params, true)) return $key; + + foreach ($params as $p) + if (preg_match('/vf/', $p)) return $p; + + return null; +} + +/** + * Robustly get PCI class (text + numeric ID) and device name from lspci/sysfs. + */ +function getPciClassNameAndId(string $pci): array { + $class = 'Unknown'; + $class_id = null; + $name = 'Unknown'; + + // Numeric class code from sysfs + $classFile = "/sys/bus/pci/devices/{$pci}/class"; + if (is_readable($classFile)) { + $raw = trim(file_get_contents($classFile)); + $class_id = sprintf("0x%04x", (hexdec($raw) >> 8) & 0xFFFF); + } + + // Try lspci -mm for machine-readable info + $out = trim(@shell_exec('lspci -mm -s ' . escapeshellarg($pci) . ' 2>/dev/null')); + if ($out && preg_match('/"([^"]+)"\s+"([^"]+)"\s+"([^"]+)"/', $out, $m)) { + $class = $m[1]; + $name = trim($m[3]); + return [$class, $class_id, $name]; + } + + // Fallback to regular lspci output + $alt = trim(@shell_exec('lspci -s ' . escapeshellarg($pci) . ' 2>/dev/null')); + if ($alt && preg_match('/^[\da-fA-F:.]+\s+([^:]+):\s+(.+)/', $alt, $m)) { + $class = trim($m[1]); + $name = trim($m[2]); + } + + return [$class, $class_id, $name]; +} + +/** + * Enumerate all VFs and group them by IOMMU group + * Output: associative array or JSON with keys like "IOMMU group 29" + */ +function getVfListByIommuGroup(): array { + $groups = []; + + foreach (glob('/sys/bus/pci/devices/*/physfn') as $vf_physfn) { + $vf_dir = dirname($vf_physfn); + $vf_pci = basename($vf_dir); + + $iommu_link = "$vf_dir/iommu_group"; + if (is_link($iommu_link)) { + $iommu_group = basename(readlink($iommu_link)); + } else { + $iommu_group = "unknown"; + } + + $groups[] = "IOMMU group " . $iommu_group; + $groups[] = $vf_pci; + } + + ksort($groups, SORT_NATURAL); + return $groups; +} + +// ---------------------- +// Parse SR-IOV VF counts +// ---------------------- +function parseVFvalues() { + $sriov_devices = []; + $DBDF_SRIOV_REGEX = '/^[[:xdigit:]]{4}:[[:xdigit:]]{2}:[[:xdigit:]]{2}\.[[:xdigit:]]\|[[:xdigit:]]{4}:[[:xdigit:]]{4}\|[[:digit:]]+$/'; + if (is_file("/boot/config/sriov.cfg")) { + $file = trim(file_get_contents("/boot/config/sriov.cfg")); + $file = preg_replace('/^VFS=/', '', $file); // Remove prefix + $entries = preg_split('/\s+/', $file, -1, PREG_SPLIT_NO_EMPTY); + + foreach ($entries as $entry) { + if (preg_match($DBDF_SRIOV_REGEX, $entry)) { + // Format: || + [$dbdf, $ven_dev, $vf_count] = explode('|', $entry); + $sriov_devices[$dbdf] = [ + 'dbdf' => $dbdf, + 'vendor' => $ven_dev, + 'vf_count' => (int)$vf_count, + ]; + } + } + + # $sriov_devices = array_values(array_unique($sriov_devices, SORT_REGULAR)); + return $sriov_devices; + } +} + +// --------------------------------- +// Parse SR-IOV VF settings (VFIO+MAC) +// --------------------------------- +function parseVFSettings() { + $sriov_devices_settings = []; + $DBDF_SRIOV_SETTINGS_REGEX = '/^[[:xdigit:]]{4}:[[:xdigit:]]{2}:[[:xdigit:]]{2}\.[[:xdigit:]]\|[[:xdigit:]]{4}:[[:xdigit:]]{4}\|[01]\|([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}$/'; + if (is_file("/boot/config/sriovvfs.cfg")) { + $file = trim(file_get_contents("/boot/config/sriovvfs.cfg")); + $file = preg_replace('/^VFSETTINGS=/', '', $file); // Remove prefix + $entries = preg_split('/\s+/', $file, -1, PREG_SPLIT_NO_EMPTY); + + foreach ($entries as $entry) { + if (preg_match($DBDF_SRIOV_SETTINGS_REGEX, $entry)) { + // Format: ||| + [$dbdf, $ven_dev, $vfio_flag, $mac] = explode('|', $entry); + $sriov_devices_settings[$dbdf] = [ + 'dbdf' => $dbdf, + 'vendor' => $ven_dev, + 'vfio' => (int)$vfio_flag, + 'mac' => strtoupper($mac), + ]; + } + } + + # $sriov_devices_settings = array_values(array_unique($sriov_devices_settings, SORT_REGULAR)); + return $sriov_devices_settings; + } +} +?> \ No newline at end of file diff --git a/emhttp/plugins/dynamix/include/SysDevs.php b/emhttp/plugins/dynamix/include/SysDevs.php index 94382790a..6823aad8f 100644 --- a/emhttp/plugins/dynamix/include/SysDevs.php +++ b/emhttp/plugins/dynamix/include/SysDevs.php @@ -1,6 +1,7 @@ $vf_pci]; - - if ($includeVfDetails) { - // Network interface info - $net = glob("/sys/bus/pci/devices/{$vf_pci}/net/*"); - if ($net && isset($net[0])) { - $iface = basename($net[0]); - $vf_entry['iface'] = $iface; - $macFile = "/sys/class/net/{$iface}/address"; - if (is_readable($macFile)) { - $vf_entry['mac'] = trim(file_get_contents($macFile)); - } - } - - // IOMMU group - $iommu_link = "/sys/bus/pci/devices/{$vf_pci}/iommu_group"; - if (is_link($iommu_link)) { - $vf_entry['iommu_group'] = basename(readlink($iommu_link)); - } else { - $vf_entry['iommu_group'] = null; - } - - // --- Current driver --- - $driver_link = "/sys/bus/pci/devices/{$vf_pci}/driver"; - if (is_link($driver_link)) { - $vf_entry['driver'] = basename(readlink($driver_link)); - } else { - $vf_entry['driver'] = null; // no driver bound - } - } - $vfs[] = $vf_entry; - } - - $results[$pci] = [ - 'class' => $class, - 'class_id' => $class_id, - 'name' => $name, - 'driver' => $driver, - 'module' => $module, - 'vf_param' => $vf_param, - 'total_vfs' => $total_vfs, - 'num_vfs' => $num_vfs, - 'vfs' => $vfs - ]; - } - - ksort($results, SORT_NATURAL); - return json_encode($results, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); -} - -function detectVfParam(string $driver): ?string { - if (!function_exists('shell_exec')) return null; - $out = @shell_exec('modinfo ' . escapeshellarg($driver) . ' 2>/dev/null'); - if (!$out) return null; - - $lines = explode("\n", strtolower($out)); - $params = []; - foreach ($lines as $line) { - if (preg_match('/^parm:\s+(\S+)/', $line, $m)) $params[] = $m[1]; - } - - foreach (['max_vfs', 'num_vfs', 'sriov_numvfs', 'sriov_vfs'] as $key) - if (in_array($key, $params, true)) return $key; - - foreach ($params as $p) - if (preg_match('/vf/', $p)) return $p; - - return null; -} - -/** - * Robustly get PCI class (text + numeric ID) and device name from lspci/sysfs. - */ -function getPciClassNameAndId(string $pci): array { - $class = 'Unknown'; - $class_id = null; - $name = 'Unknown'; - - // Numeric class code from sysfs - $classFile = "/sys/bus/pci/devices/{$pci}/class"; - if (is_readable($classFile)) { - $raw = trim(file_get_contents($classFile)); - $class_id = sprintf("0x%04x", (hexdec($raw) >> 8) & 0xFFFF); - } - - // Try lspci -mm for machine-readable info - $out = trim(@shell_exec('lspci -mm -s ' . escapeshellarg($pci) . ' 2>/dev/null')); - if ($out && preg_match('/"([^"]+)"\s+"([^"]+)"\s+"([^"]+)"/', $out, $m)) { - $class = $m[1]; - $name = trim($m[3]); - return [$class, $class_id, $name]; - } - - // Fallback to regular lspci output - $alt = trim(@shell_exec('lspci -s ' . escapeshellarg($pci) . ' 2>/dev/null')); - if ($alt && preg_match('/^[\da-fA-F:.]+\s+([^:]+):\s+(.+)/', $alt, $m)) { - $class = trim($m[1]); - $name = trim($m[2]); - } - - return [$class, $class_id, $name]; -} - -/* --- CLI Entry --- */ - $sriov = json_decode(getSriovInfoJson(true),true); - -/** - * Enumerate all VFs and group them by IOMMU group - * Output: associative array or JSON with keys like "IOMMU group 29" - */ -function getVfListByIommuGroup(): array { - $groups = []; - - foreach (glob('/sys/bus/pci/devices/*/physfn') as $vf_physfn) { - $vf_dir = dirname($vf_physfn); - $vf_pci = basename($vf_dir); - - $iommu_link = "$vf_dir/iommu_group"; - if (is_link($iommu_link)) { - $iommu_group = basename(readlink($iommu_link)); - } else { - $iommu_group = "unknown"; - } - - $groups[] = "IOMMU group " . $iommu_group; - $groups[] = $vf_pci; - } - - ksort($groups, SORT_NATURAL); - return $groups; -} +$sriov = json_decode(getSriovInfoJson(true),true); $sriovvfs = getVfListByIommuGroup(); +$sriov_devices=parseVFvalues(); +$sriov_devices_settings=parseVFSettings(); switch ($_POST['table']) { @@ -258,60 +82,6 @@ case 't1': $vfio_cfg_devices = array_values(array_unique($vfio_cfg_devices, SORT_STRING)); } -$DBDF_SRIOV_REGEX = '/^[[:xdigit:]]{4}:[[:xdigit:]]{2}:[[:xdigit:]]{2}\.[[:xdigit:]]\|[[:xdigit:]]{4}:[[:xdigit:]]{4}\|[[:digit:]]+$/'; -$DBDF_SRIOV_SETTINGS_REGEX = '/^[[:xdigit:]]{4}:[[:xdigit:]]{2}:[[:xdigit:]]{2}\.[[:xdigit:]]\|[[:xdigit:]]{4}:[[:xdigit:]]{4}\|[01]\|([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}$/'; - -// ---------------------- -// Parse SR-IOV VF counts -// ---------------------- -$sriov_devices = []; - -if (is_file("/boot/config/sriov.cfg")) { - $file = trim(file_get_contents("/boot/config/sriov.cfg")); - $file = preg_replace('/^VFS=/', '', $file); // Remove prefix - $entries = preg_split('/\s+/', $file, -1, PREG_SPLIT_NO_EMPTY); - - foreach ($entries as $entry) { - if (preg_match($DBDF_SRIOV_REGEX, $entry)) { - // Format: || - [$dbdf, $ven_dev, $vf_count] = explode('|', $entry); - $sriov_devices[$dbdf] = [ - 'dbdf' => $dbdf, - 'vendor' => $ven_dev, - 'vf_count' => (int)$vf_count, - ]; - } - } - - # $sriov_devices = array_values(array_unique($sriov_devices, SORT_REGULAR)); -} - -// --------------------------------- -// Parse SR-IOV VF settings (VFIO+MAC) -// --------------------------------- -$sriov_devices_settings = []; - -if (is_file("/boot/config/sriovvfs.cfg")) { - $file = trim(file_get_contents("/boot/config/sriovvfs.cfg")); - $file = preg_replace('/^VFSETTINGS=/', '', $file); // Remove prefix - $entries = preg_split('/\s+/', $file, -1, PREG_SPLIT_NO_EMPTY); - - foreach ($entries as $entry) { - if (preg_match($DBDF_SRIOV_SETTINGS_REGEX, $entry)) { - // Format: ||| - [$dbdf, $ven_dev, $vfio_flag, $mac] = explode('|', $entry); - $sriov_devices_settings[$dbdf] = [ - 'dbdf' => $dbdf, - 'vendor' => $ven_dev, - 'vfio' => (int)$vfio_flag, - 'mac' => strtoupper($mac), - ]; - } - } - - # $sriov_devices_settings = array_values(array_unique($sriov_devices_settings, SORT_REGULAR)); -} - $disks = (array)parse_ini_file('state/disks.ini',true); $devicelist = array_column($disks, 'device'); $lines = array (); @@ -430,7 +200,6 @@ if (is_file("/boot/config/sriovvfs.cfg")) { echo "SRIOV Available VFs:{$sriov[$pciaddress]['total_vfs']}"; $num_vfs= $sriov[$pciaddress]['num_vfs']; - if (isset($sriov_devices[$pciaddress])) $file_numvfs = $sriov_devices[$pciaddress]['vf_count']; else $file_numvfs = 0; @@ -452,7 +221,7 @@ if (is_file("/boot/config/sriovvfs.cfg")) { echo " "._("Current:").$num_vfs; #sprintf(" "._("Current").":%1s",$num_vfs); echo ' '; - echo ' '; + echo ' '; if ($file_numvfs != $num_vfs) echo " ".sprintf(_("Pending action or reboot")); @@ -479,9 +248,9 @@ if (is_file("/boot/config/sriovvfs.cfg")) { if (file_exists('/sys/bus/pci/devices/'.$pciaddress.'/reset')) echo ""; echo ""; if (!$removed) { - echo '| or just - echo (in_array($pciaddress."|".$vd, $vfio_cfg_devices) || in_array($pciaddress, $vfio_cfg_devices)) ? " checked>" : ">"; + echo (array_key_exists($pciaddress,$sriov_devices_settings) && $sriov_devices_settings[$pciaddress]['vfio'] == 1) ? " checked>" : ">"; } } else { echo ""; } echo 'MAC Address:'; echo ""; echo ' '; - echo ' '; + echo ' '; if ($vrf['driver'] == "vfio-pci") echo _("Current").": "; echo $vrf['driver'] == "vfio-pci" ? _("Bound to VFIO") : strtoupper($vrf['mac']); diff --git a/emhttp/plugins/dynamix/include/apply.sriov-cfg.php b/emhttp/plugins/dynamix/include/apply.sriov-cfg.php new file mode 100644 index 000000000..fb7ead073 --- /dev/null +++ b/emhttp/plugins/dynamix/include/apply.sriov-cfg.php @@ -0,0 +1,94 @@ + + pf + + #Apply VF settings. + + + break; + case "sriovsettings": + $old = is_file($sriovvfs) ? rtrim(file_get_contents($sriovvfs)) : ''; + $newexplode = explode(" ",str_replace("VFSETTINGS=","",$old)); + $mac= _var($_POST,'mac'); + $vfio= _var($_POST,'vfio'); + if ($vfio == "true") $vfio = 1; else $vfio = 0; + $found = false; + foreach($newexplode as $key => $newelement) { + if (strpos($newelement,$newelement_check) !== false) { + $found = true; + if($mac == "" && $vfio == 0) { + unset($newexplode[$key]) ; + break; + } else { + $newexplode[$key] = $newelement_check.$vfio."|".$mac; + break; + } + } + } + if (!$found) $newexplode[] = $newelement_check.$vfio."|".$mac; + $new = "VFSETTINGS=".implode(" ",$newexplode); + $file = $sriovvfs; + break; + } +} + + +?> diff --git a/emhttp/plugins/dynamix/include/update.sriov-cfg.php b/emhttp/plugins/dynamix/include/update.sriov-cfg.php index 138505514..c55cff61c 100644 --- a/emhttp/plugins/dynamix/include/update.sriov-cfg.php +++ b/emhttp/plugins/dynamix/include/update.sriov-cfg.php @@ -58,6 +58,7 @@ if (isset($pciid) && isset($vd)) { $newexplode = explode(" ",str_replace("VFSETTINGS=","",$old)); $mac= _var($_POST,'mac'); $vfio= _var($_POST,'vfio'); + if ($vfio == "true") $vfio = 1; else $vfio = 0; $found = false; foreach($newexplode as $key => $newelement) { if (strpos($newelement,$newelement_check) !== false) { diff --git a/sbin/sriov b/sbin/sriov index c806736f6..5c1d5391a 100755 --- a/sbin/sriov +++ b/sbin/sriov @@ -67,15 +67,8 @@ VFSETTINGS_LINE=$(grep "^VFSETTINGS=" "$CFG_VFS" | cut -d= -f2- | tr -d '"') for PARAM_VFS in $VFSETTINGS_LINE; do IFS='|' read -r arg1 arg2 arg3 arg4 <<< "$PARAM_VFS" echo "Processing $arg1 $arg2 set Mac to $arg4" - /usr/local/sbin/sriov-setmac.sh "$arg1" "$arg2" "$arg4" + /usr/local/sbin/sriov-vfsettings.sh "$arg1" "$arg2" "$arg3" "$arg4" echo "---" - - if [[ "$arg3" == "1" ]]; then - /usr/local/sbin/vfio-pci-bind.sh "$arg1" "$arg2" \ - 1>>/var/log/vfio-pci \ - 2>>/var/log/vfio-pci-errors - fi - done diff --git a/sbin/sriov-setmac.sh b/sbin/sriov-vfsettings.sh old mode 100755 new mode 100644 similarity index 100% rename from sbin/sriov-setmac.sh rename to sbin/sriov-vfsettings.sh