Don't break if no vfio-devices are passed through.
This commit is contained in:
parent
7f917c29c9
commit
6bbbd9ad56
1 changed files with 14 additions and 6 deletions
20
qemu-vm
20
qemu-vm
|
@ -37,16 +37,24 @@ 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 $(< "$CONFIG_PATH/vfio-devices.txt") $(< "$CONFIG_PATH/vfio-devices-$VMNAME.txt"); do
|
||||
device="$(echo "$device_override" | awk '{print $1}')"
|
||||
override="$(echo "$device_override" | awk '{print $2}')"
|
||||
for device_override in $(cat "$CONFIG_PATH/vfio-devices.txt" || true) $(cat "$CONFIG_PATH/vfio-devices-$VMNAME.txt" || true); do
|
||||
device_override="${device_override%%#*}"
|
||||
device="$(awk '{print $1}' <<< "$device_override")"
|
||||
override="$(awk '{print $2}' <<< "$device_override")"
|
||||
if [[ "$device" = '' ]] || [[ "$override" = '' ]]; then
|
||||
continue
|
||||
fi
|
||||
[[ "$override" != 'true' ]] && continue
|
||||
$SUDO --preserve-env=SUDO,PATH qemu-vm-pci vfio_override_device "$device"
|
||||
done
|
||||
$SUDO modprobe vfio-pci
|
||||
for device_override in $(< "$CONFIG_PATH/vfio-devices.txt") $(< "$CONFIG_PATH/vfio-devices-$VMNAME.txt"); do
|
||||
device="$(echo "$device_override" | awk '{print $1}')"
|
||||
override="$(echo "$device_override" | awk '{print $2}')"
|
||||
for device_override in $(cat "$CONFIG_PATH/vfio-devices.txt" || true) $(cat "$CONFIG_PATH/vfio-devices-$VMNAME.txt" || true); do
|
||||
device_override="${device_override%%#*}"
|
||||
device="$(awk '{print $1}' <<< "$device_override")"
|
||||
override="$(awk '{print $2}' <<< "$device_override")"
|
||||
if [[ "$device" = '' ]] || [[ "$override" = '' ]]; then
|
||||
continue
|
||||
fi
|
||||
$SUDO --preserve-env=SUDO,PATH qemu-vm-pci vfio_rebind_device "$device" "$override"
|
||||
done
|
||||
IFS="$old_IFS"
|
||||
|
|
Loading…
Add table
Reference in a new issue