Date: Tue, 9 Jan 2024 16:47:44 GMT From: Christos Margiolis <christos@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: a00a507e2d5f - stable/13 - vmrun.sh: allow device name arguments in pci-passthru option Message-ID: <202401091647.409GliOi061869@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=a00a507e2d5f4f5de7e7bbafc6df419a1565da24 commit a00a507e2d5f4f5de7e7bbafc6df419a1565da24 Author: Christos Margiolis <christos@FreeBSD.org> AuthorDate: 2024-01-02 18:20:42 +0000 Commit: Christos Margiolis <christos@FreeBSD.org> CommitDate: 2024-01-09 16:47:36 +0000 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 (cherry picked from commit 2ee77056d2d4f9d43bd316ce6dc91bf5e4b0848b) --- share/examples/bhyve/vmrun.sh | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/share/examples/bhyve/vmrun.sh b/share/examples/bhyve/vmrun.sh index d2cc371e472f..323d8e22a041 100755 --- a/share/examples/bhyve/vmrun.sh +++ b/share/examples/bhyve/vmrun.sh @@ -62,7 +62,7 @@ usage() { echo " [-L <VNC IP for UEFI framebuffer>]" echo " [-m <memsize>]" \ "[-n <network adapter emulation type>]" - echo " [-p <bus/slot/func>]" + echo " [-p <pcidev|bus/slot/func>]" echo " [-P <port>] [-t <tapdev>] <vmname>" echo "" echo " -h: display this help message" @@ -87,8 +87,8 @@ usage() { echo " -m: memory size (default: ${DEFAULT_MEMSIZE})" echo " -n: network adapter emulation type" \ "(default: ${DEFAULT_NIC})" - echo " -p: pass-through a host PCI device at bus/slot/func" \ - "(e.g. 10/0/0)" + echo " -p: pass-through a host PCI device (e.g ppt0 or" \ + "bus/slot/func)" echo " -P: UEFI GOP VNC port (default: ${DEFAULT_VNCPORT})" echo " -t: tap device for virtio-net (default: $DEFAULT_TAPDEV)" echo " -T: Enable tablet device (for UEFI GOP)" @@ -351,10 +351,21 @@ while [ 1 ]; do i=0 while [ $i -lt $pass_total ] ; do - eval "pass=\$pass_dev${i}" - devargs="$devargs -s $nextslot:0,passthru,${pass} " - nextslot=$(($nextslot + 1)) - i=$(($i + 1)) + eval "pass=\$pass_dev${i}" + bsfform="$(echo "${pass}" | grep "^[0-9]\+/[0-9]\+/[0-9]\+$")" + if [ -z "${bsfform}" ]; then + 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 efiargs=""
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202401091647.409GliOi061869>