From 71b9ee9c585afc055d33e188ba94b3ca63f01f1f Mon Sep 17 00:00:00 2001 From: Filip Strajnar Date: Sat, 26 Oct 2024 19:40:49 +0200 Subject: [PATCH] Added devices_in_iommu_group method. --- src/pci_passthrough_assist/pci_device.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pci_passthrough_assist/pci_device.py b/src/pci_passthrough_assist/pci_device.py index 4c24123..ee97910 100644 --- a/src/pci_passthrough_assist/pci_device.py +++ b/src/pci_passthrough_assist/pci_device.py @@ -1,5 +1,6 @@ from pci_passthrough_assist.pci import driver_of_pci_device from os.path import exists +from os import listdir class PciDevice: @@ -13,5 +14,10 @@ class PciDevice: def is_vga(self) -> bool: return exists(f"/sys/bus/pci/devices/{self.device_id}/boot_vga") + def devices_in_iommu_group(self) -> list['PciDevice']: + device_ids: list[str] = listdir( + f"/sys/bus/pci/devices/{self.device_id}/iommu_group/devices") + return [PciDevice(device_id) for device_id in device_ids] + def __str__(self) -> str: - return f"{self.device_id} driver: {self.driver_name()} VGA: {self.is_vga()}" \ No newline at end of file + return f"{self.device_id} driver: {self.driver_name()} VGA: {self.is_vga()}"