]> www.infradead.org Git - users/hch/nvmetcli.git/commitdiff
nvme.py: Make modprobe work for kmod lib too
authorTony Asleson <tasleson@redhat.com>
Thu, 26 Mar 2020 18:07:48 +0000 (13:07 -0500)
committerChristoph Hellwig <hch@lst.de>
Wed, 1 Apr 2020 09:00:14 +0000 (11:00 +0200)
The python library 'kmod' is included with libkmod, lets try to use that
if the user isn't utilizing kmodpy.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
nvmet/nvme.py

index 04659deed11f6d755cc6e1d8d3ac46522f93dffe..db8a03c414c4ae8c996ddce984ca77daa77231cb 100644 (file)
@@ -253,7 +253,12 @@ class Root(CFSNode):
             except kmod.KmodError:
                 pass
         except ImportError:
-            pass
+            # Try the ctypes library included with the libkmod itself.
+            try:
+                import kmod
+                kmod.Kmod().modprobe(modname)
+            except Exception as e:
+                pass
 
     def _list_subsystems(self):
         self._check_self()