mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-21 22:09:23 +01:00
test-runner: automatically find PCI passthrough config
When PCI adapters are properly configured they should exist in the vfio-pci system tree. It is assumed any devices configured as such are used for test-runner. This removes the need for a hw.conf file to be supplied, but still is required for USB adapters. Because of this the --hw option was updated to allow no value, or a file path.
This commit is contained in:
parent
99773ea7e8
commit
07a3b1d655
@ -116,6 +116,9 @@ class RunnerCoreArgParse(ArgumentParser):
|
|||||||
help='Writes PASS/FAIL to results file')
|
help='Writes PASS/FAIL to results file')
|
||||||
self.add_argument('--hw', '-w',
|
self.add_argument('--hw', '-w',
|
||||||
type=str,
|
type=str,
|
||||||
|
nargs='?',
|
||||||
|
const=True,
|
||||||
|
action='store',
|
||||||
help='Use physical adapters for tests (passthrough)')
|
help='Use physical adapters for tests (passthrough)')
|
||||||
self.add_argument('--testhome', help=SUPPRESS)
|
self.add_argument('--testhome', help=SUPPRESS)
|
||||||
self.add_argument('--monitor-parent', help=SUPPRESS)
|
self.add_argument('--monitor-parent', help=SUPPRESS)
|
||||||
@ -382,18 +385,18 @@ class QemuRunner(RunnerAbstract):
|
|||||||
self._prepare_outfiles()
|
self._prepare_outfiles()
|
||||||
|
|
||||||
if args.hw:
|
if args.hw:
|
||||||
hw_conf = ConfigParser()
|
if os.path.isfile(args.hw):
|
||||||
hw_conf.read(args.hw)
|
hw_conf = ConfigParser()
|
||||||
|
hw_conf.read(args.hw)
|
||||||
|
|
||||||
if hw_conf.has_section('USBAdapters'):
|
if hw_conf.has_section('USBAdapters'):
|
||||||
# The actual key name of the adapter
|
# The actual key name of the adapter
|
||||||
# doesn't matter since all we need is the
|
# doesn't matter since all we need is the
|
||||||
# bus/address. This gets named by the kernel
|
# bus/address. This gets named by the kernel
|
||||||
# anyways once in the VM.
|
# anyways once in the VM.
|
||||||
usb_adapters = [v for v in hw_conf['USBAdapters'].values()]
|
usb_adapters = [v for v in hw_conf['USBAdapters'].values()]
|
||||||
|
|
||||||
if hw_conf.has_section('PCIAdapters'):
|
pci_adapters = self._find_pci_adapters()
|
||||||
pci_adapters = [v for v in hw_conf['PCIAdapters'].values()]
|
|
||||||
|
|
||||||
kern_log = "ignore_loglevel" if "kernel" in args.verbose else "quiet"
|
kern_log = "ignore_loglevel" if "kernel" in args.verbose else "quiet"
|
||||||
|
|
||||||
@ -473,6 +476,25 @@ class QemuRunner(RunnerAbstract):
|
|||||||
|
|
||||||
self.cmdline = qemu_cmdline
|
self.cmdline = qemu_cmdline
|
||||||
|
|
||||||
|
def _find_pci_adapters(self):
|
||||||
|
adapters = []
|
||||||
|
|
||||||
|
try:
|
||||||
|
files = os.listdir('/sys/module/vfio_pci/drivers/pci:vfio-pci')
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
|
for bus_addr in files:
|
||||||
|
if not bus_addr.startswith('0000:'):
|
||||||
|
continue
|
||||||
|
|
||||||
|
adapters.append(bus_addr.replace('0000:', ''))
|
||||||
|
|
||||||
|
if len(adapters) == 0:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return adapters
|
||||||
|
|
||||||
def prepare_environment(self):
|
def prepare_environment(self):
|
||||||
mounts = [ MountInfo('debugfs', 'debugfs', '/sys/kernel/debug', '', 0) ]
|
mounts = [ MountInfo('debugfs', 'debugfs', '/sys/kernel/debug', '', 0) ]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user