[dts] [dts 7/9] Optimize VF devices creation and network devices pass-through function

Yong Liu yong.liu at intel.com
Thu Jun 18 05:06:42 CEST 2015


From: Marvin Liu <yong.liu at intel.com>

Add pt devices list in qemu_kvm module which can support devices free in
virtual scenario module.
Support netdevie object get by pci address.

Signed-off-by: Marvin Liu <yong.liu at intel.com>

diff --git a/framework/qemu_kvm.py b/framework/qemu_kvm.py
index 8e0582a..6320a43 100644
--- a/framework/qemu_kvm.py
+++ b/framework/qemu_kvm.py
@@ -88,6 +88,9 @@ class QEMUKvm(VirtBase):
         self.char_idx = 0
         self.netdev_idx = 0
 
+        # devices pass-through into vm
+        self.pt_devices = []
+
     def set_vm_default(self):
         self.set_vm_name(self.vm_name)
         self.set_vm_enable_kvm()
@@ -534,6 +537,7 @@ class QEMUKvm(VirtBase):
         if 'opt_host' in options.keys() and \
                 options['opt_host']:
             dev_boot_line += separator + 'host=%s' % options['opt_host']
+            self.pt_devices.append(options['opt_host'])
         if 'opt_addr' in options.keys() and \
                 options['opt_addr']:
             dev_boot_line += separator + 'addr=%s' % options['opt_addr']
@@ -773,7 +777,7 @@ class QEMUKvm(VirtBase):
         cpus = self.virt_pool.alloc_cpu(vm=self.vm_name, corelist=req_cpus)
 
         if len(req_cpus) != len(cpus):
-            self.host_logger.warn("VCPUs not enough, required [ %s ], just [ %s ]" %
+            self.host_logger.warning("VCPUs not enough, required [ %s ], just [ %s ]" %
                                   (req_cpus, cpus))
             raise Exception("No enough required vcpus!!!")
 
@@ -904,6 +908,9 @@ class QEMUKvm(VirtBase):
                     return ip
         return ''
 
+    def get_vm_pt_devices(self):
+        return self.pt_devices
+
     def __control_session(self, command, *args):
         """
         Use the qemu guest agent service to control VM.
@@ -935,10 +942,9 @@ class QEMUKvm(VirtBase):
 
         return out
 
-    def stop(self):
+    def _stop_vm(self):
         """
         Stop VM.
         """
         self.__control_session('powerdown')
         time.sleep(5)
-        self.virt_pool.free_all_resource(self.vm_name)
diff --git a/framework/settings.py b/framework/settings.py
index 19ebe6b..d3cdf80 100644
--- a/framework/settings.py
+++ b/framework/settings.py
@@ -189,3 +189,14 @@ def accepted_nic(pci_id):
             return True
 
     return False
+
+def get_netdev(crb, pci):
+    for port in crb.ports_info:
+        if pci == port['pci']:
+            return port['port']
+        if 'vfs_port' in port.keys():
+            for vf in port['vfs_port']:
+                if pci == vf.pci:
+                    return vf
+
+    return None
diff --git a/framework/test_case.py b/framework/test_case.py
index a519691..5013123 100644
--- a/framework/test_case.py
+++ b/framework/test_case.py
@@ -49,7 +49,10 @@ class TestCase(object):
         for portid in range(len(self.dut.ports_info)):
             nic_type = self.dut.ports_info[portid]['type']
             self.nics.append(nic_name_from_type(nic_type))
-        self.nic = self.nics[0]
+        if len(self.nics):
+            self.nic = self.nics[0]
+        else:
+            self.nic = ''
 
     def set_up_all(self):
         pass
-- 
1.9.3



More information about the dts mailing list