test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH] qemu-kvm: Avoid using hardcoded pci-id for access net incase of net type is nic
@ 2019-06-28  5:30 pvukkisala
  2019-07-03  6:03 ` Tu, Lijuan
  0 siblings, 1 reply; 2+ messages in thread
From: pvukkisala @ 2019-06-28  5:30 UTC (permalink / raw)
  To: dts; +Cc: avijay, fmasood, Phanendra Vukkisala

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dts] [PATCH] qemu-kvm: Avoid using hardcoded pci-id for access net incase of net type is nic
  2019-06-28  5:30 [dts] [PATCH] qemu-kvm: Avoid using hardcoded pci-id for access net incase of net type is nic pvukkisala
@ 2019-07-03  6:03 ` Tu, Lijuan
  0 siblings, 0 replies; 2+ messages in thread
From: Tu, Lijuan @ 2019-07-03  6:03 UTC (permalink / raw)
  To: pvukkisala, dts; +Cc: avijay, fmasood

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-07-03  6:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-28  5:30 [dts] [PATCH] qemu-kvm: Avoid using hardcoded pci-id for access net incase of net type is nic pvukkisala
2019-07-03  6:03 ` Tu, Lijuan

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).