From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0044.outbound.protection.outlook.com [104.47.42.44]) by dpdk.org (Postfix) with ESMTP id 0E28FA6A for ; Tue, 30 Aug 2016 01:16:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=SonusNetworks.onmicrosoft.com; s=selector1-sonusnet-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=dzArxUUhTsvitLrGj1zK52LXs/gl2/kZXTzliIIkHz8=; b=oExTtIia9SDBa0hZBsWBBA4Cj1t/NCvBU6/aLiLAbPZP2Zbi1Xk6cqNnXsD7QHYT/nTu0DH99/Ph1F67dTiO/esLAAryYa7Y1iokOcmP7DXKVBwKNCvaNtbpzTKeXDaokEVXhCoLwdHp1GUo7UaSSA7nn4pcXYPA3SuFr1JnmqU= Received: from BN6PR03MB2740.namprd03.prod.outlook.com (10.173.144.135) by BN6PR03MB2737.namprd03.prod.outlook.com (10.173.144.20) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.587.13; Mon, 29 Aug 2016 23:16:35 +0000 Received: from BN6PR03MB2740.namprd03.prod.outlook.com ([10.173.144.135]) by BN6PR03MB2740.namprd03.prod.outlook.com ([10.173.144.135]) with mapi id 15.01.0587.013; Mon, 29 Aug 2016 23:16:35 +0000 From: "Dey, Souvik" To: "Mussar, Gary" , Stephen Hemminger CC: "nhorman@tuxdriver.com" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v1] dpdk-devbind.py: Virtio interface issue. Thread-Index: AQHR/ngJrYBSlPHhJUWN6RhK2Yt0WKBbZ3YAgACM9VCABBxAUIAAiEwA Date: Mon, 29 Aug 2016 23:16:35 +0000 Message-ID: References: <20160825022546.96468-1-sodey@sonusnet.com> <20160826085500.5691e07d@xeon-e3> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=sodey@sonusnet.com; x-originating-ip: [73.114.35.204] x-ms-office365-filtering-correlation-id: b09d8cbb-fd8a-4e29-85a6-08d3d06285a3 x-microsoft-exchange-diagnostics: 1; BN6PR03MB2737; 6:JkGK8A0X4xEOZ2jv17kDclrbC8AQm1OgJqsxMYGK1SDOaPXIsC65f548klZKyJ+Us7/CaR29/ZBbTHEA8Sib0qvaed+26p8eOp9+BVKWbhIuOoSs8EkzuC0oT3WtTE4baU5cuWqImGrmQiaUedxQC4OBKZpWSJTGPG1iTesD0ycr+adc57aYyGwF5W8CxisNixt5hMKZc8ZQ5RmeG/Q7/qV3eMiU30MwSC26pmdS1GFhWK2iYl/FQTEUQNZK+90+gV0seGBqmd3WScP4YnZvj0BPAZPPHLC6/CW9ja+GPPc=; 5:pxcWQ+24HwQYdDzL9h0gT/idn8jn4SFVM5yoSZ5OZos3GI2DKH6jjuS8vTCejDqOOo+Y6go+f1uzoSqo/Gp6mmak+BmtPnCAnqnX+Sj7+D7rxoKjfkVzfJmU7d9E40QV+BoliJN1zfgA2UMiOnx+7Q==; 24:W+NenCbidvS3BIMzuqL4j1a2dE/bGQqi+WoVPcXCht8y9dWdsxW/EtgHt9Ba/fWPv+dyWOu/h68dj1PvJ6oFCb8vof75j7xNeruwdXvRYH8=; 7:wT8kCFwyv0nS4R59TKQn7we9VDyATpxCgl2kYH8ZgnMHQVK++3xRRuYowqiJYDU6yaBhzzJvufPtuX0SBlI732M1HoyEJSCb9HBHvQmBCQhu2Cg5ZzexL+Xuz/2xRVw+icKvucmbTSvuNBHl0lhJSxMMp9rjXvT4YcHEnevn+e2yR8rcmXEvej3BSYwgOzV3lCDk7WmbCHmBdKtLbPnbwrQ5IoL6Fha/Lxe2piTG+W+m/QIG4Hz2XbZLZVfsK246 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN6PR03MB2737; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:BN6PR03MB2737; BCL:0; PCL:0; RULEID:; SRVR:BN6PR03MB2737; x-forefront-prvs: 0049B3F387 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(7916002)(13464003)(189002)(24454002)(377454003)(199003)(377424004)(305945005)(66066001)(99286002)(105586002)(10400500002)(68736007)(33656002)(7846002)(7736002)(8936002)(7696003)(81166006)(3280700002)(586003)(81156014)(3660700001)(9686002)(6116002)(8676002)(97736004)(102836003)(189998001)(5002640100001)(4326007)(19580405001)(74316002)(106116001)(5660300001)(101416001)(93886004)(54356999)(15395725005)(92566002)(106356001)(2906002)(76576001)(11100500001)(5001770100001)(122556002)(19580395003)(87936001)(2950100001)(3846002)(86362001)(2900100001)(50986999)(77096005)(15975445007)(76176999)(575784001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR03MB2737; H:BN6PR03MB2740.namprd03.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: sonusnet.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: sonusnet.com X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Aug 2016 23:16:35.4668 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 29a671dc-ed7e-4a54-b1e5-8da1eb495dc3 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR03MB2737 Subject: Re: [dpdk-dev] [PATCH v1] dpdk-devbind.py: Virtio interface issue. X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Aug 2016 23:16:39 -0000 Hi, I already followed the 100% python way and submitted the v3 of this patch. = http://dpdk.org/dev/patchwork/patch/15378/ How will your patch be different in solving the issue. There will always be= multiple ways to solving things right. V3 of my submitted 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 =20 # The PCI base class for NETWORK devices @@ -222,8 +223,19 @@ def get_pci_device_details(dev_id): device[name] =3D value # check for a unix interface name sys_path =3D "/sys/bus/pci/devices/%s/net/" % dev_id + # the path for virtio devices are different, so get the correct path + virtio =3D "/sys/bus/pci/devices/%s/" % dev_id + ls =3D subprocess.Popen(['ls', virtio], stdout=3Dsubprocess.PIPE) + grep =3D subprocess.Popen('grep virt'.split(), stdin=3Dls.stdout, + stdout=3Dsubprocess.PIPE) + ls.stdout.close() + virtio =3D grep.communicate()[0].rstrip() + ls.wait() + virtio_sys_path =3D "/sys/bus/pci/devices/%s/%s/net/" % (dev_id, virti= o) if exists(sys_path): device["Interface"] =3D ",".join(os.listdir(sys_path)) + elif exists(virtio_sys_path): + device["Interface"] =3D ",".join(os.listdir(virtio_sys_path)) else: device["Interface"] =3D "" # check if a port is used for ssh connection -----Original Message----- From: Mussar, Gary [mailto:gmussar@ciena.com]=20 Sent: Monday, August 29, 2016 11:10 AM To: Dey, Souvik ; Stephen Hemminger Cc: nhorman@tuxdriver.com; dev@dpdk.org Subject: RE: [dpdk-dev] [PATCH v1] dpdk-devbind.py: Virtio interface issue. We did this slightly differently. This is 100% python and is a bit more gen= eral. We search for the first "net" directory under the specific device dir= ectory. ------------------------------------------- --- tools/dpdk-devbind.py 2016-08-29 11:02:35.594202888 -0400 +++ ../dpdk/tools/dpdk-devbind.py 2016-08-29 11:00:34.897677233 -0400 @@ -221,11 +221,11 @@ name =3D name.strip(":") + "_str" device[name] =3D value # check for a unix interface name - sys_path =3D "/sys/bus/pci/devices/%s/net/" % dev_id - if exists(sys_path): - device["Interface"] =3D ",".join(os.listdir(sys_path)) - else: - device["Interface"] =3D "" + device["Interface"] =3D "" + for base, dirs, files in os.walk("/sys/bus/pci/devices/%s/" % dev_id): + if "net" in dirs: + device["Interface"] =3D ",".join(os.listdir(os.path.join(base,= "net"))) + break # check if a port is used for ssh connection device["Ssh_if"] =3D False device["Active"] =3D "" ------------------------------------------- Gary -----Original Message----- From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Dey, Souvik Sent: Friday, August 26, 2016 8:21 PM To: Stephen Hemminger Cc: nhorman@tuxdriver.com; dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH v1] dpdk-devbind.py: Virtio interface issue. Hi , I have already updated it and have re submitted the patch v3. Can you plea= se check that http://dpdk.org/dev/patchwork/patch/15378/ -- Regards, Souvik -----Original Message----- From: Stephen Hemminger [mailto:stephen@networkplumber.org]=20 Sent: Friday, August 26, 2016 11:55 AM To: Dey, Souvik Cc: nhorman@tuxdriver.com; dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH v1] dpdk-devbind.py: Virtio interface issue. On Wed, 24 Aug 2016 22:25:46 -0400 souvikdey33 wrote: > + #The path for virtio devices are different. Get the correct path. > + virtio =3D "/sys/bus/pci/devices/%s/" % dev_id > + cmd =3D " ls %s | grep 'virt' " %virtio > + virtio =3D commands.getoutput(cmd) > + virtio_sys_path =3D "/sys/bus/pci/devices/%s/%s/net/" %=20 > +(dev_id,virtio) > if exists(sys_path): > device["Interface"] =3D ",".join(os.listdir(sys_path)) There should be a way to do this in python without going out to shell. This would be safer and more secure. The code already uses os.listdir() (which is the python library version of = ls) in later section. Why not use that here to check for virtio bus.