From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 49360A0487 for ; Wed, 3 Jul 2019 08:03:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 40C9E1E20; Wed, 3 Jul 2019 08:03:36 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 853A31BE0 for ; Wed, 3 Jul 2019 08:03:34 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jul 2019 23:03:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,446,1557212400"; d="scan'208";a="154652662" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga007.jf.intel.com with ESMTP; 02 Jul 2019 23:03:33 -0700 Received: from fmsmsx124.amr.corp.intel.com (10.18.125.39) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 2 Jul 2019 23:03:33 -0700 Received: from shsmsx108.ccr.corp.intel.com (10.239.4.97) by fmsmsx124.amr.corp.intel.com (10.18.125.39) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 2 Jul 2019 23:03:32 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.134]) by SHSMSX108.ccr.corp.intel.com ([169.254.8.174]) with mapi id 14.03.0439.000; Wed, 3 Jul 2019 14:03:31 +0800 From: "Tu, Lijuan" To: "pvukkisala@marvell.com" , "dts@dpdk.org" CC: "avijay@marvell.com" , "fmasood@marvell.com" Thread-Topic: [dts] [PATCH] qemu-kvm: Avoid using hardcoded pci-id for access net incase of net type is nic Thread-Index: AQHVLXKgIeJodS1b/0OZyG8FZahakKa4bykQ Date: Wed, 3 Jul 2019 06:03:30 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BAD93B4@SHSMSX101.ccr.corp.intel.com> References: <1561699808-16406-1-git-send-email-pvukkisala@marvell.com> In-Reply-To: <1561699808-16406-1-git-send-email-pvukkisala@marvell.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.600.7 dlp-reaction: no-action x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOTE5Mzk2ZjMtYTNmNy00YWZkLWE5NjQtOGVhMTZiZWE0NGJlIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiVGY0a3YzSkhnVU9ZVzczdUNqZW5LbmFDdFFFQ2FPRE82QnVOXC9cLzl6MDU2dWZCbUU4Vmx4THB2VGVQaW45UmJJIn0= x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH] qemu-kvm: Avoid using hardcoded pci-id for access net incase of net type is nic X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" Applied, thanks > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of > pvukkisala@marvell.com > Sent: Friday, June 28, 2019 1:30 PM > To: dts@dpdk.org > Cc: avijay@marvell.com; fmasood@marvell.com; Phanendra Vukkisala > > Subject: [dts] [PATCH] qemu-kvm: Avoid using hardcoded pci-id for access > net incase of net type is nic >=20 > From: Phanendra Vukkisala >=20 > Added code to find pci-id of access net interface if nic type is nic else= use > same hardcoded pci-id >=20 > Signed-off-by: Phanendra Vukkisala > --- > framework/qemu_kvm.py | 37 ++++++++++++++++++++++++++++++++++++- > 1 file changed, 36 insertions(+), 1 deletion(-) >=20 > diff --git a/framework/qemu_kvm.py b/framework/qemu_kvm.py index > cf1f7e7..ce8da46 100644 > --- a/framework/qemu_kvm.py > +++ b/framework/qemu_kvm.py > @@ -544,6 +544,7 @@ class QEMUKvm(VirtBase): > model =3D options['opt_model'] > else: > model =3D 'e1000' > + self.nic_model =3D model > net_boot_line +=3D separator + 'model=3D%s' % model >=20 > if 'opt_name' in options.keys() and \ @@ -1428,6 +1429,31 @@ cla= ss > QEMUKvm(VirtBase): >=20 > return qemu_boot_line >=20 > + def __get_vmnet_pci(self): > + """ > + Get PCI ID of access net interface on VM > + """ > + if not getattr(self, 'nic_model', None) is None: > + pci_reg =3D r'^.*Bus(\s+)(\d+), device(\s+)(\d+), function (= \d+)' > + dev_reg =3D r'^.*Ethernet controller:.*([a-fA-F0-9]{4}:[a-fA= -F0-9]{4})' > + if self.nic_model =3D=3D "e1000": > + dev_id =3D "8086:100e" > + elif self.nic_model =3D=3D "i82551": > + dev_id =3D "8086:1209" > + elif self.nic_model =3D=3D "virtio": > + dev_id =3D "1af4:1000" > + out =3D self.__monitor_session('info', 'pci') > + lines =3D out.split("\r\n") > + for line in lines: > + m =3D re.match(pci_reg, line) > + o =3D re.match(dev_reg, line) > + if m: > + pci =3D "%02d:%02d.%d" % ( > + int(m.group(2)), int(m.group(4)), int(m.group(5)= )) > + if o: > + if o.group(1) =3D=3D dev_id: > + self.net_nic_pci =3D pci > + > def __wait_vmnet_ready(self): > """ > wait for 120 seconds for vm net ready @@ -1438,6 +1464,8 @@ clas= s > QEMUKvm(VirtBase): > try_times =3D 0 > network_ready =3D False > while (time_diff < self.START_TIMEOUT): > + if getattr(self, 'net_nic_pci', None) is None: > + self.__get_vmnet_pci() > if self.control_command("network") =3D=3D "Success": > network_ready =3D True > break > @@ -1825,7 +1853,14 @@ class QEMUKvm(VirtBase): > time.sleep(5) > out =3D self.control_session.send_expect(self.qga_cmd_he= ad + > "ifconfig" , "#", timeout=3Dself.OPERATION_TIMEOUT) > else: > - intf =3D self.control_session.send_expect("ls -1 > /sys/bus/pci/devices/0000:00:1f.0/net", "#", > timeout=3Dself.OPERATION_TIMEOUT) > + pci =3D "00:1f.0" > + if not getattr(self, 'net_nic_pci', None) is None: > + pci =3D self.net_nic_pci > + ## If interface is vritio model, net file will be un= der virtio* > directory > + if self.nic_model =3D=3D "virtio": > + pci +=3D "/virtio*/" > + > + intf =3D self.control_session.send_expect("ls -1 > + /sys/bus/pci/devices/0000:%s/net" %pci, "#", > + timeout=3Dself.OPERATION_TIMEOUT) > out =3D self.control_session.send_expect("ifconfig %s" %= intf, "#", > timeout=3Dself.OPERATION_TIMEOUT) > if "10.0.2" not in out: > self.control_session.send_expect("dhclient %s -timeo= ut 10" % > intf, "#", timeout=3D30) > -- > 1.7.9.5