test-runner: allow infinite process wait
PATCH v2 1/3 test-runner: allow infinite process wait
subprocess.Popen's wait() method was overwritten to be non-blocking but in certain circumstances you do want to wait forever. Fix this to allow timeout=None, which calls the parent wait() method directly.
--- tools/utils.py | 4 ++++ 1 file changed, 4 insertions(+)
tools/utils.py +4 -0
@@ -246,6 +246,10 @@ class Process(subprocess.Popen): # Override wait() so it can do so non-blocking def wait(self, timeout=10): + if timeout == None: + super().wait() + return + Namespace.non_block_wait(self.__wait, timeout, 1) self._cleanup()
Signature · 1 line
2.34.1
PATCH v2 2/3 test-runner: start dbus with --start
Starts dbus-daemon as well as sets the right environment variables so IWD can start (and any other dbus services).
--- tools/run-tests | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
v2:
- Rebased so it would apply cleanly.
tools/run-tests +6 -1
@@ -1037,7 +1037,12 @@ atexit.register(exit_vm) runner.prepare_environment() if runner.args.start: - os.system(runner.args.start) + ctx = TestContext(runner.args) + ctx.start_dbus() + os.chdir(runner.args.testhome) + os.environ['DBUS_SYSTEM_BUS_ADDRESS'] = ctx.dbus_address + + subprocess.run([runner.args.start]) else: run_tests(runner.args)
Signature · 1 line
2.34.1
PATCH v2 3/3 test-runner: automatically find PCI passthrough config
In reply to James PrestwoodWhen 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.
--- tools/runner.py | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-)
tools/runner.py +32 -10
@@ -116,6 +116,9 @@ class RunnerCoreArgParse(ArgumentParser): help='Writes PASS/FAIL to results file') self.add_argument('--hw', '-w', type=str, + nargs='?', + const=True, + action='store', help='Use physical adapters for tests (passthrough)') self.add_argument('--testhome', help=SUPPRESS) self.add_argument('--monitor-parent', help=SUPPRESS)
@@ -382,18 +385,18 @@ class QemuRunner(RunnerAbstract): self._prepare_outfiles() if args.hw: - hw_conf = ConfigParser() - hw_conf.read(args.hw) + if os.path.isfile(args.hw): + hw_conf = ConfigParser() + hw_conf.read(args.hw) - if hw_conf.has_section('USBAdapters'): - # The actual key name of the adapter - # doesn't matter since all we need is the - # bus/address. This gets named by the kernel - # anyways once in the VM. - usb_adapters = [v for v in hw_conf['USBAdapters'].values()] + if hw_conf.has_section('USBAdapters'): + # The actual key name of the adapter + # doesn't matter since all we need is the + # bus/address. This gets named by the kernel + # anyways once in the VM. + usb_adapters = [v for v in hw_conf['USBAdapters'].values()] - if hw_conf.has_section('PCIAdapters'): - pci_adapters = [v for v in hw_conf['PCIAdapters'].values()] + pci_adapters = self._find_pci_adapters() kern_log = "ignore_loglevel" if "kernel" in args.verbose else "quiet"
@@ -473,6 +476,25 @@ class QemuRunner(RunnerAbstract): 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): mounts = [ MountInfo('debugfs', 'debugfs', '/sys/kernel/debug', '', 0) ]
Signature · 1 line
2.34.1
Hi James,
Quoted 7 lines · James Prestwood
subprocess.Popen's
wait()method was overwritten to be non-blocking but in certain circumstances you do want to wait forever. Fix this to allow timeout=None, which calls the parentwait()method directly.--- tools/utils.py | 4 ++++ 1 file changed, 4 insertions(+)
All applied, thanks.
Regards,
-Denis