vmrun.sh: allow device name arguments in pci-passthru option

This is more intuitive than having to run `pciconf -l` and figure out
the bus/slot/func entry manually.

Reviewed by:	markj
Sponsored by;	The FreeBSD Foundation
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43270
This commit is contained in:
Christos Margiolis
2024-01-02 20:20:42 +02:00
parent 029b10b16a
commit 2ee77056d2
+18 -7
View File
@@ -62,7 +62,7 @@ usage() {
echo " [-L <VNC IP for UEFI framebuffer>]" echo " [-L <VNC IP for UEFI framebuffer>]"
echo " [-m <memsize>]" \ echo " [-m <memsize>]" \
"[-n <network adapter emulation type>]" "[-n <network adapter emulation type>]"
echo " [-p <bus/slot/func>]" echo " [-p <pcidev|bus/slot/func>]"
echo " [-P <port>] [-t <tapdev>] <vmname>" echo " [-P <port>] [-t <tapdev>] <vmname>"
echo "" echo ""
echo " -h: display this help message" echo " -h: display this help message"
@@ -87,8 +87,8 @@ usage() {
echo " -m: memory size (default: ${DEFAULT_MEMSIZE})" echo " -m: memory size (default: ${DEFAULT_MEMSIZE})"
echo " -n: network adapter emulation type" \ echo " -n: network adapter emulation type" \
"(default: ${DEFAULT_NIC})" "(default: ${DEFAULT_NIC})"
echo " -p: pass-through a host PCI device at bus/slot/func" \ echo " -p: pass-through a host PCI device (e.g ppt0 or" \
"(e.g. 10/0/0)" "bus/slot/func)"
echo " -P: UEFI GOP VNC port (default: ${DEFAULT_VNCPORT})" echo " -P: UEFI GOP VNC port (default: ${DEFAULT_VNCPORT})"
echo " -t: tap device for virtio-net (default: $DEFAULT_TAPDEV)" echo " -t: tap device for virtio-net (default: $DEFAULT_TAPDEV)"
echo " -T: Enable tablet device (for UEFI GOP)" echo " -T: Enable tablet device (for UEFI GOP)"
@@ -351,10 +351,21 @@ while [ 1 ]; do
i=0 i=0
while [ $i -lt $pass_total ] ; do while [ $i -lt $pass_total ] ; do
eval "pass=\$pass_dev${i}" eval "pass=\$pass_dev${i}"
devargs="$devargs -s $nextslot:0,passthru,${pass} " bsfform="$(echo "${pass}" | grep "^[0-9]\+/[0-9]\+/[0-9]\+$")"
nextslot=$(($nextslot + 1)) if [ -z "${bsfform}" ]; then
i=$(($i + 1)) bsf="$(pciconf -l "${pass}" 2>/dev/null)"
if [ $? -ne 0 ]; then
errmsg "${pass} is not a host PCI device"
exit 1
fi
bsf="$(echo "${bsf}" | awk -F: '{print $2"/"$3"/"$4}')"
else
bsf="${pass}"
fi
devargs="$devargs -s $nextslot:0,passthru,${bsf} "
nextslot=$(($nextslot + 1))
i=$(($i + 1))
done done
efiargs="" efiargs=""