diff mbox series

devbind: check for lspci

Message ID d2749a0c9f18188c56e02e61c602e65ca88e099d.1541598755.git.anatoly.burakov@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers show
Series devbind: check for lspci | expand

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

Burakov, Anatoly Nov. 7, 2018, 1:56 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>
---
 usertools/dpdk-devbind.py | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Ferruh Yigit Nov. 7, 2018, 4:01 p.m. UTC | #1
On 11/7/2018 1:56 PM, Anatoly Burakov 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.

I guess we need lspci for `--status`, bind/unbind can be done without `lspci`,
what about adding check only display path?

> 
> Cc: stable@dpdk.org
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---
>  usertools/dpdk-devbind.py | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py
> index 7d564634c..74bf514c0 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 'lspci'")
> +            sys.exit(1)
>      parse_args()
>      check_modules()
>      clear_data()
>
Burakov, Anatoly Nov. 7, 2018, 4:30 p.m. UTC | #2
On 07-Nov-18 4:01 PM, Ferruh Yigit wrote:
> On 11/7/2018 1:56 PM, Anatoly Burakov 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.
> 
> I guess we need lspci for `--status`, bind/unbind can be done without `lspci`,
> what about adding check only display path?

IMO it's not worth respinning over that minor detail, but if you feel 
strongly about it - sure, i can do a v2 with this on display path only :)

> 
>>
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
>> ---
>>   usertools/dpdk-devbind.py | 7 +++++++
>>   1 file changed, 7 insertions(+)
>>
>> diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py
>> index 7d564634c..74bf514c0 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 'lspci'")
>> +            sys.exit(1)
>>       parse_args()
>>       check_modules()
>>       clear_data()
>>
> 
>
Ferruh Yigit Nov. 7, 2018, 6:07 p.m. UTC | #3
On 11/7/2018 4:30 PM, Burakov, Anatoly wrote:
> On 07-Nov-18 4:01 PM, Ferruh Yigit wrote:
>> On 11/7/2018 1:56 PM, Anatoly Burakov 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.
>>
>> I guess we need lspci for `--status`, bind/unbind can be done without `lspci`,
>> what about adding check only display path?
> 
> IMO it's not worth respinning over that minor detail, but if you feel 
> strongly about it - sure, i can do a v2 with this on display path only :)

No strong opinion, was just an idea, OK to go as it is if you prefer, not having
lspci installed but still want to use devbind may not be common usecase..

> 
>>
>>>
>>> Cc: stable@dpdk.org
>>>
>>> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
>>> ---
>>>   usertools/dpdk-devbind.py | 7 +++++++
>>>   1 file changed, 7 insertions(+)
>>>
>>> diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py
>>> index 7d564634c..74bf514c0 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 'lspci'")
>>> +            sys.exit(1)
>>>       parse_args()
>>>       check_modules()
>>>       clear_data()
>>>
>>
>>
> 
>
Rami Rosen Nov. 8, 2018, 8:38 p.m. UTC | #4
Hi, Anatoly,

This is really minor nitpick, but in case you decide to send V2, I believe
it should say
>> + if ret != 0:
>> +            print("'lspci' not found - please install pciutils')

as the name of the package containing lspci is pciutils in centos.

Regards,
Rami Rosen


>
Burakov, Anatoly Nov. 9, 2018, 12:03 p.m. UTC | #5
On 08-Nov-18 8:38 PM, Rami Rosen wrote:
> Hi, Anatoly,
> 
> This is really minor nitpick, but in case you decide to send V2, I 
> believe it should say
>  >> + if ret != 0:
>  >> +            print("'lspci' not found - please install pciutils')
> 
> as the name of the package containing lspci is pciutils in centos.

Do all other distros have lspci in package called pciutils? If not, i 
prefer to keep it the way it is.

> 
> Regards,
> Rami Rosen
> 
>
Rami Rosen Nov. 10, 2018, 11:03 a.m. UTC | #6
HI Anatoly,

>Do all other distros have lspci in package called pciutils? If not, i
>prefer to keep it the way it is.

Your original patch have:

+        if ret != 0:
+            print("'lspci' not found - please install 'lspci'")

And I suggest to consider changing it to:

 >> + if ret != 0:
 >> +            print("'lspci' not found - please install pciutils')
>

Sorry about my ignorance: which distro has a package named "lspci", if at all?

The official project that include the lspci utility is called
"pciutils": see: http://mj.ucw.cz/sw/pciutils/
You can see that a package named "pciutils" is available in great many
distros, like:
Fedora, OpenSuSE, CentOS, RHEL, Ubuntu, Debian, Mandriva and Mageia,
according to the following links:

http://www.rpmfind.net/linux/rpm2html/search.php?query=pciutils&submit=Search+...
https://packages.ubuntu.com/trusty/pciutils
https://packages.debian.org/search?keywords=pciutils
https://rpms.remirepo.net/rpmphp/zoom.php?rpm=pciutils

Regards,
Rami Rosen
Burakov, Anatoly Nov. 12, 2018, 9:18 a.m. UTC | #7
On 10-Nov-18 11:03 AM, Rami Rosen wrote:
> HI Anatoly,
> 
>> Do all other distros have lspci in package called pciutils? If not, i
>> prefer to keep it the way it is.
> 
> Your original patch have:
> 
> +        if ret != 0:
> +            print("'lspci' not found - please install 'lspci'")
> 
> And I suggest to consider changing it to:
> 
>   >> + if ret != 0:
>   >> +            print("'lspci' not found - please install pciutils')
>>
> 
> Sorry about my ignorance: which distro has a package named "lspci", if at all?
> 
> The official project that include the lspci utility is called
> "pciutils": see: http://mj.ucw.cz/sw/pciutils/
> You can see that a package named "pciutils" is available in great many
> distros, like:
> Fedora, OpenSuSE, CentOS, RHEL, Ubuntu, Debian, Mandriva and Mageia,
> according to the following links:
> 
> http://www.rpmfind.net/linux/rpm2html/search.php?query=pciutils&submit=Search+...
> https://packages.ubuntu.com/trusty/pciutils
> https://packages.debian.org/search?keywords=pciutils
> https://rpms.remirepo.net/rpmphp/zoom.php?rpm=pciutils
> 
> Regards,
> Rami Rosen
> 

Hi,

Thanks, that's good to know, will fix in v2.
Burakov, Anatoly Nov. 13, 2018, 4:03 p.m. UTC | #8
On 07-Nov-18 4:01 PM, Ferruh Yigit wrote:
> On 11/7/2018 1:56 PM, Anatoly Burakov 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.
> 
> I guess we need lspci for `--status`, bind/unbind can be done without `lspci`,
> what about adding check only display path?

This is actually incorrect. While we *use* the lspci output only on 
display paths, we actually gather info about devices using lspci in 
get_device_details(). So, i'll leave the code as is and just fix the 
package name for v2.
diff mbox series

Patch

diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py
index 7d564634c..74bf514c0 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 'lspci'")
+            sys.exit(1)
     parse_args()
     check_modules()
     clear_data()