mirror of
https://github.com/AlbrechtL/openwrt-docker.git
synced 2026-10-28 00:01:02 +00:00
Add option for second PCI pass-through device
This commit is contained in:
+3
-2
@@ -41,7 +41,7 @@ services:
|
||||
|
||||
# USB pass-through
|
||||
# Format <vendorID>:<productID> like 'lsusb' is given
|
||||
# Currently only two USB devices are supported
|
||||
# Currently, up to two USB devices are supported
|
||||
# If unset -> disabled
|
||||
#USB_1: "0bda:8153"
|
||||
#USB_2: "0e8d:7961"
|
||||
@@ -54,9 +54,10 @@ services:
|
||||
# - Ubuntu 24.04 is working by default
|
||||
# Format <bus:device.function> like 'lspci' is given
|
||||
# optional <domain:bus:device.function> like 'lspci' is given
|
||||
# Currently, up to two PCI devices are supported
|
||||
# If unset -> disabled
|
||||
#PCI_1: "00:1f.6"
|
||||
#PCI_1: "0000:00:1f.6"
|
||||
#PCI_2: "0000:00:1f.6"
|
||||
|
||||
# Define number of VM CPUs
|
||||
# If unset -> 1
|
||||
|
||||
@@ -18,6 +18,17 @@ cleanup() {
|
||||
echo 1 > /sys/bus/pci/rescan
|
||||
fi
|
||||
|
||||
if [ -n "$PCI_2" ]; then
|
||||
if [[ "$PCI_2" =~ ^[0-9]{4}: ]]; then
|
||||
PCI_SLOT="$PCI_2"
|
||||
else
|
||||
PCI_SLOT="0000:$PCI_2"
|
||||
fi
|
||||
echo "Attaching PCI device $PCI_SLOT back to the host"
|
||||
echo 1 > /sys/bus/pci/devices/$PCI_SLOT/remove
|
||||
echo 1 > /sys/bus/pci/rescan
|
||||
fi
|
||||
|
||||
|
||||
echo "Cleanup complete."
|
||||
exit 0
|
||||
@@ -38,4 +49,4 @@ if [[ $DEBUG = "true" ]]; then
|
||||
done & wait
|
||||
fi
|
||||
|
||||
sleep infinity & wait
|
||||
sleep infinity & wait
|
||||
|
||||
@@ -15,6 +15,7 @@ trap 'error "Status $? while: $BASH_COMMAND (line $LINENO/$BASH_LINENO)"' ERR
|
||||
: "${USB_1:=""}" # USB 1 vendor and device ID
|
||||
: "${USB_2:=""}" # USB 2 vendor and device ID
|
||||
: "${PCI_1:=""}" # PCI 1 slot (first number in lspci)
|
||||
: "${PCI_2:=""}" # PCI 2 slot (first number in lspci)
|
||||
: "${FORWARD_LUCI:=""}" # Make LuCI OpenWrt web interface accessible via host LAN
|
||||
: "${LUCI_WEB_BUTTON_JSON:=""}" # Adapt the "OpenWrt LuCI web interface" button to your needs.
|
||||
: "${OPENWRT_AFTER_BOOT_CMD:=""}" # User command or script to run after OpenWrt is booted
|
||||
|
||||
+12
-1
@@ -253,6 +253,7 @@ USB_ARGS="${USB_1_ARGS} ${USB_2_ARGS}"
|
||||
# Attaching PCI devices
|
||||
PCI_ARGS=""
|
||||
PCI_1_ARGS=""
|
||||
PCI_2_ARGS=""
|
||||
if [[ -n "$PCI_1" ]]; then
|
||||
if [[ "$PCI_1" =~ ^[0-9]{4}: ]]; then
|
||||
PCI_SLOT="$PCI_1"
|
||||
@@ -263,7 +264,17 @@ if [[ -n "$PCI_1" ]]; then
|
||||
PCI_1_ARGS="-device vfio-pci,host=$PCI_SLOT"
|
||||
fi
|
||||
|
||||
PCI_ARGS="${PCI_1_ARGS}"
|
||||
if [[ -n "$PCI_2" ]]; then
|
||||
if [[ "$PCI_2" =~ ^[0-9]{4}: ]]; then
|
||||
PCI_SLOT="$PCI_2"
|
||||
else
|
||||
PCI_SLOT="0000:$PCI_2"
|
||||
fi
|
||||
attach_pci_device "$PCI_SLOT"
|
||||
PCI_2_ARGS="-device vfio-pci,host=$PCI_SLOT"
|
||||
fi
|
||||
|
||||
PCI_ARGS="${PCI_1_ARGS} ${PCI_2_ARGS}"
|
||||
|
||||
|
||||
info "Booting image using $VERS..."
|
||||
|
||||
Reference in New Issue
Block a user