From: "Tu, Lijuan" <lijuan.tu@intel.com>
To: "pvukkisala@marvell.com" <pvukkisala@marvell.com>,
"dts@dpdk.org" <dts@dpdk.org>
Cc: "avijay@marvell.com" <avijay@marvell.com>,
"fmasood@marvell.com" <fmasood@marvell.com>
Subject: Re: [dts] [PATCH] qemu-kvm: Avoid using hardcoded pci-id for access net incase of net type is nic
Date: Wed, 3 Jul 2019 06:03:30 +0000 [thread overview]
Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BAD93B4@SHSMSX101.ccr.corp.intel.com> (raw)
In-Reply-To: <1561699808-16406-1-git-send-email-pvukkisala@marvell.com>
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
> <pvukkisala@marvell.com>
> Subject: [dts] [PATCH] qemu-kvm: Avoid using hardcoded pci-id for access
> net incase of net type is nic
>
> From: Phanendra Vukkisala <pvukkisala@marvell.com>
>
> 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 <pvukkisala@marvell.com>
> ---
> 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
prev parent reply other threads:[~2019-07-03 6:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-28 5:30 pvukkisala
2019-07-03 6:03 ` Tu, Lijuan [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8CE3E05A3F976642AAB0F4675D0AD20E0BAD93B4@SHSMSX101.ccr.corp.intel.com \
--to=lijuan.tu@intel.com \
--cc=avijay@marvell.com \
--cc=dts@dpdk.org \
--cc=fmasood@marvell.com \
--cc=pvukkisala@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).