[dpdk-dev,v3] tools: fix issue with virtio interfaces

Message ID 20160826113558.11856-1-sodey@sonusnet.com (mailing list archive)
State Rejected, archived
Delegated to: Yuanhan Liu
Headers

Commit Message

souvikdey33 Aug. 26, 2016, 11:35 a.m. UTC
  This change is required to have the interface name for virtio interfaces.
When we execute the status command the for virtio inerfaces we get
Sample output without the change:
0000:00:04.0 'Virtio network device' if= drv=virtio-pci unused=virtio_pci,igb_uio
Though for other drivers this works.
Sample output with the change:
0000:00:04.0 'Virtio network device' if=eth0 drv=virtio-pci unused=virtio_pci,igb_uio

souvikdey33 (1):
  Signed-off-by: Souvik Dey <sodey@sonusnet.com>

 tools/dpdk-devbind.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)
  

Comments

Thomas Monjalon Oct. 4, 2016, 9:59 a.m. UTC | #1
2016-08-26 07:35, souvikdey33:
> 
> This change is required to have the interface name for virtio interfaces.
> When we execute the status command the for virtio inerfaces we get
> Sample output without the change:
> 0000:00:04.0 'Virtio network device' if= drv=virtio-pci unused=virtio_pci,igb_uio
> Though for other drivers this works.
> Sample output with the change:
> 0000:00:04.0 'Virtio network device' if=eth0 drv=virtio-pci unused=virtio_pci,igb_uio
> 
> souvikdey33 (1):
>   Signed-off-by: Souvik Dey <sodey@sonusnet.com>

The patch from Gary - which do not use subprocess - has been preferred:
	http://dpdk.org/patch/15595
  

Patch

diff --git a/tools/dpdk-devbind.py b/tools/dpdk-devbind.py
index b69ca2a..c0b46ee 100755
--- a/tools/dpdk-devbind.py
+++ b/tools/dpdk-devbind.py
@@ -36,6 +36,7 @@  import sys
 import os
 import getopt
 import subprocess
+
 from os.path import exists, abspath, dirname, basename
 
 # The PCI base class for NETWORK devices
@@ -222,8 +223,19 @@  def get_pci_device_details(dev_id):
         device[name] = value
     # check for a unix interface name
     sys_path = "/sys/bus/pci/devices/%s/net/" % dev_id
+    # the path for virtio devices are different, so get the correct path
+    virtio = "/sys/bus/pci/devices/%s/" % dev_id
+    ls = subprocess.Popen(['ls', virtio], stdout=subprocess.PIPE)
+    grep = subprocess.Popen('grep virt'.split(), stdin=ls.stdout,
+                            stdout=subprocess.PIPE)
+    ls.stdout.close()
+    virtio = grep.communicate()[0].rstrip()
+    ls.wait()
+    virtio_sys_path = "/sys/bus/pci/devices/%s/%s/net/" % (dev_id, virtio)
     if exists(sys_path):
         device["Interface"] = ",".join(os.listdir(sys_path))
+    elif exists(virtio_sys_path):
+        device["Interface"] = ",".join(os.listdir(virtio_sys_path))
     else:
         device["Interface"] = ""
     # check if a port is used for ssh connection