[Kimchi-devel] [PATCH 2/3] support to change the network source of an active VM instance.

shaohef at linux.vnet.ibm.com shaohef at linux.vnet.ibm.com
Fri May 9 15:41:04 UTC 2014


From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>

This is a good feature to user.

Probe this feature, if libvirt support it then let kimchi support it.

Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
---
 src/kimchi/model/vmifaces.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/kimchi/model/vmifaces.py b/src/kimchi/model/vmifaces.py
index e377477..101dab1 100644
--- a/src/kimchi/model/vmifaces.py
+++ b/src/kimchi/model/vmifaces.py
@@ -24,6 +24,7 @@ from lxml import etree, objectify
 from lxml.builder import E
 
 from kimchi.exception import InvalidOperation, InvalidParameter, NotFoundError
+from kimchi.model.config import CapabilitiesModel
 from kimchi.model.vms import DOM_STATE_MAP, VMModel
 
 
@@ -137,11 +138,18 @@ class VMIfaceModel(object):
         if iface is None:
             raise NotFoundError("KCHVMIF0001E", {'name': vm, 'iface': mac})
 
-        # FIXME we will support to change the live VM configuration later.
+        # change on the active VM instance and persisted VM configuration.
         if iface.attrib['type'] == 'network' and 'network' in params:
             iface.source.attrib['network'] = params['network']
             xml = etree.tostring(iface)
-            dom.updateDeviceFlags(xml, flags=libvirt.VIR_DOMAIN_AFFECT_CONFIG)
+            if CapabilitiesModel().change_live_vm_network:
+                conf_flag = (libvirt.VIR_DOMAIN_AFFECT_CONFIG +
+                             libvirt.VIR_DOMAIN_AFFECT_LIVE if dom.isActive()
+                             and dom.isPersistent() else
+                             libvirt.VIR_DOMAIN_AFFECT_CURRENT)
+            else:
+                conf_flag = libvirt.VIR_DOMAIN_AFFECT_CONFIG
+            dom.updateDeviceFlags(xml, flags=conf_flag)
 
         # change on the persisted VM configuration only.
         if 'model' in params and dom.isPersistent():
-- 
1.9.0




More information about the Kimchi-devel mailing list