Skip to content

Commit 69b16cd

Browse files
committed
Improve PCI-ID validation in configurator script
* Accept both long (0000:xx:xx.x) and short (xx:xx.x) formats * Auto-prepend domain when missing * Show explicit error if the device is not found, not just bad syntax
1 parent f565cb0 commit 69b16cd

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ jobs:
4444
name: "Release v${{ env.VERSION }}"
4545
update: true
4646
body: |
47+
4748
<!--
4849
PECU-Channel: Stable
4950
PECU-Title: EDIT TITLE HERE
5051
PECU-Desc: EDIT SHORT DESCRIPTION HERE
51-
-->
52+
-->
5253

5354
### What's New in This Update
5455

src/proxmox-configurator.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,11 +401,24 @@ read_gpu_id() {
401401
3>&1 1>&2 2>&3) || return 1
402402

403403
# Validate PCI syntax: domain:bus.device.function
404-
if ! [[ "$GPU_ID" =~ ^[0-9A-Fa-f]{4}:[0-9A-Fa-f]{2}\.[0-9A-Fa-f]$ ]]; then
404+
if ! [[ "$GPU_ID" =~ ^([0-9A-Fa-f]{4}:)?[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}\.[0-9A-Fa-f]$ ]]; then
405405
whiptail --title "Error" --msgbox "Invalid PCI ID format: $GPU_ID" 8 60
406406
return 1
407407
fi
408408

409+
# If the user omitted the domain, prepend the default 0000:
410+
[[ "$GPU_ID" =~ ^[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}\.[0-9A-Fa-f]$ ]] && GPU_ID="0000:$GPU_ID"
411+
412+
# ── Lookup vendor/device; show error only if ID truly does not exist ──
413+
GPU_VENDOR_ID=$(lspci -n -s "$GPU_ID" | awk '{print $3}')
414+
if [[ -z "$GPU_VENDOR_ID" ]]; then
415+
whiptail --title "Error" --msgbox "PCI ID not found: $GPU_ID" 8 60
416+
return 1
417+
fi
418+
419+
whiptail --title "Vendor/Device" \
420+
--msgbox "Vendor/Device ID: $GPU_VENDOR_ID" 8 60
421+
409422
# Lookup vendor/device code; abort if lookup fails.
410423
GPU_VENDOR_ID=$(lspci -n -s "$GPU_ID" | awk '{print $3}') || {
411424
whiptail --title "Error" --msgbox "PCI ID not found: $GPU_ID" 8 60

0 commit comments

Comments
 (0)