[Kimchi-devel] [PATCH] issue #491: Check model parameter exists when generating the interface XML
Aline Manera
alinefm at linux.vnet.ibm.com
Fri Dec 5 14:10:14 UTC 2014
When interface model is not explicitly set on interface XML, libvirt
automaticaly sets the default value.
Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
---
src/kimchi/xmlutils/interface.py | 4 +++-
tests/test_model.py | 10 ++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/kimchi/xmlutils/interface.py b/src/kimchi/xmlutils/interface.py
index c76131a..7b79584 100644
--- a/src/kimchi/xmlutils/interface.py
+++ b/src/kimchi/xmlutils/interface.py
@@ -32,7 +32,9 @@ def get_iface_xml(params, arch=None, os_distro=None, os_version=None):
"""
interface = E.interface(type=params['type'])
interface.append(E.source(network=params['network']))
- interface.append(E.model(type=params['model']))
+
+ if 'model' in params.keys():
+ interface.append(E.model(type=params['model']))
mac = params.get('mac', None)
if mac is not None:
diff --git a/tests/test_model.py b/tests/test_model.py
index 9a4fc0f..aa2a1bb 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -298,6 +298,16 @@ class ModelTests(unittest.TestCase):
self.assertEquals("test-network", iface['network'])
self.assertEquals("virtio", iface["model"])
+ # attach network interface to vm without providing model
+ iface_args = {"type": "network",
+ "network": "test-network"}
+ mac = inst.vmifaces_create('kimchi-ifaces', iface_args)
+ rollback.prependDefer(inst.vmiface_delete, 'kimchi-ifaces', mac)
+
+ iface = inst.vmiface_lookup('kimchi-ifaces', mac)
+ self.assertEquals("network", iface["type"])
+ self.assertEquals("test-network", iface['network'])
+
# update vm interface
iface_args = {"network": "default",
"model": "e1000"}
--
1.9.3
More information about the Kimchi-devel
mailing list