Blame SOURCES/0006-nvme.py-Make-modprobe-work-for-kmod-lib-too.patch

26b18e
From 75c178f6c2943490ef2c13df5863d6ac308f6ef1 Mon Sep 17 00:00:00 2001
26b18e
From: Tony Asleson <tasleson@redhat.com>
26b18e
Date: Thu, 26 Mar 2020 13:07:48 -0500
26b18e
Subject: [PATCH 06/12] nvme.py: Make modprobe work for kmod lib too
26b18e
26b18e
The python library 'kmod' is included with libkmod, lets try to use that
26b18e
if the user isn't utilizing kmodpy.
26b18e
26b18e
Signed-off-by: Tony Asleson <tasleson@redhat.com>
26b18e
Signed-off-by: Christoph Hellwig <hch@lst.de>
26b18e
---
26b18e
 nvmet/nvme.py | 7 ++++++-
26b18e
 1 file changed, 6 insertions(+), 1 deletion(-)
26b18e
26b18e
diff --git a/nvmet/nvme.py b/nvmet/nvme.py
26b18e
index 04659de..db8a03c 100644
26b18e
--- a/nvmet/nvme.py
26b18e
+++ b/nvmet/nvme.py
26b18e
@@ -253,7 +253,12 @@ class Root(CFSNode):
26b18e
             except kmod.KmodError:
26b18e
                 pass
26b18e
         except ImportError:
26b18e
-            pass
26b18e
+            # Try the ctypes library included with the libkmod itself.
26b18e
+            try:
26b18e
+                import kmod
26b18e
+                kmod.Kmod().modprobe(modname)
26b18e
+            except Exception as e:
26b18e
+                pass
26b18e
 
26b18e
     def _list_subsystems(self):
26b18e
         self._check_self()
26b18e
-- 
26b18e
2.29.2
26b18e