Improve PCI pass-through error handling

This commit is contained in:
Albrecht Lohofener
2025-01-10 21:42:08 +01:00
parent 2bb5a119fb
commit 812fa9e4c1
2 changed files with 5 additions and 8 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ services:
# PCI and PCIe pass-through
# Host system requirements
# - IOMMU CPU feature has to enabled in bios
# - IOMMU CPU virtualization feature (e.g. Intel VT-d) has to enabled in bios
# - Host kernel has to switch on intel_iommu=on or amd_iommu=on
# - Host kernel module 'vfio-pci' has to exists
# - Ubuntu 24.04 is working by default
+4 -7
View File
@@ -143,7 +143,7 @@ attach_pci_device () {
info "Preparing PCI pass-through for device $PCI_DEVICE ..."
if [ ! -e "$PCI_PATH" ]; then
echo "Error: PCI device $PCI_DEVICE not found"
error "Error: PCI device $PCI_DEVICE not found"
exit 1
fi
@@ -162,12 +162,9 @@ attach_pci_device () {
# Bind to vfio-pci
echo "vfio-pci" > "$PCI_PATH/driver_override"
echo "$PCI_DEVICE" > /sys/bus/pci/drivers/vfio-pci/bind
# Verify binding
if [ "$(basename "$(readlink "$PCI_PATH/driver" 2>/dev/null)")" != "vfio-pci" ]; then
echo "Failed to bind $PCI_DEVICE to vfio-pci"
exit 1
if ! echo "$PCI_DEVICE" > /sys/bus/pci/drivers/vfio-pci/bind 2>/dev/null; then
error "Failed to bind PCI device $PCI_DEVICE to vfio-pci. Please double check if your system supports IOMMU and if CPU virtualization features (e.g. Intel VT-d) is enabled in your bios."
exit 1
fi
echo "Successfully bound $PCI_DEVICE to vfio-pci"