mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-04-25 08:56:21 +00:00
Update gpu_hook_guard_helpers.sh
This commit is contained in:
@@ -133,16 +133,20 @@ if [[ -f "$vm_conf" ]]; then
|
|||||||
|
|
||||||
# Slot-only syntax (e.g. 01:00) is accepted by Proxmox.
|
# Slot-only syntax (e.g. 01:00) is accepted by Proxmox.
|
||||||
if [[ "$id" =~ ^[0-9a-fA-F]{2}:[0-9a-fA-F]{2}$ ]]; then
|
if [[ "$id" =~ ^[0-9a-fA-F]{2}:[0-9a-fA-F]{2}$ ]]; then
|
||||||
slot_ok=false
|
slot_has_gpu=false
|
||||||
for dev in /sys/bus/pci/devices/0000:${id}.*; do
|
for dev in /sys/bus/pci/devices/0000:${id}.*; do
|
||||||
[[ -e "$dev" ]] || continue
|
[[ -e "$dev" ]] || continue
|
||||||
|
class_hex="$(cat "$dev/class" 2>/dev/null | sed 's/^0x//')"
|
||||||
|
[[ "${class_hex:0:2}" != "03" ]] && continue
|
||||||
|
slot_has_gpu=true
|
||||||
drv="$(basename "$(readlink "$dev/driver" 2>/dev/null)" 2>/dev/null)"
|
drv="$(basename "$(readlink "$dev/driver" 2>/dev/null)" 2>/dev/null)"
|
||||||
[[ "$drv" == "vfio-pci" ]] && slot_ok=true && break
|
if [[ "$drv" != "vfio-pci" ]]; then
|
||||||
|
failed=1
|
||||||
|
details+=$'\n'"- ${dev##*/}: driver=${drv:-none}"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
if [[ "$slot_ok" != "true" ]]; then
|
# If this slot does not include a display/3D controller, it is not GPU-guarded.
|
||||||
failed=1
|
[[ "$slot_has_gpu" == "true" ]] || true
|
||||||
details+=$'\n'"- ${id}: not bound to vfio-pci"
|
|
||||||
fi
|
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -153,6 +157,9 @@ if [[ -f "$vm_conf" ]]; then
|
|||||||
details+=$'\n'"- ${id}: PCI device not found"
|
details+=$'\n'"- ${id}: PCI device not found"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
class_hex="$(cat "$dev_path/class" 2>/dev/null | sed 's/^0x//')"
|
||||||
|
# Enforce vfio only for display/3D devices (PCI class 03xx).
|
||||||
|
[[ "${class_hex:0:2}" == "03" ]] || continue
|
||||||
drv="$(basename "$(readlink "$dev_path/driver" 2>/dev/null)" 2>/dev/null)"
|
drv="$(basename "$(readlink "$dev_path/driver" 2>/dev/null)" 2>/dev/null)"
|
||||||
if [[ "$drv" != "vfio-pci" ]]; then
|
if [[ "$drv" != "vfio-pci" ]]; then
|
||||||
failed=1
|
failed=1
|
||||||
|
|||||||
Reference in New Issue
Block a user