Skip to content

Commit

Permalink
improve kmod logging, optimize lspci kmod loading
Browse files Browse the repository at this point in the history
Signed-off-by: Zen <[email protected]>
  • Loading branch information
desultory committed Sep 22, 2024
1 parent 807c1c6 commit 5bf9481
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/ugrd/kmod/kmod.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__author__ = 'desultory'
__version__ = '2.14.2'
__version__ = '2.15.0'

from pathlib import Path
from subprocess import run
Expand Down Expand Up @@ -114,6 +114,7 @@ def _autodetect_modules_lspci(self) -> None:
cmd = self._run(['lspci', '-k'])
except RuntimeError as e:
raise DependencyResolutionError("Failed to get list of kernel modules") from e
lspci_kmods = set()
# Iterate over all output lines
for line in cmd.stdout.decode('utf-8').split('\n'):
# If the line contains the string 'Kernel modules:' or 'Kernel driver in use:', it contains the name of a kernel module
Expand All @@ -122,10 +123,11 @@ def _autodetect_modules_lspci(self) -> None:
if ',' in module:
# If there are multiple modules, split them and add them to the module set
for module in module.split(','):
self['_kmod_auto'] = module.strip()
lspci_kmods.add(module.strip())
else:
# Add the single module to the module set
self['_kmod_auto'] = module.strip()
lspci_kmods.add(module.strip())

self['_kmod_auto'] = list(lspci_kmods)


@contains('kmod_autodetect_lsmod', "kmod_autodetect_lsmod is not enabled, skipping.")
Expand Down Expand Up @@ -306,7 +308,10 @@ def process_modules(self) -> None:
try:
_process_kmod_dependencies(self, kmod)
continue
except (IgnoredModuleError, BuiltinModuleError) as e:
except BuiltinModuleError as e:
self.logger.debug(e)
continue # Don't add built-in modules to the ignore list
except IgnoredModuleError as e:
self.logger.info(e)
except DependencyResolutionError as e:
if kmod in self['kmod_init']:
Expand Down

0 comments on commit 5bf9481

Please sign in to comment.