Created unbind_driver and bind_to_driver.
This commit is contained in:
parent
71b9ee9c58
commit
6cc3a29828
|
|
@ -14,6 +14,19 @@ class PciDevice:
|
||||||
def is_vga(self) -> bool:
|
def is_vga(self) -> bool:
|
||||||
return exists(f"/sys/bus/pci/devices/{self.device_id}/boot_vga")
|
return exists(f"/sys/bus/pci/devices/{self.device_id}/boot_vga")
|
||||||
|
|
||||||
|
def unbind_driver(self):
|
||||||
|
with open(f"/sys/bus/pci/devices/{self.device_id}/driver/unbind",
|
||||||
|
"w") as device_driver:
|
||||||
|
device_driver.write(self.device_id)
|
||||||
|
|
||||||
|
def bind_to_driver(self, driver_to_bind: str, unbind_first: bool = True):
|
||||||
|
if unbind_first:
|
||||||
|
self.unbind_driver()
|
||||||
|
|
||||||
|
with open(f"/sys/bus/pci/drivers/{driver_to_bind}/bind",
|
||||||
|
"w") as driver:
|
||||||
|
driver.write(self.device_id)
|
||||||
|
|
||||||
def devices_in_iommu_group(self) -> list['PciDevice']:
|
def devices_in_iommu_group(self) -> list['PciDevice']:
|
||||||
device_ids: list[str] = listdir(
|
device_ids: list[str] = listdir(
|
||||||
f"/sys/bus/pci/devices/{self.device_id}/iommu_group/devices")
|
f"/sys/bus/pci/devices/{self.device_id}/iommu_group/devices")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue