Re: [PATCH i-g-t 02/10] tools/vmtb: Fix DUT selection based on card index

Bernatowicz, Marcin
2026-03-10T10:27:03Z

On 2/24/2026 8:50 AM, Adam Miszczak wrote:
> A GPU devices list need to be searched by requested card index
> (device minor number) - not list index.
> Implement Host.get_device() function to return Device
> with a given minor number from the detected devices list,
> bound to a requested DRM driver (e.g. xe).
> DUT reference is now kept by the VmmTestingSetup,
> not embedded within Host class.
>
> Signed-off-by: Adam Miszczak <adam.miszczak@linux.intel.com>
> ---
> tools/vmtb/bench/machines/host.py | 12 +++++++-----
> tools/vmtb/bench/machines/physical/device.py | 5 ++++-
> tools/vmtb/vmm_flows/conftest.py | 15 ++++++++-------
> tools/vmtb/vmm_flows/test_basic.py | 4 ++--
> 4 files changed, 21 insertions(+), 15 deletions(-)
>
> diff --git a/tools/vmtb/bench/machines/host.py b/tools/vmtb/bench/machines/host.py
> index 666f35c26..aecc7709a 100644
> --- a/tools/vmtb/bench/machines/host.py
> +++ b/tools/vmtb/bench/machines/host.py
> @@ -1,8 +1,7 @@
> # SPDX-License-Identifier: MIT
> -# Copyright © 2024 Intel Corporation
> +# Copyright © 2024-2026 Intel Corporation
>
> import logging
> -import re
> import shlex
> import signal
> import subprocess
> @@ -24,13 +23,12 @@ class Host(MachineInterface):
> def __init__(self) -> None:
> self.running_procs: typing.Dict[int, subprocess.Popen] = {}
> self.gpu_devices: typing.List[Device] = []
> - self.dut_index: int = 0
> # Initialize in conftest/VmmTestingSetup:
> self.drm_driver_name: str
> self.igt_config: VmtbIgtConfig
>
> def __str__(self) -> str:
> - return f'Host-{self.gpu_devices[self.dut_index].pci_info.bdf}'
> + return 'Host'
>
> @LogDecorators.parse_kmsg
> def execute(self, command: str) -> int:
> @@ -181,9 +179,13 @@ class Host(MachineInterface):
>
> logger.debug("Detected GPU PCI device(s):")
> for dev in self.gpu_devices:
> - logger.debug("[%s] PCI BDF: %s / DevID: %s (%s)",
> + logger.debug("[card%s] PCI BDF: %s / DevID: %s (%s)",
> dev.pci_info.minor_number, dev.pci_info.bdf, dev.pci_info.devid, dev.gpu_model)
>
> + def get_device(self, dev_minor: int) -> typing.Optional[Device]:
> + """Find device with a given minor number within detected GPU devices list."""
> + return next((dev for dev in self.gpu_devices if dev.pci_info.minor_number == dev_minor), None)
> +
> def suspend(self, mode: SuspendMode = SuspendMode.ACPI_S3) -> None:
> """Perform host suspend cycle (ACPI S3) via rtcwake tool."""
> wakeup_delay = 10 # wakeup timer in seconds
> diff --git a/tools/vmtb/bench/machines/physical/device.py b/tools/vmtb/bench/machines/physical/device.py
> index 12a5d5f7d..887f607e4 100644
> --- a/tools/vmtb/bench/machines/physical/device.py
> +++ b/tools/vmtb/bench/machines/physical/device.py
> @@ -1,5 +1,5 @@
> # SPDX-License-Identifier: MIT
> -# Copyright © 2024 Intel Corporation
> +# Copyright © 2024-2026 Intel Corporation
>
> import importlib
> import logging
> @@ -48,6 +48,9 @@ class Device(DeviceInterface):
> self.gpu_model: str = pci.get_gpu_model(self.pci_info.devid)
> self.driver: DriverInterface = self.instantiate_driver(driver, self.pci_info.minor_number)
>
> + def __str__(self) -> str:
> + return f'Dev-{self.pci_info.bdf}'
> +
> def instantiate_driver(self, driver_name: str, card_index: int) -> Any:
> module_name = f'bench.drivers.{driver_name}'
> class_name = f'{driver_name.capitalize()}Driver'
> diff --git a/tools/vmtb/vmm_flows/conftest.py b/tools/vmtb/vmm_flows/conftest.py
> index 675312253..3bfac01c4 100644
> --- a/tools/vmtb/vmm_flows/conftest.py
> +++ b/tools/vmtb/vmm_flows/conftest.py
> @@ -81,12 +81,12 @@ class VmmTestingSetup:
>
> self.vgpu_profiles_dir = vmtb_config.vmtb_config_file.parent / vmtb_config.config.vgpu_profiles_path
>
> - self.host.dut_index = self.dut_index
> self.host.drm_driver_name = vmtb_config.get_host_config().driver
> self.host.igt_config = vmtb_config.get_host_config().igt_config
>
> self.host.load_drivers()
> self.host.discover_devices()
> + self.dut: Device = self.host.get_device(self.dut_index)
>
> # VF migration requires vendor specific VFIO driver (e.g. xe-vfio-pci)
> vf_migration_support: bool = self.host.is_driver_loaded(f'{self.host.drm_driver_name}-vfio-pci')
> @@ -97,7 +97,7 @@ class VmmTestingSetup:
> "\n\tDevice ID: %s (%s)"
> "\n\tHost DRM driver: %s"
> "\n\tVF migration support: %s",
> - self.host.dut_index,
> + self.dut_index,
> self.get_dut().pci_info.bdf,
> self.get_dut().pci_info.devid, self.get_dut().gpu_model,
> self.get_dut().driver.get_name(),
> @@ -127,11 +127,12 @@ class VmmTestingSetup:
> return vgpu_profile
>
> def get_dut(self) -> Device:
> - try:
> - return self.host.gpu_devices[self.dut_index]
> - except IndexError as exc:
> - logger.error("Invalid VMTB config - device card index = %s not available", self.dut_index)
> - raise exceptions.VmtbConfigError(f'Device card index = {self.dut_index} not available') from exc
> + if self.dut is None:
> + logger.error("Invalid VMTB config - DRM card%s is not bound to %s driver",
> + self.dut_index, self.host.drm_driver_name)
> + raise exceptions.VmtbConfigError(f'Invalid VMTB config - DRM card{self.dut_index} device not supported')
> +
> + return self.dut
>
> @property
> def get_vm(self):
> diff --git a/tools/vmtb/vmm_flows/test_basic.py b/tools/vmtb/vmm_flows/test_basic.py
> index 100be7652..1d3a68b36 100644
> --- a/tools/vmtb/vmm_flows/test_basic.py
> +++ b/tools/vmtb/vmm_flows/test_basic.py
> @@ -1,5 +1,5 @@
> # SPDX-License-Identifier: MIT
> -# Copyright © 2024 Intel Corporation
> +# Copyright © 2024-2026 Intel Corporation
>
> import logging
> import time
> @@ -82,7 +82,7 @@ class TestVmWorkload:
> logger.info("[%s] Verify result of basic WL", igt.target)
> assert igt_check(igt)
>
> - logger.info("[%s] Verify result of basic WL", ts.host)
> + logger.info("[Host %s] Verify result of basic WL", ts.get_dut())
LGTM,
Reviewed-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
> igt_run_check(ts.host, IgtType.EXEC_STORE)
>