Skip to contentSkip to conversation

vfio: selftests: Find devices that have VFIO selftest drivers

PATCH Superseded Josh Hilke 2 participants 2 messages Jun 2

Subsystems (4)

v5 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Josh Hilke

author
#0 lore raw

PATCH v5 1/1 vfio: selftests: Find devices that have VFIO selftest drivers

Add a new script, list_devices.sh, which prints out the segment:bus:device.function (SBDF) numbers and names of devices on a machine that have a VFIO selftest driver. This makes it easier to determine if the system is capable of running VFIO selftests.

Includes a -q (quiet) argument which prints just the SBDFs so that the output can be piped into tools/testing/selftests/vfio/script/setup.sh to bind the devices to VFIO to use in VFIO selftests.

Examples:

$ ./list_devices.sh
0000:6a:01.0 - Intel SPR DSA (8086:0b25)
0000:6f:01.0 - Intel SPR DSA (8086:0b25)
0000:74:01.0 - Intel SPR DSA (8086:0b25)
0000:79:01.0 - Intel SPR DSA (8086:0b25)
0000:e7:01.0 - Intel SPR DSA (8086:0b25)
0000:ec:01.0 - Intel SPR DSA (8086:0b25)
0000:f1:01.0 - Intel SPR DSA (8086:0b25)
0000:f6:01.0 - Intel SPR DSA (8086:0b25)
$ ./list_devices.sh -q
0000:6a:01.0
0000:6f:01.0
0000:74:01.0
0000:79:01.0
0000:e7:01.0
0000:ec:01.0
0000:f1:01.0
0000:f6:01.0

---
Changelog

v4 -> v5
- Rename list_devices.sh to list_supported_devices.sh (Vipin)
- Document the source of supported device names/IDs (Vipin)
- Align the output format with lspci (Vipin)
- Fix errors in device names and IDs (Vipin)

v4: https://lore.kernel.org/kvm/[email protected]/

 tools/testing/selftests/vfio/Makefile         |  1 +
 .../vfio/scripts/list_supported_devices.sh    | 44 +++++++++++++++++++
 2 files changed, 45 insertions(+)
 create mode 100755 tools/testing/selftests/vfio/scripts/list_supported_devices.sh
tools/testing/selftests/vfio/Makefile +1 -0
index 0684932d91bf..127e70b996a9 100644
@@ -15,6 +15,7 @@ TEST_GEN_PROGS += vfio_pci_driver_test
 
 TEST_FILES += scripts/cleanup.sh
 TEST_FILES += scripts/lib.sh
+TEST_FILES += scripts/list_supported_devices.sh
 TEST_FILES += scripts/run.sh
 TEST_FILES += scripts/setup.sh
 
tools/testing/selftests/vfio/scripts/list_supported_devices.sh new file +44 -0

44 lines not on this page · raw message

Signature · 1 line
2.54.0.1013.g208068f2d8-goog
#1 lore raw
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] Documentation and implementation mismatch regarding script name, output format, and usage…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Documentation and implementation mismatch regarding script name, output format, and usage instructions.
- [Low] Unused local variable bdf.
--

commit dac67adaa35d0b3beddd4d11badc85a43ad7c2e3
Author: Josh Hilke <[email protected]>

vfio: selftests: Find devices that have VFIO selftest drivers

This commit adds a new script to print the SBDF numbers and names of devices that have a VFIO selftest driver. It also includes a quiet mode to print only the SBDFs.

Quoted 8 lines

Add a new script, list_devices.sh, which prints out the segment:bus:device.function (SBDF) numbers and names of devices on a machine that have a VFIO selftest driver. This makes it easier to determine if the system is capable of running VFIO selftests.

Includes a -q (quiet) argument which prints just the SBDFs so that the output can be piped into tools/testing/selftests/vfio/script/setup.sh to bind the devices to VFIO to use in VFIO selftests.

[Severity: Medium]
Are these instructions accurate for how the scripts are meant to be used?

The script is named list_supported_devices.sh in the patch, rather than list_devices.sh.

Additionally, the commit message states the output can be piped directly into script/setup.sh (which is missing an 's' for scripts/), but setup.sh requires arguments to be passed on the command line rather than through standard input. Piping directly might result in a usage error.

Quoted 4 lines
    Examples:
    
    $ ./list_devices.sh
    0000:6a:01.0 - Intel SPR DSA (8086:0b25)

[Severity: Medium]
The output format in the example shows "Intel SPR DSA (8086:0b25)", but the script below generates "Intel DSA SPR [8086:0b25]". Could the commit message be updated to match the implementation?

Quoted 8 lines
tools/testing/selftests/vfio/scripts/list_supported_devices.sh new file +2 -0
new file mode 100755
index 0000000000000..a123a965d3586
@@ -0,0 +1,44 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later

[ ... ]

tools/testing/selftests/vfio/scripts/list_supported_devices.sh line 20

Quoted 6 lines
tools/testing/selftests/vfio/scripts/list_supported_devices.sh new file +6 -0
+function main() {
+	local id_name
+	local quiet=""
+	local name
+	local bdfs
+	local bdf

[Severity: Low]
Is this bdf variable used anywhere in the script? It appears to be declared but never assigned or read.

Quoted 1 line
tools/testing/selftests/vfio/scripts/list_supported_devices.sh new file +1 -0
+	local id
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1