Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Michal Suchánek" <msuchanek@suse.de>
To: linux-nvme@lists.infradead.org
Cc: Daniel Wagner <wagi@kernel.org>
Subject: Re: [PATCH] When kmodpy is not available call kmod binary directly
Date: Tue, 7 Jul 2026 15:37:09 +0200	[thread overview]
Message-ID: <ak0BBYBYdrLBh63I@kunlun.suse.cz> (raw)
In-Reply-To: <20250321105915.8971-1-msuchanek@suse.de>

On Fri, Mar 21, 2025 at 11:59:10AM +0100, Michal Suchanek wrote:
> kmodpy is an unmaintained project. Python is not really good at
> backwards compatibility. With the upstream project not keeping up with
> python churn using the library is a maintenance burden.
> 
> nvmet does not use the python library in any substantial way, it only
> loads a module once. This can be easily accomplished without any library
> using the modprobe tool directly.

Forgot

Signed-off-by: Michal Suchanek <msuchanek@suse.de>

> ---
>  nvmet/nvme.py | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/nvmet/nvme.py b/nvmet/nvme.py
> index 59efdb5b7c1b..397f103abcdb 100644
> --- a/nvmet/nvme.py
> +++ b/nvmet/nvme.py
> @@ -256,9 +256,20 @@ class Root(CFSNode):
>              # Try the ctypes library included with the libkmod itself.
>              try:
>                  import kmod
> -                kmod.Kmod().modprobe(modname)
> -            except Exception as e:
> -                pass
> +
> +                try:
> +                    kmod.Kmod().modprobe(modname)
> +                except Exception as e:
> +                    pass
> +            except ImportError:
> +                # Try the binary specified in /proc
> +                try:
> +                    kmod = None
> +                    with open('/proc/sys/kernel/modprobe', 'r') as f:
> +                        kmod = f.read().rstrip()
> +                    os.system(kmod + ' ' + modname)
> +                except Exception as e:
> +                    pass
>  
>      def _list_subsystems(self):
>          self._check_self()
> -- 
> 2.47.1
> 


      parent reply	other threads:[~2026-07-07 13:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-21 10:59 [PATCH] When kmodpy is not available call kmod binary directly Michal Suchanek
2025-03-21 12:39 ` Maurizio Lombardi
2026-07-07 13:37 ` Michal Suchánek [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ak0BBYBYdrLBh63I@kunlun.suse.cz \
    --to=msuchanek@suse.de \
    --cc=linux-nvme@lists.infradead.org \
    --cc=wagi@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox