DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Anatoly Burakov <anatoly.burakov@intel.com>
Cc: dev@dpdk.org, john.mcnamara@intel.com, thomas@monjalon.net
Subject: Re: [dpdk-dev] [PATCH 2/2] usertools/devbind: check if module is loaded before binding
Date: Wed, 24 Jul 2019 09:28:12 -0700	[thread overview]
Message-ID: <20190724092812.069d9049@hermes.lan> (raw)
In-Reply-To: <1862ad94e15a61121aea75a2933dc8a44bb12623.1563982007.git.anatoly.burakov@intel.com>

On Wed, 24 Jul 2019 16:34:44 +0100
Anatoly Burakov <anatoly.burakov@intel.com> wrote:

> +# check if a specific kernel module is loaded
> +def module_is_loaded(module):
> +    # Get list of sysfs modules (both built-in and dynamically loaded)
> +    sysfs_path = '/sys/module/'
> +
> +    # Get the list of directories in sysfs_path
> +    sysfs_mods = [os.path.join(sysfs_path, o) for o
> +                  in os.listdir(sysfs_path)
> +                  if os.path.isdir(os.path.join(sysfs_path, o))]
> +
> +    # get module names
> +    sysfs_mods = [os.path.basename(a) for a in sysfs_mods]
> +
> +    # special case for vfio_pci (module is named vfio-pci,
> +    # but its .ko is named vfio_pci)
> +    sysfs_mods = [a if a != 'vfio_pci' else 'vfio-pci' for a in sysfs_mods]
> +
> +    return module in sysfs_mods
> +

You could just check if the one module exist rather than getting full
list.

Maybe vfio-pci should be renamed vfil_pci earlier in the code.

  reply	other threads:[~2019-07-24 16:28 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-24 15:34 [dpdk-dev] [PATCH 0/2] Small usability improvements for devbind Anatoly Burakov
2019-07-24 15:34 ` [dpdk-dev] [PATCH 1/2] usertools/devbind: add error on forgetting to specify driver Anatoly Burakov
2019-07-24 16:29   ` Stephen Hemminger
2019-07-24 16:47     ` Burakov, Anatoly
2019-07-24 15:34 ` [dpdk-dev] [PATCH 2/2] usertools/devbind: check if module is loaded before binding Anatoly Burakov
2019-07-24 16:28   ` Stephen Hemminger [this message]
2019-07-24 16:47     ` Burakov, Anatoly
2019-07-25 13:48 ` [dpdk-dev] [PATCH v2 0/3] Small usability improvements for devbind Anatoly Burakov
2019-07-25 13:55   ` [dpdk-dev] [PATCH v3 " Anatoly Burakov
2019-07-25 14:21     ` [dpdk-dev] [PATCH v4 " Anatoly Burakov
2019-07-30 21:52       ` Thomas Monjalon
2019-07-25 14:21     ` [dpdk-dev] [PATCH v4 1/3] usertools/devbind: add error on forgetting to specify driver Anatoly Burakov
2019-07-25 14:21     ` [dpdk-dev] [PATCH v4 2/3] usertools/devbind: check if module is loaded before binding Anatoly Burakov
2019-07-25 14:21     ` [dpdk-dev] [PATCH v4 3/3] usertools/devbind: print all errors to stderr Anatoly Burakov
2019-07-25 13:55   ` [dpdk-dev] [PATCH v3 1/3] usertools/devbind: add error on forgetting to specify driver Anatoly Burakov
2019-07-25 13:55   ` [dpdk-dev] [PATCH v3 2/3] usertools/devbind: check if module is loaded before binding Anatoly Burakov
2019-07-25 13:55   ` [dpdk-dev] [PATCH v3 3/3] usertools/devbind: print all errors to stderr Anatoly Burakov
2019-07-25 13:48 ` [dpdk-dev] [PATCH v2 1/3] usertools/devbind: add error on forgetting to specify driver Anatoly Burakov
2019-07-25 13:48 ` [dpdk-dev] [PATCH v2 2/3] usertools/devbind: check if module is loaded before binding Anatoly Burakov
2019-07-25 13:48 ` [dpdk-dev] [PATCH v2 3/3] usertools/devbind: print all errors to stderr Anatoly Burakov

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=20190724092812.069d9049@hermes.lan \
    --to=stephen@networkplumber.org \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=john.mcnamara@intel.com \
    --cc=thomas@monjalon.net \
    /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;
as well as URLs for NNTP newsgroup(s).