feat(quickemu): add support for passing extra arguments to the SPICE viewer

This commit is contained in:
Lorenzo Villani 2025-08-29 19:11:18 +02:00
parent 40dea5547e
commit 99f2d2e394
2 changed files with 20 additions and 0 deletions

View File

@ -46,6 +46,7 @@ secureboot="off"
tpm="off"
usb_devices=()
viewer="spicy"
viewer_extra_args=""
ssh_port=""
spice_port=""
public_dir=""
@ -273,6 +274,18 @@ device selection*) support this feature.
To ensure that this functionality works as expected, make sure that you
have installed the necessary SPICE Guest Tools on the virtual machine.
Automatic redirection of specific devices can be configured in the
configuration file by setting the `viewer_extra_args` variable.
For example (in the configuration file):
viewer_extra_args="--spice-usbredir-redirect-on-connect=-1,0x1234,0x5678,-1,1"
Where `0x1234` and `0x5678` are example USB VID and PID, respectively.
The string format is described at:
<https://www.spice-space.org/usbredir.html#filter-string-format>.
##### Enabling SPICE redirection on NixOS
On NixOS, if you encounter this error:

View File

@ -2243,6 +2243,12 @@ function start_viewer {
viewer_args+=("${viewer_uri}")
fi
# Add extra arguments
if [ -n "${viewer_extra_args}" ]; then
# shellcheck disable=SC2206
viewer_args+=(${viewer_extra_args})
fi
# Launch the viewer
echo " - Viewer: ${viewer} ${viewer_args[*]} >/dev/null 2>&1 &"
"${viewer}" "${viewer_args[@]}" >/dev/null 2>&1 &
@ -2550,6 +2556,7 @@ secureboot="off"
tpm="off"
usb_devices=()
viewer="${viewer:-spicy}"
viewer_extra_args="${viewer_extra_args:-}"
width="${width:-}"
height="${height:-}"
ssh_port="${ssh_port:-}"