コード例 #1
0
 def get_disks_xhci(self):
     """
     Compare
     1. the pci slot name of the devices using xhci
     2. the pci slot name of the disks,
        which is usb3 disks in this case so far,
     to make sure the usb3 disk does be on the controller using xhci
     """
     # LP: #1378724
     udev_client = GUdev.Client()
     # Get a collection of all udev devices corresponding to block devices
     udev_devices = get_udev_block_devices(udev_client)
     # Get a collection of all udev devices corresponding to xhci devices
     udev_devices_xhci = get_udev_xhci_devices(udev_client)
     if platform.machine() in ("aarch64", "armv7l"):
         enumerator = GUdev.Enumerator(client=udev_client)
         udev_devices_xhci = [
             device for device in enumerator.execute()
             if (device.get_driver() == 'xhci-hcd')
         ]
     for udev_device_xhci in udev_devices_xhci:
         pci_slot_name = udev_device_xhci.get_property('PCI_SLOT_NAME')
         xhci_devpath = udev_device_xhci.get_property('DEVPATH')
         for udev_device in udev_devices:
             devpath = udev_device.get_property('DEVPATH')
             if (self._compare_pci_slot_from_devpath(
                     devpath, pci_slot_name)):
                 self.rem_disks_xhci[udev_device.get_property(
                     'DEVNAME')] = 'xhci'
             if platform.machine() in ("aarch64", "armv7l"):
                 if xhci_devpath in devpath:
                     self.rem_disks_xhci[udev_device.get_property(
                         'DEVNAME')] = 'xhci'
     return self.rem_disks_xhci
コード例 #2
0
def get_udev_xhci_devices(udev_client):
    """
    Get a list of all devices on pci slots using xhci drivers
    """
    # setup an enumerator so that we can list devices
    enumerator = GUdev.Enumerator(client=udev_client)
    # Iterate over pci devices only
    enumerator.add_match_subsystem('pci')
    devices = [
        device for device in enumerator.execute()
        if (device.get_driver() == 'xhci_hcd')]
    # Sort the list, this is not needed but makes various debugging dumps
    # look better.
    devices.sort(key=lambda device: device.get_property('PCI_SLOT_NAME'))
    return devices
コード例 #3
0
def get_udev_block_devices(udev_client):
    """
    Get a list of all block devices

    Returns a list of GUdev.Device objects representing all block devices in
    the system. Virtual devices are filtered away using
    checkbox.heuristics.udev.is_virtual_device.
    """
    # setup an enumerator so that we can list devices
    enumerator = GUdev.Enumerator(client=udev_client)
    # Iterate over block devices only
    enumerator.add_match_subsystem('block')
    # Convert the enumerator into a plain list and filter-away all
    # devices deemed virtual by the heuristic.
    devices = [
        device for device in enumerator.execute()
        if not is_virtual_device(device.get_device_file())]
    # Sort the list, this is not needed but makes various debugging dumps
    # look better.
    devices.sort(key=lambda device: device.get_device_file())
    return devices