From nobody Tue Jan 02 18:20:52 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4T4Lkr45Lwz561Jy; Tue, 2 Jan 2024 18:20:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4T4Lkr2Fn5z3gQH; Tue, 2 Jan 2024 18:20:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704219652; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DDbsiT5wYPJ3MbIHqBC32hDu42uYCE7VQhv+reXSmLA=; b=lrj/WLBjuTYpopd7eF9y2rrCr+QvVIGTr/O6b2Rv8N9EUJUqfVBIJ6N5jEqXOrlf0wrk0M Vtb6Lr0JIXrJbxREoP5pgxCUPctvEDqgbiw3qbL+JIR3pkutlVHc8CQZV7pmegjtDdQhfn 4MaTM2Jx6yoWOTqQSFIIdczUvLTlksPQKpdHcZYKAZXd3X4gsq5s+beDlb7sIP/vL4vMUy fWlq78Z3SGZQ5snZS6NFxaoJNRKEJP/rK4+4kmen195JEFBnq/8DFDvG8QEi7GeuJRMRuX CvdbyRmaefJnknysHF/6ydm76/W/o5Jt6WfDPQE5s1Mtp6z98ji07yzARn/YmA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704219652; a=rsa-sha256; cv=none; b=JTCCZqAr4ZgNQxPqtCyWFaPwwMK7gFS2EXYfkIgnL58ojpx5cKXYvWlwYjBVWQyfnhUU18 2rR9GVpJ+M4fOOVseXi8irjXZFHny/EXvpRJsVryWpYbWBcAEy9WPmshqrXURqU1weu9y5 wsjdYTf2tG+qdkLyLM0zSkudI+nPPNYh0ijcbMAm7IuBM/WiackX/mBnYFONVbe9rYLXew izZge0rxJ6wkkmhr7OpcEdi1znLBhalgTU0k8KzI73+0WVVcyy6psXr6cyrGt7VzlekN8V dPWIM09GeukUwwd9N5/Mf40nyqgw5db5n1yWTE7Vh2VStQxxUkOscupJcpmPwg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704219652; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DDbsiT5wYPJ3MbIHqBC32hDu42uYCE7VQhv+reXSmLA=; b=QvorE043eIhI+vvuHcPza5HsyL6guWpmOubYN8EkFjvzPAjYK5hkfTo+WyDX1G7XflF8Ud dXX+jX5mrERdKQW6LBNIa83ilTupzry8RHeJNd4lq6p1ozVHkmU7yss+7KgBWJYCD/9ff6 xiZPl2OQLoGggff1ijd2JE+H79HpVi8pVsqVRPhAem7tPS22gfcth4X+xGPC2hwNBa9VpH 040A37PYQS8ENdE2F24n+eD2GIB1AvDENpq1oYgN4raoQqgsC5ZLP0TrTQgyk86UJSwM75 uKJaCqBozKHfC7RuwT2/yZmB8GVoll7CGM9YMHAnVyCIk2oxcD1yDoDhPdkDSA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4T4Lkr12N0z19c0; Tue, 2 Jan 2024 18:20:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 402IKqbX078505; Tue, 2 Jan 2024 18:20:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 402IKqsm078502; Tue, 2 Jan 2024 18:20:52 GMT (envelope-from git) Date: Tue, 2 Jan 2024 18:20:52 GMT Message-Id: <202401021820.402IKqsm078502@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Christos Margiolis Subject: git: 2ee77056d2d4 - main - vmrun.sh: allow device name arguments in pci-passthru option List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: christos X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2ee77056d2d4f9d43bd316ce6dc91bf5e4b0848b Auto-Submitted: auto-generated The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=2ee77056d2d4f9d43bd316ce6dc91bf5e4b0848b commit 2ee77056d2d4f9d43bd316ce6dc91bf5e4b0848b Author: Christos Margiolis AuthorDate: 2024-01-02 18:20:42 +0000 Commit: Christos Margiolis CommitDate: 2024-01-02 18:20:42 +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 --- 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 ]" echo " [-m ]" \ "[-n ]" - echo " [-p ]" + echo " [-p ]" echo " [-P ] [-t ] " 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=""