From 9ffc23d4217897864c48b3790559cc9f643ecf72 Mon Sep 17 00:00:00 2001 From: redxef Date: Wed, 5 Feb 2025 18:00:29 +0100 Subject: [PATCH] feat: allow dynamic vfio device selection via shell scripts. Create files $CONFIG/vfio-devices.sh and $CONFIG/vfio-devices-$VMNAME.sh. --- qemu-vm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qemu-vm b/qemu-vm index 8ff9230..012f742 100755 --- a/qemu-vm +++ b/qemu-vm @@ -37,7 +37,7 @@ NET_CONF_FILE="$NET_CONF_FILE" "$SUDO" --preserve-env=PATH,NET_CONF_FILE qemu-vm # rebind devices old_IFS="$IFS" IFS=$'\n' -for device_override in $(cat "$CONFIG_PATH/vfio-devices.txt" || true) $(cat "$CONFIG_PATH/vfio-devices-$VMNAME.txt" || true); do +for device_override in $(cat "$CONFIG_PATH/vfio-devices.txt" || true) $(sh "$CONFIG_PATH/vfio-devices.sh") $(cat "$CONFIG_PATH/vfio-devices-$VMNAME.txt" || true) $(sh "$CONFIG_PATH/vfio-devices-$VMNAME.sh"); do device_override="${device_override%%#*}" device="$(awk '{print $1}' <<< "$device_override")" override="$(awk '{print $2}' <<< "$device_override")" @@ -48,7 +48,7 @@ for device_override in $(cat "$CONFIG_PATH/vfio-devices.txt" || true) $(cat "$CO $SUDO --preserve-env=SUDO,PATH qemu-vm-pci vfio_override_device "$device" done $SUDO modprobe vfio-pci -for device_override in $(cat "$CONFIG_PATH/vfio-devices.txt" || true) $(cat "$CONFIG_PATH/vfio-devices-$VMNAME.txt" || true); do +for device_override in $(cat "$CONFIG_PATH/vfio-devices.txt" || true) $(sh "$CONFIG_PATH/vfio-devices.sh") $(cat "$CONFIG_PATH/vfio-devices-$VMNAME.txt" || true) $(sh "$CONFIG_PATH/vfio-devices-$VMNAME.sh"); do device_override="${device_override%%#*}" device="$(awk '{print $1}' <<< "$device_override")" override="$(awk '{print $2}' <<< "$device_override")"