[Kimchi-devel] [PATCH v2] [Kimchi 2/3] Adding 'passthrough' forward mode to Macvtap: model and test changes

dhbarboza82 at gmail.com dhbarboza82 at gmail.com
Wed May 18 19:32:42 UTC 2016


From: Daniel Henrique Barboza <danielhb at linux.vnet.ibm.com>

Adding a new forward mode called 'passthrough' to macvtap
networks. New test included.

Signed-off-by: Daniel Henrique Barboza <danielhb at linux.vnet.ibm.com>
---
 model/networks.py        |  5 +++--
 tests/test_networkxml.py | 14 ++++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/model/networks.py b/model/networks.py
index cc59ca8..3478395 100644
--- a/model/networks.py
+++ b/model/networks.py
@@ -192,7 +192,8 @@ class NetworksModel(object):
             raise InvalidParameter('KCHNET0028E', {'name': iface})
 
         # set macvtap network
-        params['forward'] = {'mode': 'bridge', 'dev': iface}
+        forward_mode = params.get('forward_mode', 'bridge')
+        params['forward'] = {'mode': forward_mode, 'dev': iface}
 
     def _set_network_vepa(self, params):
         for iface in params['interfaces']:
@@ -353,7 +354,7 @@ class NetworkModel(object):
 
         connection = forward['mode'] or "isolated"
         # FIXME, if we want to support other forward mode well.
-        if connection == 'bridge':
+        if connection in ['bridge', 'passthrough']:
             # macvtap bridge
             interface = interface or forward['interface'][0]
             if netinfo.is_nic(interface) or netinfo.is_bonding(interface):
diff --git a/tests/test_networkxml.py b/tests/test_networkxml.py
index 8e83744..40776bc 100644
--- a/tests/test_networkxml.py
+++ b/tests/test_networkxml.py
@@ -195,6 +195,20 @@ class NetworkXmlTests(unittest.TestCase):
         xml_str = nxml.to_network_xml(**params)
         self.assertEqual(xml_str, expected_xml)
 
+    def test_macvtap_passthrough_forward_xml(self):
+        expected_xml = """<network><name>test_macvtap</name>\
+<forward mode="passthrough" dev="interface1"/></network>"""
+
+        params = {
+            "name": "test_macvtap",
+            "forward": {
+                "mode": "passthrough",
+                "dev": "interface1"
+            }
+        }
+        xml_str = nxml.to_network_xml(**params)
+        self.assertEqual(xml_str, expected_xml)
+
 
 class InterfaceXmlTests(unittest.TestCase):
 
-- 
2.5.5




More information about the Kimchi-devel mailing list