webgui icon indicating copy to clipboard operation
webgui copied to clipboard

Enhanced Syslinux Configuration Interface -

Open SpaceinvaderOne opened this issue 10 months ago • 1 comments

This PR replaces the existing Syslinux configuration page (/Main/Flash) with a comprehensive boot parameter management interface that makes kernel boot parameter configuration accessible to all users while maintaining safety and robustness.

Currently, users must manually edit /boot/syslinux/syslinux.cfg to configure kernel boot parameters (e.g., GPU passthrough, PCIe ACS override, power management settings). This requires:

  • Direct text file editing with risk of syntax errors
  • Knowledge of syslinux syntax and kernel parameter names
  • No validation or error recovery if config becomes unbootable
  • No guidance on which parameters apply to which scenarios

This enhancement provides a guided UI for the most common boot parameters while preserving advanced users' ability to directly edit the raw configuration.

Key Features

1. Dual View Modes

Menu View (Guided Interface)

  • Toggle switches and dropdowns for 16 common boot parameters
  • Per-boot-entry toggles (Unraid OS, GUI Mode, Safe Mode, GUI Safe Mode)
  • Live parameter preview showing before/after diff
  • Collapsible help sections for each parameter
  • Custom parameter support with comment system

Raw View (Direct Config Editor)

  • Direct editing of syslinux.cfg content
  • Syntax highlighting via CSS
  • Preserves all formatting and comments
  • For advanced users and edge cases

2. GUI-Configurable Parameters

VM Passthrough & GPU:

  • PCIe ACS Override (dropdown: Disabled, Downstream, Multi-function, Both)
  • VFIO Unsafe Interrupts
  • Framebuffer controls (EFI, VESA, Simple, Sysfb blacklist)

Hardware Compatibility:

  • ACPI Sensor Access (for motherboard sensor drivers)
  • GHES Disable (suppress firmware error spam)
  • PCIe Error Reporting Disable
  • PCI Resource Reallocation

Power Management:

  • USB Autosuspend Disable
  • NVMe Deep Power States Disable
  • PCIe ASPM Disable
  • PCIe Port PM Disable

Boot Configuration:

  • Timeout (1-10 seconds, with custom value preservation)
  • Default boot entry selector (radio buttons)

3. Safety Features

Safe Mode Protection

  • Safe Mode entries can be modified, but require explicit confirmation modal
  • GUI Safe Mode automatically excludes framebuffer parameters to ensure display works

Automatic Backups

  • Timestamped backups created before every change: syslinux.cfg.bak.YYYY-MMM-DD_HH-MM-SS
  • Keep last 10 backups, auto-cleanup older ones
  • One-click restore interface with backup browser
  • Automatic restore if validation fails after write

FAT32-Safe Atomic Writes

  • Temp files created on same filesystem as target (mktemp -p "$(dirname "$SYSLINUX_CFG")")
  • Near-atomic mv operation minimizes corruption risk during power loss
  • Write-validate-move pattern ensures config is valid before replacing production file

Boot Mode Auto-Detection

  • Detects UEFI vs Legacy boot by checking /sys/firmware/efi
  • Auto-enables appropriate framebuffer toggles based on boot mode
  • Shows advisory if user enables wrong framebuffer for current boot mode

GUI Mode Framebuffer Auto-Exclusion

  • When applying to GUI Mode entries, automatically strips all framebuffer parameters
  • Prevents breaking GUI console display when user has GPU passthrough enabled

4. Smart Automation

Existing Config Import

  • Parses current syslinux.cfg on page load
  • Automatically enables toggles/dropdowns for recognized parameters
  • Extracts unmanaged parameters to "Custom Parameters" list
  • Preserves custom timeout values (e.g., 2.5 seconds) instead of rounding

PCI Parameter Merging

  • Parses both formats: pci=noaer pci=realloc and pci=noaer,realloc
  • Automatically consolidates to single comma-separated parameter
  • Deduplicates options while preserving case and order
  • Preserves unrecognized PCI options in custom parameters

Managed Parameter Conflict Detection

  • Detects when custom parameter matches existing toggle/dropdown
  • Shows alert and auto-enables UI control instead of allowing duplicate
  • Prevents conflicts between custom params and managed parameters

Legacy Parameter Detection

  • Detects isolcpus= and shows info banner with link to /Settings/CPUset GUI
  • Detects deprecated vfio-pci.ids= and pci-stub.ids= with migration warnings
  • Provides clickable links to System Devices (/Tools/SysDevs) for proper VFIO binding

5. User Experience

Live Parameter Preview

  • Git-style diff display showing before/after append line changes
  • Updates in real-time as user toggles options
  • Per-entry preview (shows what each boot entry will have)

Smart Button States

  • Apply/Save buttons disabled on page load
  • Only enable when actual changes are made
  • Race condition prevention during initialization

Done/Reset Toggle

  • "Done" button visible by default (returns to Main page)
  • Transforms to "Reset" button when changes made
  • Menu View: Reset reloads page; Raw View: Reset restores textarea

Persistent Reboot Notifications

  • Uses Unraid's global addRebootNotice() API
  • Orange banner persists across all Unraid pages until reboot
  • Survives page reloads and browser restarts
  • Auto-clears on reboot (stored in tmpfs)

Hardware Change Detection

  • Tracks CPU, motherboard, BIOS via dmidecode
  • Shows warning banner if hardware changes detected
  • Prompts user to review parameters after hardware upgrade

6. Validation & Error Prevention

Parameter Syntax Validation

  • Blocks reserved syslinux directives (append, initrd, label, etc.)
  • Prevents space-separated parameters (enforces one param per entry)
  • Detects forum paste mistakes (e.g., copying full append initrd=/bzroot line)
  • SweetAlert modals with clear error messages

Configuration Structure Validation

  • Ensures required labels exist (Unraid OS, GUI Mode, Safe Mode)
  • Validates initrd=/bzroot presence
  • Timeout digit-only validation (prevents injection)
  • Backup filename sanitization with strict regex

Error Recovery

  • Automatic backup restore if validation fails
  • Detailed error messages in SweetAlert modals
  • No silent data loss (preserves custom values)

7. Technical Implementation

Three-Layer Architecture

Frontend (Syslinux.page)
    ↓ AJAX POST with CSRF token
PHP Handler (boot_params_handler.php)
    ↓ Environment variables
Shell Script (manage_boot_params.sh)
    ↓ File operations
syslinux.cfg (Bootloader Config)

Security

  • CSRF protection via Unraid's Wrappers.php (enforced on all POST requests)
  • Input sanitization and validation (PHP + Bash defense in depth)
  • Backup filename validation prevents directory traversal
  • Environment variable pattern prevents command injection

Theme Compatibility

  • CSS variables with fallbacks: color: var(--text-color, #e0e0e0)
  • Works with Unraid 7.1 (no CSS variables) and 7.2 (with CSS variables)
  • Light/Dark theme support (Azure, Gray, Black)
  • Responsive design using Unraid's native <dl>/<dt>/<dd> structure

Data Persistence

  • Custom parameter comments stored in /boot/config/custom_params_comments.json
  • Hardware tracking data preserved across comment writes
  • Pure Bash JSON manipulation (no jq dependency)

Changes to Existing Files

1. dynamix/Syslinux.page (REPLACED)

  • Complete rewrite of existing basic syslinux config editor
  • Maintains same Menu/Title/Tag structure (Menu="Flash", Title="Boot Parameters")
  • Backward compatible with all Unraid versions (7.0+)

2. dynamix.vm.manager/VMSettings.page (MODIFIED)

  • Added deprecation notice before PCIe ACS Override control (line 264)
  • Info box directs users to new Boot Parameters page with anchor link
  • Text: "PCIe ACS Override, VFIO interrupts & GPU framebuffer settings are managed in Boot Parameters"
  • Link: /Main/Flash#boot-parameters (scrolls directly to VM Passthrough section)
  • Existing controls remain functional for backward compatibility

New Files

1. dynamix/include/boot_params_handler.php

  • PHP AJAX handler routing operations to shell script
  • Operations: read_config, write_config, write_raw_config, list_backups, restore_backup, delete_all_backups, reset_default, detect_boot_mode, check_hardware, acknowledge_hardware_change
  • CSRF enforcement via Wrappers.php
  • JSON response format

2. dynamix/scripts/manage_boot_params.sh

  • Core shell logic for parsing and writing syslinux.cfg
  • Functions: parse_append_line(), build_append_line(), read_config(), write_config(), validate_config(), create_backup(), list_backups(), restore_backup()
  • PCI parameter merging with deduplication
  • Backup management (keep last 10)
  • FAT32-safe atomic writes

Summary by CodeRabbit

  • New Features

    • Boot Parameter Settings informational block added to VM Settings page with link to centralized Boot Parameters management.
  • Refactor

    • Removed PCIe ACS override and VFIO interrupt settings from VM Settings form.
    • Consolidated boot parameter configuration handling across dedicated management interface.
    • Enhanced backend infrastructure for boot parameter operations including configuration management and hardware tracking.

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

SpaceinvaderOne avatar Jan 07 '26 18:01 SpaceinvaderOne

Walkthrough

Replaces PCIe ACS override and VFIO unsafe interrupts UI controls with a Boot Parameters informational banner, and adds a new boot parameter management backend: a PHP POST API handler plus a comprehensive Bash script to read/write syslinux.cfg, manage backups, and track hardware.

Changes

Cohort / File(s) Summary
VM Settings UI
emhttp/plugins/dynamix.vm.manager/VMSettings.page
Removed PCIe ACS override and VFIO unsafe interrupts selects and their help blocks; added a Boot Parameters informational/banner linking to the Boot Parameters page; adjusted submit logic to post only action:'cmdlineoverride' without specific pcie/vfio values.
Boot Parameters API Handler
emhttp/plugins/dynamix/include/boot_params_handler.php
New PHP POST controller exposing operations (read_config, write_config, list_backups, restore_backup, delete_all_backups, reset_default, write_raw_config, detect_boot_mode, check_hardware, acknowledge_hardware_change). Implements CSRF handling, input validation/sanitization, JSON responses, and invokes the Bash backend.
Boot Parameters Bash Backend
emhttp/plugins/dynamix/scripts/manage_boot_params.sh
New, feature-complete Bash script implementing OPERATION dispatch: read_config, write_config, write_raw_config, list_backups, restore_backup, delete_all_backups, check_hardware, update_hardware; supports parsing/constructing append lines, PCI option merging/deduplication, backups/rotation, atomic writes, validation, hardware tracking (dmidecode), and JSON metadata handling.

Sequence Diagram(s)

sequenceDiagram
    participant UI as Client UI
    participant PHP as boot_params_handler.php
    participant SH as manage_boot_params.sh
    participant FS as Filesystem
    participant HW as dmidecode

    rect rgb(200,220,240)
    Note over UI,PHP: Read configuration
    UI->>PHP: POST operation=read_config
    PHP->>SH: Execute OPERATION=read_config
    SH->>FS: Read syslinux.cfg + metadata
    SH-->>PHP: JSON payload (config + full_config)
    PHP-->>UI: JSON response
    end

    rect rgb(220,240,200)
    Note over UI,PHP: Write configuration
    UI->>PHP: POST operation=write_config + params
    PHP->>SH: Execute OPERATION=write_config with env
    SH->>FS: Backup, validate, construct append, atomic write
    SH-->>PHP: Success / CONFIG block
    PHP-->>UI: JSON result
    end

    rect rgb(240,220,200)
    Note over UI,PHP: Hardware detection / tracking
    UI->>PHP: POST operation=check_hardware or detect_boot_mode
    PHP->>SH: Execute corresponding OPERATION
    SH->>HW: Query dmidecode
    SH->>FS: Read/compare/update hardware_tracking
    SH-->>PHP: JSON detection/tracking
    PHP-->>UI: JSON response
    end

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐰 I hopped through boot lines, tidy and bright,

swapped selects for a banner, left and right.
Scripts guard the configs, backups in rows,
dmidecode hums where the hardware note grows.
A little hop, and the system boots light.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: introducing an enhanced boot configuration interface with guided parameter management and a raw editor, which directly corresponds to the PR's core objective of replacing the Syslinux configuration page with a new Boot Parameters interface.
Docstring Coverage ✅ Passed Docstring coverage is 96.00% which is sufficient. The required threshold is 80.00%.

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


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.

coderabbitai[bot] avatar Jan 07 '26 18:01 coderabbitai[bot]

🔧 PR Test Plugin Available

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

Version: 2026.01.08.1538 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-2507/webgui-pr-2507.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/VMSettings.page
emhttp/plugins/dynamix/Syslinux.page
emhttp/plugins/dynamix/include/boot_params_handler.php
emhttp/plugins/dynamix/scripts/manage_boot_params.sh

🔄 To Remove:

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

plugin remove webgui-pr-2507

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

github-actions[bot] avatar Jan 08 '26 15:01 github-actions[bot]

Do the error messages from the php get displayed in the JS? if so, need to put them also in translations ideally. But not a immediate issue

Squidly271 avatar Jan 09 '26 18:01 Squidly271