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 EC6D4A046B for ; Fri, 28 Jun 2019 07:30:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BA55C5B34; Fri, 28 Jun 2019 07:30:22 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id C07E15905 for ; Fri, 28 Jun 2019 07:30:20 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5S5Qo70014932 for ; Thu, 27 Jun 2019 22:30:19 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=pfpt0818; bh=fmo97OwkyAGxZWsYxS4ABwrOkgGdzCuouGACkuRVUtQ=; b=X/5IZcT4OMtUiDM06Apb6uBd06NLyV8VlzvWgCQcSRJ0z0Re0KYuMFVBGNsG8r6TuEFr zFRk1wRYjtkDaUe0oJh8tbx0cZ6dj+1gIi4NtcRW+p9qXuYB4pM1u+t9XucMXSWkC20L IUWK3xuCojv6pWf8p6Kk/ppb/aEB95IDEUawO0EIZy2VhXLNN4QNrU03wsyHq6j3omNG ORIiKWJcj9jDNbOQmh1F+eY+Q44C3Q84iWCtJ4uLVQMw1wUvqq5FOKjsFcCCv+NkZlIq 8y5GpMAbAes/VMBq62IYTfXZwW8ONW+tg9CjVeMSeFyALUmCfGSGXeHaSriqxZdkhDAw 1g== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0a-0016f401.pphosted.com with ESMTP id 2td6jj18pq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 27 Jun 2019 22:30:16 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 27 Jun 2019 22:30:13 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 27 Jun 2019 22:30:13 -0700 Received: from phanendra-system.marvell.com (unknown [10.28.11.20]) by maili.marvell.com (Postfix) with ESMTP id BE4D43F7045; Thu, 27 Jun 2019 22:30:11 -0700 (PDT) From: To: CC: , , Phanendra Vukkisala Date: Fri, 28 Jun 2019 11:00:08 +0530 Message-ID: <1561699808-16406-1-git-send-email-pvukkisala@marvell.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-06-28_01:, , signatures=0 Subject: [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" From: Phanendra Vukkisala Added code to find pci-id of access net interface if nic type is nic else use same hardcoded pci-id Signed-off-by: Phanendra Vukkisala --- framework/qemu_kvm.py | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) 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 = options['opt_model'] else: model = 'e1000' + self.nic_model = model net_boot_line += separator + 'model=%s' % model if 'opt_name' in options.keys() and \ @@ -1428,6 +1429,31 @@ class QEMUKvm(VirtBase): return qemu_boot_line + 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 = r'^.*Bus(\s+)(\d+), device(\s+)(\d+), function (\d+)' + dev_reg = r'^.*Ethernet controller:.*([a-fA-F0-9]{4}:[a-fA-F0-9]{4})' + if self.nic_model == "e1000": + dev_id = "8086:100e" + elif self.nic_model == "i82551": + dev_id = "8086:1209" + elif self.nic_model == "virtio": + dev_id = "1af4:1000" + out = self.__monitor_session('info', 'pci') + lines = out.split("\r\n") + for line in lines: + m = re.match(pci_reg, line) + o = re.match(dev_reg, line) + if m: + pci = "%02d:%02d.%d" % ( + int(m.group(2)), int(m.group(4)), int(m.group(5))) + if o: + if o.group(1) == dev_id: + self.net_nic_pci = pci + def __wait_vmnet_ready(self): """ wait for 120 seconds for vm net ready @@ -1438,6 +1464,8 @@ class QEMUKvm(VirtBase): try_times = 0 network_ready = 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") == "Success": network_ready = True break @@ -1825,7 +1853,14 @@ class QEMUKvm(VirtBase): time.sleep(5) out = self.control_session.send_expect(self.qga_cmd_head + "ifconfig" , "#", timeout=self.OPERATION_TIMEOUT) else: - intf = self.control_session.send_expect("ls -1 /sys/bus/pci/devices/0000:00:1f.0/net", "#", timeout=self.OPERATION_TIMEOUT) + pci = "00:1f.0" + if not getattr(self, 'net_nic_pci', None) is None: + pci = self.net_nic_pci + ## If interface is vritio model, net file will be under virtio* directory + if self.nic_model == "virtio": + pci += "/virtio*/" + + intf = self.control_session.send_expect("ls -1 /sys/bus/pci/devices/0000:%s/net" %pci, "#", timeout=self.OPERATION_TIMEOUT) out = self.control_session.send_expect("ifconfig %s" % intf, "#", timeout=self.OPERATION_TIMEOUT) if "10.0.2" not in out: self.control_session.send_expect("dhclient %s -timeout 10" % intf, "#", timeout=30) -- 1.7.9.5