diff --git a/scripts/gpu_tpu/add_gpu_vm.sh b/scripts/gpu_tpu/add_gpu_vm.sh index 18cc074b..2a27ede4 100644 --- a/scripts/gpu_tpu/add_gpu_vm.sh +++ b/scripts/gpu_tpu/add_gpu_vm.sh @@ -1811,6 +1811,30 @@ sanitize_nvidia_host_stack_for_vfio() { else msg_ok "$(translate 'NVIDIA host services already aligned for VFIO mode')" | tee -a "$screen_capture" fi + + # Sync components_status.json — the host driver stays on disk but is + # not in use for this GPU because it now belongs to a VM. Per-BDF + # model: on multi-GPU hosts where another NVIDIA card still uses the + # nvidia driver, keep the status as "installed" — the driver is + # genuinely in use elsewhere. Only flip to "vfio_passthrough" when no + # NVIDIA GPU is bound to the host driver anymore. + if declare -F update_component_status >/dev/null 2>&1; then + local _nvd_ver _nvd_new_status + _nvd_ver=$(jq -r '.nvidia_driver.version // ""' \ + /usr/local/share/proxmenux/components_status.json 2>/dev/null) + _nvd_new_status="vfio_passthrough" + # Any NVIDIA PCI device still using the nvidia driver on the host? + if lspci -nnk 2>/dev/null | awk ' + /NVIDIA/{gpu=1; next} + gpu && /Kernel driver in use: nvidia$/ {found=1; exit} + /^[^\t]/{gpu=0} + END{exit !found} + '; then + _nvd_new_status="installed" + fi + update_component_status "nvidia_driver" "$_nvd_new_status" \ + "${_nvd_ver:-}" "gpu" '{"patched":false}' >>"$LOG_FILE" 2>&1 || true + fi } # Per-BDF VFIO binder + legacy NVIDIA blacklist migration are defined in diff --git a/scripts/gpu_tpu/switch_gpu_mode.sh b/scripts/gpu_tpu/switch_gpu_mode.sh index 9f719fc0..02acb793 100644 --- a/scripts/gpu_tpu/switch_gpu_mode.sh +++ b/scripts/gpu_tpu/switch_gpu_mode.sh @@ -338,6 +338,18 @@ EOF else msg_ok "$(translate 'NVIDIA host services/autoload already aligned for VFIO mode')" | tee -a "$screen_capture" fi + + # Sync components_status.json — the host driver stays on disk but is + # not in use because the GPU now belongs to a VM. Prevents the update + # notification path (and any future logic gated on nvidia_driver.status) + # from acting on a state that no longer matches reality. + if declare -F update_component_status >/dev/null 2>&1; then + local _nvd_ver + _nvd_ver=$(jq -r '.nvidia_driver.version // ""' \ + /usr/local/share/proxmenux/components_status.json 2>/dev/null) + update_component_status "nvidia_driver" "vfio_passthrough" \ + "${_nvd_ver:-}" "gpu" '{"patched":false}' >>"$LOG_FILE" 2>&1 || true + fi } _restore_nvidia_host_stack_for_lxc() { @@ -402,6 +414,21 @@ _restore_nvidia_host_stack_for_lxc() { else msg_ok "$(translate 'NVIDIA host services/autoload already aligned for native mode')" | tee -a "$screen_capture" fi + + # Sync components_status.json back to installed — the host has reclaimed + # the GPU and the nvidia stack is being reloaded. Restores the state to + # what it was before the VFIO switch so the update notification path and + # the auto-reinstall gate see the driver as active on the host again. + if declare -F update_component_status >/dev/null 2>&1; then + local _nvd_ver + _nvd_ver=$(nvidia-smi --query-gpu=driver_version --format=csv,noheader 2>/dev/null | head -1) + if [[ -z "$_nvd_ver" ]]; then + _nvd_ver=$(jq -r '.nvidia_driver.version // ""' \ + /usr/local/share/proxmenux/components_status.json 2>/dev/null) + fi + update_component_status "nvidia_driver" "installed" \ + "${_nvd_ver:-}" "gpu" '{"patched":false}' >>"$LOG_FILE" 2>&1 || true + fi } _add_amd_softdep() { diff --git a/scripts/gpu_tpu/switch_gpu_mode_direct.sh b/scripts/gpu_tpu/switch_gpu_mode_direct.sh index e0ef87f7..cd14b9b7 100644 --- a/scripts/gpu_tpu/switch_gpu_mode_direct.sh +++ b/scripts/gpu_tpu/switch_gpu_mode_direct.sh @@ -316,6 +316,18 @@ EOF else msg_ok "$(translate 'NVIDIA host services/autoload already aligned for VFIO mode')" | tee -a "$screen_capture" fi + + # Sync components_status.json — the host driver stays on disk but is + # not in use because the GPU now belongs to a VM. Prevents the update + # notification path (and any future logic gated on nvidia_driver.status) + # from acting on a state that no longer matches reality. + if declare -F update_component_status >/dev/null 2>&1; then + local _nvd_ver + _nvd_ver=$(jq -r '.nvidia_driver.version // ""' \ + /usr/local/share/proxmenux/components_status.json 2>/dev/null) + update_component_status "nvidia_driver" "vfio_passthrough" \ + "${_nvd_ver:-}" "gpu" '{"patched":false}' >>"$LOG_FILE" 2>&1 || true + fi } _restore_nvidia_host_stack_for_lxc() { @@ -376,6 +388,21 @@ _restore_nvidia_host_stack_for_lxc() { else msg_ok "$(translate 'NVIDIA host services/autoload already aligned for native mode')" | tee -a "$screen_capture" fi + + # Sync components_status.json back to installed — the host has reclaimed + # the GPU and the nvidia stack is being reloaded. Restores the state to + # what it was before the VFIO switch so the update notification path and + # the auto-reinstall gate see the driver as active on the host again. + if declare -F update_component_status >/dev/null 2>&1; then + local _nvd_ver + _nvd_ver=$(nvidia-smi --query-gpu=driver_version --format=csv,noheader 2>/dev/null | head -1) + if [[ -z "$_nvd_ver" ]]; then + _nvd_ver=$(jq -r '.nvidia_driver.version // ""' \ + /usr/local/share/proxmenux/components_status.json 2>/dev/null) + fi + update_component_status "nvidia_driver" "installed" \ + "${_nvd_ver:-}" "gpu" '{"patched":false}' >>"$LOG_FILE" 2>&1 || true + fi } _add_amd_softdep() {