From: David Matlack <dmatlack@google.com>
To: Josh Hilke <jrhilke@google.com>
Cc: Alex Williamson <alex@shazbot.org>,
Vipin Sharma <vipinsh@google.com>,
Raghavendra Rao Ananta <rananta@google.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
seanjc@google.com
Subject: Re: [PATCH 2/2] vfio: selftests: Automate setting up devices for testing
Date: Fri, 10 Apr 2026 22:49:49 +0000 [thread overview]
Message-ID: <adl-jZhpu8R2mZVR@google.com> (raw)
In-Reply-To: <20260409015139.2800185-3-jrhilke@google.com>
On 2026-04-09 01:51 AM, Josh Hilke wrote:
> Update the VFIO selftest setup script to find a device that has a VFIO selftest
> driver on the system, and set it up (i.e unbind that device from its driver, and
> then bind that device to VFIO).
>
> This makes the process of setting up a device to VFIO selftests much easier, as
> users don't have to manually figure out which device to use. Though, users can
> still manually setup a device by passing the -d argument with a
> segment:bus:device.function number.
>
> Example of automated device setup:
>
> $ ./tools/testing/selftests/vfio/scripts/setup.sh./setup.sh
Script path here got garbled
> + echo "0000:6a:01.0" > /sys/bus/pci/drivers/idxd/unbind
> + echo "vfio-pci" > /sys/bus/pci/devices/0000:6a:01.0/driver_override
> + echo "0000:6a:01.0" > /sys/bus/pci/drivers/vfio-pci/bind
> Successfully set up 0000:6a:01.0
>
> Example of automated device setup where no compatible devices exist:
>
> $ . ./tools/testing/selftests/vfio/scripts/setup.sh/setup.sh
Here too, also the extra '.' before the path looks like a mistake.
> No available supported devices found on the system.
>
> Example of manual device setup:
>
> $ ./tools/testing/selftests/vfio/scripts/setup.sh -d 0000:6a:01.0
> + echo "0000:6a:01.0" > /sys/bus/pci/drivers/idxd/unbind
> + echo "vfio-pci" > /sys/bus/pci/devices/0000:6a:01.0/driver_override
> + echo "0000:6a:01.0" > /sys/bus/pci/drivers/vfio-pci/bind
> Successfully set up 0000:6a:01.0
>
> Signed-off-by: Josh Hilke <jrhilke@google.com>
Please add Suggested-by tag for Sean and also Cc Sean on next version
of the series :)
> ---
> tools/testing/selftests/vfio/scripts/setup.sh | 22 +++++++++++++++++--
> 1 file changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/vfio/scripts/setup.sh b/tools/testing/selftests/vfio/scripts/setup.sh
> index 2cde07eb9c8b..6d4492b211ea 100755
> --- a/tools/testing/selftests/vfio/scripts/setup.sh
> +++ b/tools/testing/selftests/vfio/scripts/setup.sh
> @@ -19,11 +19,30 @@ function print_supported_devices() {
> done
> }
>
> +function pick_device() {
> + local bdf
> +
> + while read -r bdf; do
> + if [ -n "${bdf}" ]; then
> + if [ -d "${DEVICES_DIR}/${bdf}" ]; then
> + echo "${bdf} has already been set up, exiting." >&2
> + exit 0
> + fi
> + echo "${bdf}"
> + return 0
> + fi
> + done <<< "$(print_supported_devices)"
> +
> + echo "No available supported devices found on the system." >&2
I think we should make it clear what "supported" means in this log. This
is about finding a device that has a VFIO selftests driver, which is
only required by some tests.
Same goes for the -l option in the previous commit actually and the
usage message below.
> + exit 1
> +}
> +
> function usage() {
> echo "usage: $0 [-l] [-d <segment:bus:device.function>]" >&2
> echo "" >&2
> echo " -l List segment:bus:device.function numbers of supported devices." >&2
> echo " -d segment:bus:device.function to set up." >&2
> + echo " If -d is not specified, a device will be automatically picked." >&2
> }
>
> function main() {
> @@ -46,8 +65,7 @@ function main() {
> done
>
> if [ ${#bdf_list[@]} -eq 0 ]; then
> - usage
> - exit 1
> + bdf_list=($(pick_device))
Sashiko thinks this will ignore any errors from pick_device():
https://sashiko.dev/#/patchset/20260409015139.2800185-1-jrhilke%40google.com?part=2
> fi
>
> for device_bdf in "${bdf_list[@]}"; do
> --
> 2.53.0.1213.gd9a14994de-goog
>
next prev parent reply other threads:[~2026-04-10 22:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-09 1:51 [PATCH 0/2] vfio: selftests: Automate finding/setting up devices for testing Josh Hilke
2026-04-09 1:51 ` [PATCH 1/2] vfio: selftests: Find devices that are compatible with VFIO selftests Josh Hilke
2026-04-10 22:40 ` David Matlack
2026-04-09 1:51 ` [PATCH 2/2] vfio: selftests: Automate setting up devices for testing Josh Hilke
2026-04-10 22:49 ` David Matlack [this message]
2026-04-10 22:54 ` David Matlack
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=adl-jZhpu8R2mZVR@google.com \
--to=dmatlack@google.com \
--cc=alex@shazbot.org \
--cc=jrhilke@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rananta@google.com \
--cc=seanjc@google.com \
--cc=vipinsh@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox