[dpdk-dev,v2] tools: fix issue with virtio interfaces
Commit Message
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>
Fixes: 3da038604009 ("Signed-off-by: Souvik Dey <sodey@sonusnet.com>")
tools/dpdk-devbind.py | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
@@ -36,7 +36,6 @@ import sys
import os
import getopt
import subprocess
-import commands
from os.path import exists, abspath, dirname, basename
@@ -224,14 +223,18 @@ 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. Get the correct path.
- virtio = "/sys/bus/pci/devices/%s/" % dev_id
- cmd = " ls %s | grep 'virt' " %virtio
- virtio = commands.getoutput(cmd)
- virtio_sys_path = "/sys/bus/pci/devices/%s/%s/net/" % (dev_id,virtio)
+ # 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(virt_path):
+ elif exists(virtio_sys_path):
device["Interface"] = ",".join(os.listdir(virtio_sys_path))
else:
device["Interface"] = ""