Skip to content

Conversation

@SimonFair
Copy link
Contributor

@SimonFair SimonFair commented Jan 10, 2026

Summary by CodeRabbit

  • New Features

    • UI text standardized to "SR-IOV"; device listings now surface per-device PCI class and SR-IOV warnings that can disable VM start.
  • Bug Fixes

    • MAC assignment now applies only to network-class VFs with stronger validation and clearer errors.
    • GPU/device lists exclude PFs that have VFs to prevent incorrect selections; VFIO/rebind behavior adjusted for class-specific handling.
  • Chores

    • VF settings format and tooling updated to carry class information through settings and apply flows.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 10, 2026

Walkthrough

Propagated a new per‑VF class_id through UI, helpers, backend, and scripts; exposed per‑VF PCI class info; changed VFSETTINGS entries to include class_id; and restricted MAC assignment to network PCI class (0x02).

Changes

Cohort / File(s) Summary
UI & Apply/Save Flow
emhttp/plugins/dynamix/SysDevs.page
Added class_id param to saveVFSettingsConfig, applyVFSettings, doVFSettingApply signatures and calls; propagate class_id through apply/save flow; conditional MAC handling based on class_id.
SR‑IOV Helpers & VF data
emhttp/plugins/dynamix/include/SriovHelpers.php
Expose per‑VF class and class_id; extend allowed classes; parse and store VF PCI class info in VF entries.
SysDevs grouping & display
emhttp/plugins/dynamix/include/SysDevs.php
Change per‑IOMMU entry shape to ['line']; detect groups with SR‑IOV and adjust filtering/display and warning insertion.
Backend apply logic
emhttp/plugins/dynamix/include/apply.sriov-cfg.php
Read/propagate class_id from settings/POST; gate MAC processing to class_id == '0x02'; include class_id when invoking sriov-vfsettings.sh and in VFIO/rebind logic.
Settings format & CLI glue
emhttp/plugins/dynamix/include/update.sriov-cfg.php, sbin/sriov
VFSETTINGS entries changed from `pciid
VF settings script
sbin/sriov-vfsettings.sh
Add CLASS_ID arg (new 3rd param); shift VFIO/MAC positions; validate MAC; gate MAC ops to CLASS_ID == 0x02; add PF/VF discovery, driver unbind/rebind, stricter errors; preserve VFIO bind flow.
VM manager & checks
emhttp/plugins/dynamix.vm.manager/include/VMMachines.php, .../libvirt_helpers.php, .../javascript/vmmanager.js, .../scripts/pcicheck.php, emhttp/plugins/dynamix/include/DashboardApps.php
Include SriovHelpers, retrieve SR‑IOV info, normalize PCI IDs, set per‑VM $srioverror/srioverror when PFs have VFs, pass SR‑IOV error into VM context, and prevent start/autostart when SR‑IOV root device detected.
QEMU wrapper
sbin/qemu
Treat PCI=="sriov" as fatal: print SR‑IOV root device message and exit with status 1 to disable start/autostart.

Sequence Diagram(s)

sequenceDiagram
    participant UI as Browser UI
    participant Page as SysDevs.page (JS)
    participant Helper as SriovHelpers
    participant Server as apply.sriov-cfg.php
    participant Script as sbin/sriov-vfsettings.sh

    UI->>Page: user triggers "Apply VF settings" (includes class_id)
    Page->>Helper: request VF details (reads per‑VF class_id)
    Page->>Server: doVFSettingApply(pciId,vd,vfio,mac,currentvfio,currentmac,class_id,message)
    Server->>Script: invoke sriov-vfsettings.sh pciId vd class_id vfio [mac]
    Script->>Script: if class_id == 0x02 -> validate MAC, unbind driver, set MAC, rebind
    Script->>Script: if vfio requested -> bind to vfio
    Script-->>Server: result (success/failure)
    Server-->>Page: response
    Page->>Helper: saveVFSettingsConfig(..., class_id)
    Helper-->>Page: persisted
    Page-->>UI: display result
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰
I hopped through classes, code in paw,
0x02 for nets, 0x03 I saw,
Passing class_id down the trail,
MACs set where networks prevail,
A tiny rabbit clap — hooray!

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Feature: SRIOV GPU Changes' is vague and overly generic, using non-descriptive phrasing that fails to convey the specific nature of the changes across multiple systems and files. Consider a more specific title that describes the main change, such as 'Add SR-IOV class_id support across device and VM management' or 'Extend SR-IOV handling to include GPU class filtering.'
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 29daee5 and d79b409.

📒 Files selected for processing (1)
  • emhttp/plugins/dynamix/include/DashboardApps.php
🧰 Additional context used
🧠 Learnings (5)
📚 Learning: 2025-11-14T15:18:55.567Z
Learnt from: SimonFair
Repo: unraid/webgui PR: 2443
File: emhttp/plugins/dynamix/include/SriovHelpers.php:16-16
Timestamp: 2025-11-14T15:18:55.567Z
Learning: In the file emhttp/plugins/dynamix/include/SriovHelpers.php, the global variable $allowedPCIClass is defined and is used in emhttp/plugins/dynamix/include/SysDevs.php which includes SriovHelpers.php. This variable should not be flagged as unused.

Applied to files:

  • emhttp/plugins/dynamix/include/DashboardApps.php
📚 Learning: 2025-10-22T17:36:50.995Z
Learnt from: Squidly271
Repo: unraid/webgui PR: 0
File: :0-0
Timestamp: 2025-10-22T17:36:50.995Z
Learning: In the Unraid webgui codebase, when adjusting CPU pinning, 3rd party containers without template files do not appear in the list. Therefore, silently skipping non-existent template files without logging is the appropriate behavior in UpdateOne.php.

Applied to files:

  • emhttp/plugins/dynamix/include/DashboardApps.php
📚 Learning: 2025-06-03T21:27:15.912Z
Learnt from: zackspear
Repo: unraid/webgui PR: 2230
File: emhttp/plugins/dynamix/include/Templates.php:63-74
Timestamp: 2025-06-03T21:27:15.912Z
Learning: In the Unraid WebGUI codebase (emhttp/plugins/dynamix/include/Templates.php), there are known duplicate ID issues in checkbox templates across multiple template instances that the maintainers are aware of but have chosen not to address due to the effort required for legacy code improvements.

Applied to files:

  • emhttp/plugins/dynamix/include/DashboardApps.php
📚 Learning: 2025-06-21T00:10:40.789Z
Learnt from: zackspear
Repo: unraid/webgui PR: 2258
File: emhttp/plugins/dynamix/DashStats.page:0-0
Timestamp: 2025-06-21T00:10:40.789Z
Learning: In the Unraid webgui codebase (emhttp/plugins/dynamix), replacing `<i>` elements with `<button>` elements for accessibility would require extensive CSS refactoring due to legacy CSS having direct button styles that would conflict with icon-based toggles.

Applied to files:

  • emhttp/plugins/dynamix/include/DashboardApps.php
📚 Learning: 2025-12-28T15:54:58.673Z
Learnt from: mgutt
Repo: unraid/webgui PR: 2496
File: emhttp/plugins/dynamix/Browse.page:901-906
Timestamp: 2025-12-28T15:54:58.673Z
Learning: In the unraid/webgui codebase, CSRF validation is centralized in the global auto_prepend_file (local_prepend.php) which runs before every PHP request. Do not add per-script CSRF checks in individual files like Browse.page or Control.php. If a script relies on global validation, ensure it does not duplicate CSRF logic; otherwise extend the central preface to cover the needed checks.

Applied to files:

  • emhttp/plugins/dynamix/include/DashboardApps.php
🧬 Code graph analysis (1)
emhttp/plugins/dynamix/include/DashboardApps.php (1)
emhttp/plugins/dynamix/include/SriovHelpers.php (1)
  • getSriovInfoJson (54-142)
🔇 Additional comments (6)
emhttp/plugins/dynamix/include/DashboardApps.php (6)

22-22: LGTM!

The inclusion of SriovHelpers.php is correctly placed alongside other helper includes and provides access to the getSriovInfoJson() function used in the VM processing loop.


120-120: LGTM!

Good performance practice: fetching SR-IOV data once outside the loop rather than per-VM. The isset($sriov[$check_id]) check on line 174 handles the case where json_decode might return null gracefully.


164-177: Logic is correct for detecting SR-IOV PFs with VFs.

The check correctly identifies when a VM is configured to use an SR-IOV physical function (PF) that has virtual functions (VFs) defined, which would cause issues. The domain prefix normalization handles both formats (0000:xx:yy.z and xx:yy.z).

Minor style note: indentation inside the if blocks (lines 172, 175-176) uses extra spaces compared to surrounding code, but this is cosmetic.


201-203: LGTM!

The SR-IOV warning icon follows the same pattern as the existing PCI warning, maintaining UI consistency. The warning message clearly indicates the issue to users.


206-206: LGTM!

Consistent with the menu construction on line 178—both now pass $srioverror as the 13th parameter to addVMContext.


178-178: No action needed. The JavaScript function addVMContext in emhttp/plugins/dynamix.vm.manager/javascript/vmmanager.js (line 86) correctly accepts 13 parameters with srioverror as the final parameter, matching the PHP call.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

github-actions bot commented Jan 10, 2026

🔧 PR Test Plugin Available

A test plugin has been generated for this PR that includes the modified files.

Version: 2026.01.12.1719
Build: View Workflow Run

📥 Installation Instructions:

Install via Unraid Web UI:

  1. Go to Plugins → Install Plugin
  2. Copy and paste this URL:
https://preview.dl.unraid.net/pr-plugins/pr-2512/webgui-pr-2512.plg
  1. Click Install

Alternative: Direct Download

⚠️ Important Notes:

  • Testing only: This plugin is for testing PR changes
  • Backup included: Original files are automatically backed up
  • Easy removal: Files are restored when plugin is removed
  • Conflicts: Remove this plugin before installing production updates

📝 Modified Files:

Click to expand file list
emhttp/plugins/dynamix.vm.manager/include/VMMachines.php
emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php
emhttp/plugins/dynamix.vm.manager/javascript/vmmanager.js
emhttp/plugins/dynamix.vm.manager/scripts/pcicheck.php
emhttp/plugins/dynamix/SysDevs.page
emhttp/plugins/dynamix/include/DashboardApps.php
emhttp/plugins/dynamix/include/SriovHelpers.php
emhttp/plugins/dynamix/include/SysDevs.php
emhttp/plugins/dynamix/include/apply.sriov-cfg.php
emhttp/plugins/dynamix/include/update.sriov-cfg.php

🔄 To Remove:

Navigate to Plugins → Installed Plugins and remove webgui-pr-2512, or run:

plugin remove webgui-pr-2512

🤖 This comment is automatically generated and will be updated with each new push to this PR.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Fix all issues with AI agents
In @emhttp/plugins/dynamix/include/SriovHelpers.php:
- Around line 84-95: The PF's class variables ($class, $class_id, $name) are
being overwritten by VF loop assignments from getPciClassNameAndId($vf_pci);
rename the VF-specific variables (e.g., $vf_class, $vf_class_id, $vf_name)
inside the VF loop and use those new names when populating $vf_entry['class']
and $vf_entry['class_id'] so the original PF $class/$class_id/$name values (set
earlier) remain unchanged for $results[$pci]; update all references in the VF
loop accordingly (including where you set $vf_entry['class'] and
$vf_entry['class_id']) to prevent shadowing.

In @emhttp/plugins/dynamix/include/SysDevs.php:
- Around line 424-448: The switch on $class_id can leave $mac undefined for
unhandled classes, causing a warning where $mac is later used (e.g., around the
usage near line 460); initialize $mac before the switch (e.g., $mac = null) or
ensure the switch's default case sets $mac = null (and any related variables
like $action/$saveaction) so $mac is always defined regardless of $class_id,
referencing the existing variables $class_id, $vrf, $pciaddress and the switch
block in SysDevs.php.
- Around line 454-458: The echo calling applyVFSettings uses $current_mac even
for non-network classes, causing an undefined variable; ensure $current_mac is
initialized before it's used (e.g., set a default empty string or null) prior to
the switch that sets it for class_id "0x02", or ensure you pass a safe value
when calling applyVFSettings; update the code around the applyVFSettings echo
and the switch that sets $current_mac so $current_mac is always defined when
used with applyVFSettings (references: applyVFSettings(), $current_mac, $vrf,
$class_id).

In @emhttp/plugins/dynamix/SysDevs.page:
- Around line 431-435: The function applyVFSettings assigns to mac without a
declaration, creating an implicit global; update the code in applyVFSettings to
declare mac locally (e.g., use let mac = ... or const mac = (class_id == '0x02'
? document.getElementById("vfmac" + pciId).value : null)); mirror the same fix
you applied to saveVFSettingsConfig so mac is not a global variable.
- Around line 203-208: In saveVFSettingsConfig, mac is assigned without a
declaration making it an implicit global; fix this by declaring mac with let (or
const if not reassigned) before use (e.g., initialize let mac = null), then set
mac = document.getElementById("vfmac" + pciId).value only when class_id ==
'0x02'; ensure vfio remains read from document.getElementById("vfvfio" +
pciId).checked and update the $.post call to use the locally scoped mac
variable.
🧹 Nitpick comments (1)
emhttp/plugins/dynamix/include/apply.sriov-cfg.php (1)

225-225: Consider validating class_id input.

The class_id is retrieved from POST without validation. While it's used in string comparisons, validating it against expected values ('0x02', '0x03') would add defense-in-depth.

♻️ Optional: Add validation for class_id
        $mac         = _var($_POST, 'mac');
        $class_id    = _var($_POST, 'class_id');
+       // Validate class_id if provided
+       if ($class_id !== '' && !in_array($class_id, ['0x02', '0x03'], true)) {
+           json_response(false, _("Invalid device class"));
+       }
        $vfio        = _var($_POST, 'vfio');
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4a1e8f3 and 37df059.

📒 Files selected for processing (4)
  • emhttp/plugins/dynamix/SysDevs.page
  • emhttp/plugins/dynamix/include/SriovHelpers.php
  • emhttp/plugins/dynamix/include/SysDevs.php
  • emhttp/plugins/dynamix/include/apply.sriov-cfg.php
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-11-14T15:18:55.567Z
Learnt from: SimonFair
Repo: unraid/webgui PR: 2443
File: emhttp/plugins/dynamix/include/SriovHelpers.php:16-16
Timestamp: 2025-11-14T15:18:55.567Z
Learning: In the file emhttp/plugins/dynamix/include/SriovHelpers.php, the global variable $allowedPCIClass is defined and is used in emhttp/plugins/dynamix/include/SysDevs.php which includes SriovHelpers.php. This variable should not be flagged as unused.

Applied to files:

  • emhttp/plugins/dynamix/include/SysDevs.php
  • emhttp/plugins/dynamix/include/apply.sriov-cfg.php
  • emhttp/plugins/dynamix/include/SriovHelpers.php
  • emhttp/plugins/dynamix/SysDevs.page
📚 Learning: 2025-12-28T15:54:58.673Z
Learnt from: mgutt
Repo: unraid/webgui PR: 2496
File: emhttp/plugins/dynamix/Browse.page:901-906
Timestamp: 2025-12-28T15:54:58.673Z
Learning: In the unraid/webgui codebase, CSRF validation is centralized in the global auto_prepend_file (local_prepend.php) which runs before every PHP request. Do not add per-script CSRF checks in individual files like Browse.page or Control.php. If a script relies on global validation, ensure it does not duplicate CSRF logic; otherwise extend the central preface to cover the needed checks.

Applied to files:

  • emhttp/plugins/dynamix/include/SysDevs.php
  • emhttp/plugins/dynamix/include/apply.sriov-cfg.php
  • emhttp/plugins/dynamix/include/SriovHelpers.php
🧬 Code graph analysis (1)
emhttp/plugins/dynamix/include/apply.sriov-cfg.php (1)
emhttp/plugins/dynamix/include/Wrappers.php (1)
  • _var (106-108)
🔇 Additional comments (5)
emhttp/plugins/dynamix/include/SriovHelpers.php (1)

16-16: LGTM!

The extension of $allowedPCIClass to include '0x03' (Display class) alongside '0x02' (Network class) correctly enables SR-IOV support for GPUs. Based on learnings, this global variable is used in SysDevs.php which includes this file.

emhttp/plugins/dynamix/include/apply.sriov-cfg.php (1)

241-262: LGTM - Class-aware MAC and VFIO handling.

The logic correctly separates concerns:

  1. MAC changes only apply to network class (0x02) devices
  2. VFIO rebinding for non-network devices (e.g., GPU 0x03) proceeds without MAC considerations

The control flow ensures that when both MAC and VFIO change for network devices, the MAC path handles the driver rebind, preventing duplicate operations.

emhttp/plugins/dynamix/include/SysDevs.php (1)

449-449: LGTM - Proper class_id propagation to save action.

The saveVFSettingsConfig call correctly passes class_id to enable class-aware configuration saving.

emhttp/plugins/dynamix/SysDevs.page (2)

135-137: LGTM - Correctly enables display filter when SR-IOV filter is active.

Since SR-IOV now supports both network (0x02) and display (0x03) device classes, enabling showdisplay alongside shownetwork when showsriov is activated ensures all SR-IOV capable devices are visible.


487-528: LGTM - Proper class_id propagation through the apply workflow.

The doVFSettingApply function correctly:

  1. Accepts class_id as a parameter
  2. Includes it in the POST payload to apply.sriov-cfg.php
  3. Passes it to saveVFSettingsConfig on successful application

This ensures consistent class-aware handling throughout the configuration flow.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
sbin/sriov (1)

56-56: Typo: /n should be \n for newline.

The escape sequence for newline is \n, not /n.

Proposed fix
-echo -e "Loading settings config from $CFG_VFS/n"
+echo -e "Loading settings config from $CFG_VFS\n"
🤖 Fix all issues with AI agents
In @sbin/sriov-vfsettings.sh:
- Around line 162-165: The error message in the VF_INDEX check wrongly uses $BDF
(the VF address) as the PF; update the string in the if-block that checks
VF_INDEX (the lines around the VF_INDEX, VF_PCI check) to reference the actual
PF variable (e.g. $PF or $PF_BDF) instead of $BDF, and ensure that the chosen PF
variable is defined earlier in the script so the message reads like "Error: VF
index not found for $VF_PCI under PF $PF" (or use the exact PF variable name
used elsewhere, e.g. $PF_BDF).
🧹 Nitpick comments (3)
emhttp/plugins/dynamix/include/SriovHelpers.php (1)

84-95: Variable shadowing is intentional but consider renaming for clarity.

The $class, $class_id, and $name variables from line 76 are shadowed here. While this is intentional to get the VF's class info, the $name is fetched but not added to the VF entry. Consider either:

  1. Using distinct variable names (e.g., $vf_class, $vf_class_id) for clarity
  2. Adding $name to the VF entry if useful, or omit fetching it
emhttp/plugins/dynamix/include/update.sriov-cfg.php (1)

60-60: Consider validating class_id format.

The class_id is read from POST but not validated. While the regex in parseVFSettings() enforces 0x prefix on read, malformed input could be written to the config file.

Proposed validation
 $class_id = _var($_POST,'class_id');
+if (!preg_match('/^0x[0-9a-fA-F]{2}$/', $class_id)) {
+    echo 0;
+    exit;
+}
 $vfio= _var($_POST,'vfio');
sbin/sriov-vfsettings.sh (1)

140-143: Consider replacing ls | grep with a glob-based approach.

Shellcheck flags the ls | grep pattern as potentially problematic with non-alphanumeric filenames. While PCI paths are typically well-structured, a safer approach uses globs.

Proposed alternative
 PF_IFACE=$(basename "$(readlink -f "$PF_PATH/net"/* 2>/dev/null)")
 if [ -z "$PF_IFACE" ]; then
-    PF_IFACE=$(basename "$(ls -d /sys/class/net/*/device 2>/dev/null | grep "$PF_PATH" | head -n1 | cut -d/ -f5)")
+    for netdev in /sys/class/net/*/device; do
+        [ -e "$netdev" ] || continue
+        if [ "$(readlink -f "$netdev")" = "$PF_PATH" ]; then
+            PF_IFACE=$(basename "$(dirname "$netdev")")
+            break
+        fi
+    done
 fi
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 37df059 and b7c5d3a.

📒 Files selected for processing (5)
  • emhttp/plugins/dynamix/include/SriovHelpers.php
  • emhttp/plugins/dynamix/include/apply.sriov-cfg.php
  • emhttp/plugins/dynamix/include/update.sriov-cfg.php
  • sbin/sriov
  • sbin/sriov-vfsettings.sh
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-11-14T15:18:55.567Z
Learnt from: SimonFair
Repo: unraid/webgui PR: 2443
File: emhttp/plugins/dynamix/include/SriovHelpers.php:16-16
Timestamp: 2025-11-14T15:18:55.567Z
Learning: In the file emhttp/plugins/dynamix/include/SriovHelpers.php, the global variable $allowedPCIClass is defined and is used in emhttp/plugins/dynamix/include/SysDevs.php which includes SriovHelpers.php. This variable should not be flagged as unused.

Applied to files:

  • emhttp/plugins/dynamix/include/apply.sriov-cfg.php
  • emhttp/plugins/dynamix/include/SriovHelpers.php
  • emhttp/plugins/dynamix/include/update.sriov-cfg.php
📚 Learning: 2025-12-28T15:54:58.673Z
Learnt from: mgutt
Repo: unraid/webgui PR: 2496
File: emhttp/plugins/dynamix/Browse.page:901-906
Timestamp: 2025-12-28T15:54:58.673Z
Learning: In the unraid/webgui codebase, CSRF validation is centralized in the global auto_prepend_file (local_prepend.php) which runs before every PHP request. Do not add per-script CSRF checks in individual files like Browse.page or Control.php. If a script relies on global validation, ensure it does not duplicate CSRF logic; otherwise extend the central preface to cover the needed checks.

Applied to files:

  • emhttp/plugins/dynamix/include/apply.sriov-cfg.php
  • emhttp/plugins/dynamix/include/SriovHelpers.php
  • emhttp/plugins/dynamix/include/update.sriov-cfg.php
📚 Learning: 2025-10-04T05:22:33.141Z
Learnt from: Squidly271
Repo: unraid/webgui PR: 2421
File: emhttp/plugins/dynamix/include/DefaultPageLayout/MainContentTabless.php:23-0
Timestamp: 2025-10-04T05:22:33.141Z
Learning: In the Unraid webgui repository, `emhttp/webGui` is a symlink that points to `plugins/dynamix`. Therefore, paths using `$docroot/webGui/...` correctly resolve to `$docroot/plugins/dynamix/...` at runtime.

Applied to files:

  • emhttp/plugins/dynamix/include/update.sriov-cfg.php
🧬 Code graph analysis (2)
emhttp/plugins/dynamix/include/apply.sriov-cfg.php (1)
emhttp/plugins/dynamix/include/Wrappers.php (1)
  • _var (106-108)
emhttp/plugins/dynamix/include/update.sriov-cfg.php (1)
emhttp/plugins/dynamix/include/Wrappers.php (1)
  • _var (106-108)
🪛 Shellcheck (0.11.0)
sbin/sriov-vfsettings.sh

[warning] 142-142: Don't use ls | grep. Use a glob or a for loop with a condition to allow non-alphanumeric filenames.

(SC2010)

🔇 Additional comments (13)
sbin/sriov (2)

14-15: LGTM!

The updated comment correctly documents the new 5-field VFSETTINGS format including class_id.


68-70: LGTM!

The 5-field parsing and forwarding to sriov-vfsettings.sh is correctly implemented and consistent with the new format.

emhttp/plugins/dynamix/include/SriovHelpers.php (2)

16-16: LGTM!

Extending the allowed PCI class list to include 0x03 (display class) for GPU SR-IOV support is correct.


312-333: LGTM!

The updated regex and parsing correctly handle the new 5-field VFSETTINGS format with class_id validation.

emhttp/plugins/dynamix/include/apply.sriov-cfg.php (3)

121-126: LGTM!

Correctly gates MAC processing to network-class VFs only (class_id 0x02), which aligns with the design intent.


133-138: LGTM!

The command construction correctly includes class_id in the proper position with proper escaping.


246-267: LGTM!

The conditional logic correctly handles:

  1. MAC changes (network class only) with appropriate driver binding
  2. VFIO-only changes for non-network classes or when MAC is unchanged

The setVfMacAddress call on line 249 already handles the driver binding based on the target VFIO state, so combined MAC+VFIO changes are properly addressed.

emhttp/plugins/dynamix/include/update.sriov-cfg.php (1)

71-76: LGTM!

The entry construction correctly uses the 5-field format for both update and insert operations.

sbin/sriov-vfsettings.sh (5)

64-68: LGTM!

The updated argument count check and usage message correctly document the new 5-parameter interface.


71-92: LGTM!

The argument parsing correctly handles the positional parameters with appropriate pattern matching. The use of -z checks ensures proper ordering of CLASS_ID before VFIO parsing.


167-175: LGTM!

MAC validation is appropriate for network-class VFs. The caller is expected to provide a MAC address (or the reset value 00:00:00:00:00:00).


183-207: LGTM!

The driver unbind/rebind flow around MAC setting is correctly implemented, and the non-network class path appropriately skips MAC operations.


209-214: LGTM!

VFIO binding is correctly applied regardless of device class, which is appropriate since both network and GPU VFs can be passed through to VMs.

Change SRIOV to be SR-IOV
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
emhttp/plugins/dynamix/include/SysDevs.php (1)

223-227: Data structure mismatch for "Removed" group entries.

Line 226 stores removed entries as strings ($lsiommu[$removedKey][$bdf] = $line), but line 250 expects an associative array with a 'line' key ($pcidetail['line']). This will cause removed devices to fail rendering or display incorrect data.

Proposed fix: use consistent data structure
-        $lsiommu[$removedKey][$bdf] = $line;
+        $lsiommu[$removedKey][$bdf]['line'] = $line;
🤖 Fix all issues with AI agents
In @emhttp/plugins/dynamix/include/SysDevs.php:
- Around line 249-252: The foreach over $group can hit the metadata key
'_has_sriov' whose value is a boolean, so accessing $pcidetail['line'] causes
PHP warnings; in the loop (the foreach ($group as $pciaddress => $pcidetail)
block) add an explicit guard to skip non-array entries (e.g., continue if
!is_array($pcidetail)) before referencing $pcidetail['line'], and keep the
existing in_array($pciaddress,$sriovvfs) && !empty($group['_has_sriov']) check
intact.
- Around line 465-489: The switch lacks safe defaults causing $mac, $action, and
$saveaction to be undefined if $class_id falls through; fix by initializing
those variables before the switch (e.g. $mac = null; $action = ''; $saveaction =
'') or by populating them in the default: branch; ensure the rest of the code
that uses $mac (saved/current), the generateMAC() call, and the final
saveVFSettingsConfig(...) invocation always have defined values
($saved_mac/$current_mac should be derived from $mac after initialization).

In @emhttp/plugins/dynamix/SysDevs.page:
- Line 205: The assignment to mac in the SysDevs.page snippet is missing a
declaration and creates an implicit global; declare the variable (e.g., use let
or const) in the local scope before or as part of the conditional (replace the
bare assignment to mac in the class_id == '0x02' branch with a declared variable
like let mac = ... or declare let mac; then set mac = ... in the branches) so
mac is block-scoped and not global — update the line using the unique
identifiers class_id and pciId (or the element id "vfmac"+pciId) to locate and
fix the assignment.
- Line 434: The assignment to mac in the conditional creates an implicit global;
declare the variable locally (e.g., use let or const) before or in the branch so
it’s not global. Replace the bare assignment in the block that checks class_id
== '0x02' (the line using document.getElementById("vfmac" + pciId).value) with a
local declaration such as let mac = ... (or declare let mac; above and assign
inside the branches), mirroring the fix used at the other occurrence around line
205 to avoid leaking mac to the global scope.
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b7c5d3a and 2ede0ed.

📒 Files selected for processing (2)
  • emhttp/plugins/dynamix/SysDevs.page
  • emhttp/plugins/dynamix/include/SysDevs.php
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-11-14T15:18:55.567Z
Learnt from: SimonFair
Repo: unraid/webgui PR: 2443
File: emhttp/plugins/dynamix/include/SriovHelpers.php:16-16
Timestamp: 2025-11-14T15:18:55.567Z
Learning: In the file emhttp/plugins/dynamix/include/SriovHelpers.php, the global variable $allowedPCIClass is defined and is used in emhttp/plugins/dynamix/include/SysDevs.php which includes SriovHelpers.php. This variable should not be flagged as unused.

Applied to files:

  • emhttp/plugins/dynamix/SysDevs.page
  • emhttp/plugins/dynamix/include/SysDevs.php
📚 Learning: 2025-12-28T15:54:58.673Z
Learnt from: mgutt
Repo: unraid/webgui PR: 2496
File: emhttp/plugins/dynamix/Browse.page:901-906
Timestamp: 2025-12-28T15:54:58.673Z
Learning: In the unraid/webgui codebase, CSRF validation is centralized in the global auto_prepend_file (local_prepend.php) which runs before every PHP request. Do not add per-script CSRF checks in individual files like Browse.page or Control.php. If a script relies on global validation, ensure it does not duplicate CSRF logic; otherwise extend the central preface to cover the needed checks.

Applied to files:

  • emhttp/plugins/dynamix/include/SysDevs.php
🔇 Additional comments (6)
emhttp/plugins/dynamix/include/SysDevs.php (3)

116-136: LGTM!

The SR-IOV group flagging logic correctly identifies IOMMU groups that contain SR-IOV devices but where the first device is not SR-IOV. This enables appropriate warning display for ACS override requirements.


316-322: LGTM!

The SR-IOV warning appropriately alerts users when IOMMU groups contain mixed SR-IOV devices, directing them to enable ACS Override for proper isolation.


236-242: LGTM!

The filter adjustment correctly handles IOMMU groups where the first device is not SR-IOV by using the second device for class-based filtering. The _has_sriov key check prevents using metadata for filtering.

emhttp/plugins/dynamix/SysDevs.page (3)

74-74: LGTM!

The label update to "SR-IOV" follows standard terminology, and auto-enabling showdisplay when SR-IOV is toggled on ensures GPU-related SR-IOV devices are visible alongside network VFs.

Also applies to: 135-137


487-528: LGTM!

The doVFSettingApply function correctly propagates class_id and currentmac through the POST payload and subsequent save operation, enabling proper per-class handling on the server side.


188-193: LGTM!

Terminology updated to "SR-IOV" for consistency with industry standards.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
emhttp/plugins/dynamix/include/SysDevs.php (1)

317-323: Consider extracting the link from the translatable string.

The HTML <a> tag embedded in the translatable string may cause issues for translators and could break if the translation system escapes HTML. Consider separating the link:

♻️ Suggested improvement
-          echo '<span class="orange-text">'._('Warning').': '._('IOMMU group contains SR-IOV devices. Enable ACS Override in <a href="/Main/Flash#boot-parameters">Boot Parameters</a> for proper isolation').'.</span>';
+          echo '<span class="orange-text">'._('Warning').': '._('IOMMU group contains SR-IOV devices. Enable ACS Override in').' <a href="/Main/Flash#boot-parameters">'._('Boot Parameters').'</a> '._('for proper isolation').'.</span>';
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2ede0ed and 814f59f.

📒 Files selected for processing (3)
  • emhttp/plugins/dynamix/SysDevs.page
  • emhttp/plugins/dynamix/include/SriovHelpers.php
  • emhttp/plugins/dynamix/include/SysDevs.php
🚧 Files skipped from review as they are similar to previous changes (1)
  • emhttp/plugins/dynamix/SysDevs.page
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-11-14T15:18:55.567Z
Learnt from: SimonFair
Repo: unraid/webgui PR: 2443
File: emhttp/plugins/dynamix/include/SriovHelpers.php:16-16
Timestamp: 2025-11-14T15:18:55.567Z
Learning: In the file emhttp/plugins/dynamix/include/SriovHelpers.php, the global variable $allowedPCIClass is defined and is used in emhttp/plugins/dynamix/include/SysDevs.php which includes SriovHelpers.php. This variable should not be flagged as unused.

Applied to files:

  • emhttp/plugins/dynamix/include/SysDevs.php
  • emhttp/plugins/dynamix/include/SriovHelpers.php
📚 Learning: 2025-12-28T15:54:58.673Z
Learnt from: mgutt
Repo: unraid/webgui PR: 2496
File: emhttp/plugins/dynamix/Browse.page:901-906
Timestamp: 2025-12-28T15:54:58.673Z
Learning: In the unraid/webgui codebase, CSRF validation is centralized in the global auto_prepend_file (local_prepend.php) which runs before every PHP request. Do not add per-script CSRF checks in individual files like Browse.page or Control.php. If a script relies on global validation, ensure it does not duplicate CSRF logic; otherwise extend the central preface to cover the needed checks.

Applied to files:

  • emhttp/plugins/dynamix/include/SysDevs.php
  • emhttp/plugins/dynamix/include/SriovHelpers.php
🔇 Additional comments (7)
emhttp/plugins/dynamix/include/SriovHelpers.php (3)

16-16: LGTM - Extended allowed PCI class list.

The addition of '0x03' (display controllers) to $allowedPCIClass enables SR-IOV support for GPUs, which aligns with the PR objective. Based on learnings, this variable is consumed in SysDevs.php.


84-94: LGTM - VF class information properly exposed.

The VF class and class_id are now correctly retrieved and added to each VF entry, enabling class-specific handling downstream. The $vfname variable is unused but this is acceptable as only the class information is needed for VFs.


316-330: Regex pattern is correct for the actual data format.

The regex at line 316 correctly expects 0x[[:xdigit:]]{2} because the full 4-digit class_id returned by getPciClassNameAndId() (e.g., 0x0200) is intentionally truncated at SysDevs.php line 463 using substr($vrf['class_id'],0,4), reducing it to the 2-digit format (e.g., 0x02). This truncated value is passed to the POST handler and stored in the config file, matching the regex pattern. The example at line 15 of update.sriov-cfg.php confirms the actual stored format uses 2-digit class_id values like 0x02 and 0x02.

emhttp/plugins/dynamix/include/SysDevs.php (4)

114-136: LGTM - SR-IOV group flagging logic.

The logic correctly identifies IOMMU groups containing SR-IOV devices where the first device is not SR-IOV-capable. This enables appropriate warnings about ACS override requirements. The is_string($pdev) check properly skips metadata keys.


236-253: LGTM - Adjusted group iteration for SR-IOV handling.

The changes correctly handle the mixed IOMMU groups by:

  1. Using the second device for filter checks when the first isn't SR-IOV
  2. Properly iterating the new nested data structure
  3. Skipping VFs in flagged groups to avoid duplicate rendering

463-508: LGTM - Class-specific VF UI implementation.

The class-based switch statement properly differentiates between network controllers (0x02) with MAC address handling and display controllers (0x03). The use of htmlspecialchars() and htmlentities() for user-facing values provides appropriate XSS protection.


391-391: No concerns with this line.

@SimonFair SimonFair marked this pull request as ready for review January 12, 2026 11:16
@SimonFair SimonFair added the 7.3 label Jan 12, 2026
@SimonFair SimonFair marked this pull request as draft January 12, 2026 16:04
Stop VMs starting if Root devices defined and VFs exist.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @emhttp/plugins/dynamix.vm.manager/javascript/vmmanager.js:
- Around line 194-196: The code redeclares errtext with var and overwrites
messages when both pcierror and srioverror are true; fix by declaring errtext
once (use let or const) before the conditionals and then set it via
mutually-exclusive logic or by combining messages: e.g., if both pcierror and
srioverror are true build a single string like "Start disabled due to PCI
Changes and SR-IOV GPU Changes", otherwise set the single message; update the
branch that pushes to opts (opts.push({...})) to use the single errtext
variable.

In @emhttp/plugins/dynamix/include/DashboardApps.php:
- Line 178: The addVMContext JavaScript call is missing the two error-flag
arguments ($pcierror and $srioverror) and currently only passes 11 parameters
instead of the required 13; update the other addVMContext invocation to include
the two error flags as the final arguments (matching the existing call that
passes ..., $pcierror, $srioverror) so the JS function receives all parameters
and PCI / SR-IOV error state is propagated to the VM usage menu.
🧹 Nitpick comments (5)
emhttp/plugins/dynamix.vm.manager/scripts/pcicheck.php (2)

45-46: Simplify redundant ternary operators.

The ternary expressions are redundant since we're already inside the if block where the condition is truthy. The "no" branches are unreachable dead code.

♻️ Suggested simplification
-if ($pcierror) { echo $pcierror == true ? "yes" : "no"; exit; }
-if ($srioverror) { echo $srioverror == true ? "sriov" : "no"; exit; }
+if ($pcierror) { echo "yes"; exit; }
+if ($srioverror) { echo "sriov"; exit; }

27-44: Consider consistent indentation.

The code inside the foreach loops has inconsistent indentation - some lines start at column 0, others are indented. This is a minor style nit.

♻️ Suggested formatting
 foreach ($argv as $arg) {
-if (preg_match('/"host"\s*:\s*"([^"]+)"/', $arg, $matches)) {
-    $pci_addresses[] = $matches[1];
+    if (preg_match('/"host"\s*:\s*"([^"]+)"/', $arg, $matches)) {
+        $pci_addresses[] = $matches[1];
     }
 }
 foreach($pci_addresses as $pciid) {
-if (isset($pci_device_changes[$pciid])) {
-    $pcierror = true;
+    if (isset($pci_device_changes[$pciid])) {
+        $pcierror = true;
     }
     // Check if device is an SR-IOV PF with VFs defined
     $check_id = $pciid;
     if (!preg_match('/^[0-9a-fA-F]{4}:/', $check_id)) {
         $check_id = "0000:" . $check_id;
     }
     if (isset($sriov[$check_id]) && !empty($sriov[$check_id]['vfs'])) {
         $srioverror = true;
     }
 }
emhttp/plugins/dynamix/include/SysDevs.php (2)

116-136: Logic for filtering metadata key may be incorrect.

Line 122 uses !is_string($pdev) to skip non-device keys, but _has_sriov is a string key. While this currently works because _has_sriov is only set after the loop completes for each group, the check is misleading and fragile.

Consider using a more explicit check:

♻️ Suggested improvement
       foreach ($devices as $pdev => $pdetail) {
-        if (!is_string($pdev)) continue;
+        if (!is_string($pdev) || str_starts_with($pdev, '_')) continue;

317-323: Inline HTML in translation string may cause i18n issues.

The <a> tag is embedded within the translated string on line 321. This can cause problems for translators and may break if the translation system doesn't handle HTML properly.

♻️ Suggested improvement
-          echo '<span class="orange-text">'._('Warning').': '._('IOMMU group contains SR-IOV devices. Enable ACS Override in <a href="/Main/Flash#boot-parameters">Boot Parameters</a> for proper isolation').'.</span>';
+          echo '<span class="orange-text">'._('Warning').': '._('IOMMU group contains SR-IOV devices. Enable ACS Override in').' <a href="/Main/Flash#boot-parameters">'._('Boot Parameters').'</a> '._('for proper isolation').'.</span>';
emhttp/plugins/dynamix.vm.manager/include/VMMachines.php (1)

60-70: SR-IOV error detection logic is correct.

The implementation properly normalizes PCI IDs and checks for VF presence. Note that the PCI ID normalization pattern (lines 64-67) is duplicated from libvirt_helpers.php (lines 924-926).

Consider extracting the PCI ID normalization to a shared helper function to reduce duplication:

function normalizePciId($pciId) {
    if (!preg_match('/^[0-9a-fA-F]{4}:/', $pciId)) {
        return "0000:" . $pciId;
    }
    return $pciId;
}
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 814f59f and 1cb5c46.

📒 Files selected for processing (7)
  • emhttp/plugins/dynamix.vm.manager/include/VMMachines.php
  • emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php
  • emhttp/plugins/dynamix.vm.manager/javascript/vmmanager.js
  • emhttp/plugins/dynamix.vm.manager/scripts/pcicheck.php
  • emhttp/plugins/dynamix/include/DashboardApps.php
  • emhttp/plugins/dynamix/include/SysDevs.php
  • sbin/qemu
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-11-14T15:18:55.567Z
Learnt from: SimonFair
Repo: unraid/webgui PR: 2443
File: emhttp/plugins/dynamix/include/SriovHelpers.php:16-16
Timestamp: 2025-11-14T15:18:55.567Z
Learning: In the file emhttp/plugins/dynamix/include/SriovHelpers.php, the global variable $allowedPCIClass is defined and is used in emhttp/plugins/dynamix/include/SysDevs.php which includes SriovHelpers.php. This variable should not be flagged as unused.

Applied to files:

  • emhttp/plugins/dynamix.vm.manager/include/VMMachines.php
  • emhttp/plugins/dynamix.vm.manager/scripts/pcicheck.php
  • emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php
  • emhttp/plugins/dynamix/include/SysDevs.php
  • emhttp/plugins/dynamix/include/DashboardApps.php
📚 Learning: 2025-10-04T05:22:33.141Z
Learnt from: Squidly271
Repo: unraid/webgui PR: 2421
File: emhttp/plugins/dynamix/include/DefaultPageLayout/MainContentTabless.php:23-0
Timestamp: 2025-10-04T05:22:33.141Z
Learning: In the Unraid webgui repository, `emhttp/webGui` is a symlink that points to `plugins/dynamix`. Therefore, paths using `$docroot/webGui/...` correctly resolve to `$docroot/plugins/dynamix/...` at runtime.

Applied to files:

  • emhttp/plugins/dynamix.vm.manager/include/VMMachines.php
  • emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php
📚 Learning: 2025-12-28T15:54:58.673Z
Learnt from: mgutt
Repo: unraid/webgui PR: 2496
File: emhttp/plugins/dynamix/Browse.page:901-906
Timestamp: 2025-12-28T15:54:58.673Z
Learning: In the unraid/webgui codebase, CSRF validation is centralized in the global auto_prepend_file (local_prepend.php) which runs before every PHP request. Do not add per-script CSRF checks in individual files like Browse.page or Control.php. If a script relies on global validation, ensure it does not duplicate CSRF logic; otherwise extend the central preface to cover the needed checks.

Applied to files:

  • emhttp/plugins/dynamix.vm.manager/include/VMMachines.php
  • emhttp/plugins/dynamix.vm.manager/scripts/pcicheck.php
  • emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php
  • emhttp/plugins/dynamix/include/SysDevs.php
  • emhttp/plugins/dynamix/include/DashboardApps.php
🧬 Code graph analysis (4)
emhttp/plugins/dynamix.vm.manager/include/VMMachines.php (1)
emhttp/plugins/dynamix/include/SriovHelpers.php (1)
  • getSriovInfoJson (54-142)
emhttp/plugins/dynamix.vm.manager/scripts/pcicheck.php (2)
emhttp/plugins/dynamix/include/Helpers.php (1)
  • comparePCIData (605-651)
emhttp/plugins/dynamix/include/SriovHelpers.php (1)
  • getSriovInfoJson (54-142)
emhttp/plugins/dynamix/include/SysDevs.php (1)
emhttp/plugins/dynamix/include/SmartInfo.php (1)
  • append (44-46)
emhttp/plugins/dynamix/include/DashboardApps.php (1)
emhttp/plugins/dynamix/include/SriovHelpers.php (1)
  • getSriovInfoJson (54-142)
🪛 Biome (2.1.2)
emhttp/plugins/dynamix.vm.manager/javascript/vmmanager.js

[error] 195-195: Shouldn't redeclare 'errtext'. Consider to delete it or rename it.

'errtext' is defined here:

(lint/suspicious/noRedeclare)

🔇 Additional comments (20)
emhttp/plugins/dynamix.vm.manager/scripts/pcicheck.php (3)

19-19: LGTM!

The include for SriovHelpers.php follows the existing pattern and provides access to getSriovInfoJson().


23-23: LGTM!

The JSON decode correctly passes true for associative array output, and downstream isset() checks safely handle the case where $sriov is null.


36-43: LGTM!

The PCI ID normalization correctly adds the 0000: domain prefix when missing, matching the key format used in getSriovInfoJson() output. The SR-IOV VF check properly validates that the device is a PF with active VFs.

emhttp/plugins/dynamix/include/SysDevs.php (5)

236-242: LGTM!

The fallback logic to use the second entry for filter checking when the first entry is a non-SR-IOV device in an SR-IOV group is correctly implemented. The check for _has_sriov key ensures metadata isn't used for filtering.


249-253: LGTM!

The iteration correctly handles the new data structure by checking !is_array($pcidetail) to filter metadata keys, and properly accesses the line via $pcidetail['line'].


463-504: LGTM!

The class_id-based handling correctly restricts MAC address UI to network controllers (0x02) and shows class information for display controllers (0x03). The HTML escaping with htmlspecialchars and htmlentities properly prevents XSS vulnerabilities.


223-226: LGTM!

The removed entries correctly use the new ['line' => $line] structure, maintaining consistency with the data structure established at line 111.


389-391: LGTM!

The SR-IOV Available VFs display is correctly implemented.

sbin/qemu (1)

16-20: LGTM - SR-IOV root device check is correctly implemented.

The new conditional block follows the same pattern as the existing PCI change detection at lines 11-15, providing consistent error handling and exit behavior for SR-IOV root devices.

emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php (2)

173-173: LGTM - Dependency inclusion is correct.

The path resolves correctly at runtime since $docroot/webGui is a symlink to plugins/dynamix. Based on learnings, this is the expected pattern for the Unraid webgui repository.


918-931: SR-IOV physical function filtering looks correct.

The implementation properly:

  1. Retrieves SR-IOV info and decodes it as an associative array
  2. Normalizes PCI IDs to include the 0000: domain prefix for consistent lookup
  3. Removes GPU devices that are SR-IOV physical functions with VFs defined

One minor note: the regex pattern /^[0-9a-fA-F]{4}:/ checks for the domain prefix correctly.

emhttp/plugins/dynamix.vm.manager/include/VMMachines.php (3)

44-44: LGTM - Efficient SR-IOV data retrieval.

Good design choice to fetch SR-IOV info once before the VM loop rather than inside it, avoiding redundant system calls.


220-220: LGTM - SR-IOV warning icon is consistent with PCI warning.

The warning icon and tooltip follow the same pattern as the existing PCI warning on line 219, providing consistent user feedback.


138-138: addVMContext function signature is properly updated.

The JavaScript function in vmmanager.js correctly accepts both pcierror and srioverror as the final parameters, matching the 13 arguments passed from the PHP sprintf call.

emhttp/plugins/dynamix.vm.manager/javascript/vmmanager.js (2)

86-86: LGTM - Function signature correctly extended.

The srioverror=false parameter is properly added with a default value, maintaining backward compatibility.


175-175: LGTM - Guard condition correctly updated.

The condition !pcierror && !srioverror properly prevents VM start when either error flag is set.

emhttp/plugins/dynamix/include/DashboardApps.php (4)

22-22: LGTM!

The include for SriovHelpers.php is correctly added and necessary for the getSriovInfoJson() function used later in this file.


120-120: LGTM!

Fetching SR-IOV info once before the loop is efficient. The downstream isset() check at line 174 handles potential null from json_decode gracefully.


164-176: LGTM!

The SR-IOV PF detection logic correctly normalizes PCI addresses and checks for VFs. The isset() combined with !empty() ensures safe array access.

Minor observation: Line 166 unconditionally prepends "0000:" while lines 171-173 check first. The defensive check here is the better approach.


201-202: LGTM!

The SR-IOV warning icon follows the same pattern as the existing PCI error icon, with appropriate styling and translated tooltip text.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
emhttp/plugins/dynamix.vm.manager/javascript/vmmanager.js (1)

86-86: Consider refactoring to an options object in a future PR.

The function now has 13 positional parameters, which can make call sites harder to read and maintain. The current change is backward-compatible and follows the existing pattern, so it's acceptable for this PR.

For a future improvement, consider consolidating the trailing boolean/optional parameters into a single options object:

// Example future signature
function addVMContext(name, uuid, template, state, vmrcurl, vmrcprotocol, log, options = {}) {
  const { fstype = "QEMU", consolein = "web;no", usage = false, webui = "", pcierror = false, srioverror = false } = options;
  // ...
}
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1cb5c46 and 29daee5.

📒 Files selected for processing (1)
  • emhttp/plugins/dynamix.vm.manager/javascript/vmmanager.js
🔇 Additional comments (2)
emhttp/plugins/dynamix.vm.manager/javascript/vmmanager.js (2)

175-179: LGTM!

The guard condition correctly prevents VM start when either pcierror or srioverror is true, ensuring users cannot start a VM with misconfigured PCI or SR-IOV GPU settings.


193-205: LGTM!

The error message handling is well-structured, covering all three cases (both errors, PCI only, SR-IOV only) with clear, internationalized messages. The explicit else if (srioverror) on line 199 improves readability even though a plain else would suffice logically.

@SimonFair SimonFair marked this pull request as ready for review January 12, 2026 17:24
@limetech limetech merged commit fa37cf3 into unraid:master Jan 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants