[v2] devbind: check for lspci

Message ID 9b28e77a26d11b3cb8d063ea5949f231b0f9830d.1542124966.git.anatoly.burakov@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v2] devbind: check for lspci |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS

Commit Message

Anatoly Burakov Nov. 13, 2018, 4:06 p.m. UTC
  On some distributions (such as CentOS 7) lspci may not be installed
by default, causing exceptions which are difficult to interpret.

Fix devbind script to check if lspci is installed at script startup.

Cc: stable@dpdk.org

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---

Notes:
    v2: correct package name to "pciutils"

 usertools/dpdk-devbind.py | 7 +++++++
 1 file changed, 7 insertions(+)
  

Comments

Rami Rosen Nov. 16, 2018, 4:54 p.m. UTC | #1
Reviewed-by: Rami Rosen <roszenrami@gmail.com>
On Tue, 13 Nov 2018 at 18:06, Anatoly Burakov <anatoly.burakov@intel.com> wrote:
>
> On some distributions (such as CentOS 7) lspci may not be installed
> by default, causing exceptions which are difficult to interpret.
>
> Fix devbind script to check if lspci is installed at script startup.
>
> Cc: stable@dpdk.org
>
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---
>
> Notes:
>     v2: correct package name to "pciutils"
>
>  usertools/dpdk-devbind.py | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py
> index 7d564634c..40dc28a7d 100755
> --- a/usertools/dpdk-devbind.py
> +++ b/usertools/dpdk-devbind.py
> @@ -655,6 +655,13 @@ def do_arg_actions():
>
>  def main():
>      '''program main function'''
> +    # check if lspci is installed, suppress any output
> +    with open(os.devnull, 'w') as devnull:
> +        ret = subprocess.call(['which', 'lspci'],
> +                              stdout=devnull, stderr=devnull)
> +        if ret != 0:
> +            print("'lspci' not found - please install 'pciutils'")
> +            sys.exit(1)
>      parse_args()
>      check_modules()
>      clear_data()
> --
> 2.17.1
  
Thomas Monjalon Nov. 18, 2018, 11:05 p.m. UTC | #2
16/11/2018 17:54, Rami Rosen:
> On Tue, 13 Nov 2018 at 18:06, Anatoly Burakov <anatoly.burakov@intel.com> wrote:
> >
> > On some distributions (such as CentOS 7) lspci may not be installed
> > by default, causing exceptions which are difficult to interpret.
> >
> > Fix devbind script to check if lspci is installed at script startup.
> >
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> Reviewed-by: Rami Rosen <roszenrami@gmail.com>

Applied, thanks
  

Patch

diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py
index 7d564634c..40dc28a7d 100755
--- a/usertools/dpdk-devbind.py
+++ b/usertools/dpdk-devbind.py
@@ -655,6 +655,13 @@  def do_arg_actions():
 
 def main():
     '''program main function'''
+    # check if lspci is installed, suppress any output
+    with open(os.devnull, 'w') as devnull:
+        ret = subprocess.call(['which', 'lspci'],
+                              stdout=devnull, stderr=devnull)
+        if ret != 0:
+            print("'lspci' not found - please install 'pciutils'")
+            sys.exit(1)
     parse_args()
     check_modules()
     clear_data()