From: Daniel Henrique Barboza <danielhb(a)linux.vnet.ibm.com>
v2:
- used interface now being displayed in UI and backend
- fixed an issue where the newly created network would
appear as 'passthrough' in the UI until a page refresh
This patch set adds a new forward mode called 'passthrough' to
the 'macvtap' network.
Docs, model, test and UI changes included.
Daniel Henrique Barboza (3):
Adding 'passthrough' forward mode to Macvtap: doc changes
Adding 'passthrough' forward mode to Macvtap: model and test changes
Adding 'passthrough' forward mode to Macvtap: UI changes
API.json | 6 ++++++
docs/API.md | 1 +
i18n.py | 1 +
model/networks.py | 5 +++--
tests/test_networkxml.py | 14 ++++++++++++++
ui/js/src/kimchi.network.js | 1 +
ui/js/src/kimchi.network_add_main.js | 12 ++++++++++--
ui/pages/network-add.html.tmpl | 3 ++-
8 files changed, 38 insertions(+), 5 deletions(-)
--
2.5.5
Show replies by date
From: Daniel Henrique Barboza <danielhb(a)linux.vnet.ibm.com>
This patch makes changes in docs/API.md, API.json and i18n.py
to add a new forward mode in macvtap networks called 'passthrough'.
A new 'forward_mode' attribute was added. This attribute is optional
and it is only valid when connection is 'macvtap'. If not present,
the current default value 'bridge' for the forwarding mode of the
'macvtap' network is used.
Signed-off-by: Daniel Henrique Barboza <danielhb(a)linux.vnet.ibm.com>
---
API.json | 6 ++++++
docs/API.md | 1 +
i18n.py | 1 +
3 files changed, 8 insertions(+)
diff --git a/API.json b/API.json
index 40278bb..88b0b36 100644
--- a/API.json
+++ b/API.json
@@ -397,6 +397,12 @@
"maximum": 4094,
"minimum": 1,
"error": "KCHNET0015E"
+ },
+ "forward_mode": {
+ "description": "Forward mode for macvtap networks. If
not present, macvtap forward mode defaults to 'bridge'.",
+ "type": "string",
+ "pattern": "^bridge|passthrough$",
+ "error": "KCHNET0033E"
}
}
},
diff --git a/docs/API.md b/docs/API.md
index 83f9d38..9e5dc3e 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -701,6 +701,7 @@ A interface represents available interface on host.
For "macvtap" and "bridge"
connections, only
one interface will be allowed in this array.
* vlan_id *(optional)*: VLAN tagging ID for the macvtap bridge network.
+ * forward_mode *(optional)*: Forward mode for macvtap networks. Allowed values are
'bridge' and 'passthrough'. If not present, macvtap forward mode defaults
to 'bridge'.
### Resource: Network
diff --git a/i18n.py b/i18n.py
index cfbc81e..1774afe 100644
--- a/i18n.py
+++ b/i18n.py
@@ -282,6 +282,7 @@ messages = {
"KCHNET0030E": _("Only one interface is allowed for 'bridge'
and 'macvtap' networks."),
"KCHNET0031E": _("Subnet is not a valid parameter for this type of
virtual network."),
"KCHNET0032E": _("VLAN ID and interfaces are not valid parameters for
this type of virtual network."),
+ "KCHNET0033E": _("Invalid macvtap forward mode. Valid values:
'bridge' and 'passthrough'."),
"KCHSR0001E": _("Storage server %(server)s was not used by
Kimchi"),
--
2.5.5
From: Daniel Henrique Barboza <danielhb(a)linux.vnet.ibm.com>
Adding a new forward mode called 'passthrough' to macvtap
networks. New test included.
Signed-off-by: Daniel Henrique Barboza <danielhb(a)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
From: Daniel Henrique Barboza <danielhb(a)linux.vnet.ibm.com>
A new network type was added to distinguish between the
Macvtap forward modes 'bridge' and 'passthrough'.
Signed-off-by: Daniel Henrique Barboza <danielhb(a)linux.vnet.ibm.com>
---
ui/js/src/kimchi.network.js | 1 +
ui/js/src/kimchi.network_add_main.js | 12 ++++++++++--
ui/pages/network-add.html.tmpl | 3 ++-
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/ui/js/src/kimchi.network.js b/ui/js/src/kimchi.network.js
index d362010..3e8ed33 100644
--- a/ui/js/src/kimchi.network.js
+++ b/ui/js/src/kimchi.network.js
@@ -17,6 +17,7 @@
*/
kimchi.NETWORK_TYPE_MACVTAP = "macvtap";
+kimchi.NETWORK_TYPE_MACVTAP_PASSTHROUGH = "passthrough";
kimchi.NETWORK_TYPE_BRIDGED = "bridge";
kimchi.NETWORK_TYPE_VEPA = "vepa";
diff --git a/ui/js/src/kimchi.network_add_main.js b/ui/js/src/kimchi.network_add_main.js
index e12f1df..722acfc 100644
--- a/ui/js/src/kimchi.network_add_main.js
+++ b/ui/js/src/kimchi.network_add_main.js
@@ -38,6 +38,10 @@ kimchi.startNetworkCreation = function() {
// in VEPA connection case, network.interface is already an array
if (data.connection === kimchi.NETWORK_TYPE_VEPA) {
data.interfaces = network.interface;
+ } else if (data.connection === kimchi.NETWORK_TYPE_MACVTAP_PASSTHROUGH) {
+ network.type = 'macvtap';
+ data.connection = 'macvtap';
+ data.forward_mode = 'passthrough';
}
kimchi.createNetwork(data, function(result) {
@@ -86,7 +90,9 @@ kimchi.getNetworkDialogValues = function() {
name : $("#networkName").val(),
type : $("#networkType").val()
};
- if (network.type === kimchi.NETWORK_TYPE_MACVTAP || network.type ===
kimchi.NETWORK_TYPE_VEPA) {
+ if (network.type === kimchi.NETWORK_TYPE_MACVTAP ||
+ network.type === kimchi.NETWORK_TYPE_MACVTAP_PASSTHROUGH ||
+ network.type === kimchi.NETWORK_TYPE_VEPA) {
network.interface = $("#networkDestinationID").val();
}
if (network.type === kimchi.NETWORK_TYPE_BRIDGED) {
@@ -110,7 +116,9 @@ kimchi.setupNetworkFormEvent = function() {
$('#networkType').on('change', function() {
var selectedType = $("#networkType").val();
- if(selectedType === kimchi.NETWORK_TYPE_MACVTAP || selectedType ===
kimchi.NETWORK_TYPE_VEPA) {
+ if(selectedType === kimchi.NETWORK_TYPE_MACVTAP ||
+ selectedType === kimchi.NETWORK_TYPE_MACVTAP_PASSTHROUGH ||
+ selectedType === kimchi.NETWORK_TYPE_VEPA) {
if (selectedType === kimchi.NETWORK_TYPE_VEPA){
$('#networkDestinationID').attr('multiple', true);
if($('#networkDestinationID option').length > 10 ) {
diff --git a/ui/pages/network-add.html.tmpl b/ui/pages/network-add.html.tmpl
index 7a2fadb..4192c79 100644
--- a/ui/pages/network-add.html.tmpl
+++ b/ui/pages/network-add.html.tmpl
@@ -40,7 +40,8 @@
<select id="networkType" class="selectpicker col-md-12
col-lg-12">
<option value="isolated">$_("Isolated: no external
network connection")</option>
<option value="nat">$_("NAT: outbound physical
network connection only")</option>
- <option value="macvtap">$_("Macvtap: Virtual
machines are connected to physical network directly")</option>
+ <option value="macvtap">$_("Macvtap (bridged mode):
Virtual machines are connected to physical network directly")</option>
+ <option value="passthrough">$_("Macvtap (passthrough
mode): Network device will be passthrough to the virtual machines.")</option>
<option value="vepa">$_("VEPA: special mode where
virtual machines are connected to a VEPA-enabled switch")</option>
<option value="bridge">$_("Bridged: Virtual machines
are connected through a network bridge")</option>
</select>
--
2.5.5