mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-09-14 18:56:52 +00:00
gpu: nvidia install drops VFIO autoload; GPU flows self-repair stale vfio.conf
The nvidia driver installer now writes only `nvidia` and `nvidia_uvm` into `/etc/modules-load.d/nvidia-vfio.conf`, leaving the vfio-pci modules for `switch_gpu_mode.sh` to add and remove when the user explicitly transitions between LXC and VM mode. A host with residual `/etc/modprobe.d/vfio.conf` entries from an earlier VM passthrough setup no longer has vfio-pci racing nvidia at boot and capturing the GPU by ID. All three GPU-facing entry points also detect a stale `vfio.conf` entry whose vid:did belongs to a GPU currently bound to a non-vfio driver, and offer to clean it in place. `nvidia_installer.sh` runs the check as a pre-flight before install. `switch_gpu_mode.sh` presents an interactive dialog and rebuilds initramfs. `switch_gpu_mode_direct.sh` performs the same cleanup transparently for the Monitor web variant. Once cleaned, "Add GPU to LXC", the driver install and Switch Mode all proceed without any manual intervention. The two supporting helpers `_pci_driver_of` and `_clean_vfio_conf_ids` previously local to `add_gpu_lxc.sh` move to `scripts/global/pci_passthrough_helpers.sh`, so every GPU-related script resolves them from a single source without duplication.
This commit is contained in:
@@ -1257,6 +1257,39 @@ parse_arguments() {
|
||||
# ==========================================================
|
||||
# Main Entry Point
|
||||
# ==========================================================
|
||||
check_stale_vfio_config_switch_mode_direct() {
|
||||
local vfio_conf="/etc/modprobe.d/vfio.conf"
|
||||
[[ ! -f "$vfio_conf" ]] && return 0
|
||||
|
||||
local ids_line ids_part
|
||||
ids_line=$(grep "^options vfio-pci ids=" "$vfio_conf" 2>/dev/null | head -1)
|
||||
[[ -z "$ids_line" ]] && return 0
|
||||
ids_part=$(echo "$ids_line" | grep -oE 'ids=[^[:space:]]+' | sed 's/ids=//')
|
||||
[[ -z "$ids_part" ]] && return 0
|
||||
|
||||
local -a legacy_ids=()
|
||||
local idx viddid drv
|
||||
for idx in "${SELECTED_GPU_IDX[@]}"; do
|
||||
viddid="${ALL_GPU_VIDDID[$idx]}"
|
||||
drv="${ALL_GPU_DRIVERS[$idx]}"
|
||||
[[ -z "$viddid" ]] && continue
|
||||
[[ "$drv" == "vfio-pci" ]] && continue
|
||||
if echo ",${ids_part}," | grep -q ",${viddid},"; then
|
||||
legacy_ids+=("$viddid")
|
||||
fi
|
||||
done
|
||||
|
||||
[[ ${#legacy_ids[@]} -eq 0 ]] && return 0
|
||||
|
||||
msg_info "$(translate 'Removing stale VFIO entries from vfio.conf...')"
|
||||
if declare -F _clean_vfio_conf_ids >/dev/null 2>&1 \
|
||||
&& _clean_vfio_conf_ids "${legacy_ids[@]}"; then
|
||||
update-initramfs -u >/dev/null 2>&1 || true
|
||||
HOST_CONFIG_CHANGED=true
|
||||
msg_ok "$(translate 'Stale VFIO entries removed and initramfs rebuilt.')" | tee -a "$screen_capture"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
: >"$LOG_FILE"
|
||||
: >"$screen_capture"
|
||||
@@ -1323,6 +1356,10 @@ main() {
|
||||
local gpu_name="${ALL_GPU_NAMES[$gpu_idx]}"
|
||||
local gpu_pci="${ALL_GPU_PCIS[$gpu_idx]}"
|
||||
|
||||
if [[ "$TARGET_MODE" == "lxc" ]]; then
|
||||
check_stale_vfio_config_switch_mode_direct
|
||||
fi
|
||||
|
||||
# Execute the switch
|
||||
if [[ "$TARGET_MODE" == "vm" ]]; then
|
||||
switch_to_vm_mode
|
||||
|
||||
Reference in New Issue
Block a user