[Libvirt-cim] [PATCH 4 of 4] [TEST][RFC] #2 Added new tc to verify remote live migration

Deepti B. Kalakeri deeptik at linux.vnet.ibm.com
Mon Mar 16 07:27:21 UTC 2009


# HG changeset patch
# User Deepti B. Kalakeri <deeptik at linux.vnet.ibm.com>
# Date 1237188257 25200
# Node ID 8a282c8879a9986c2bdde0238a4307ea3378ee4b
# Parent  c272bb5f4c9fcbceb6e70d0b5a0cd0ea40359e72
[TEST][RFC] #2 Added new tc to verify remote live migration.

Updates:
--------
Patch 2:
-------
1) Moved the VSMS object creation to vsmigration.py local_remote_migrate() fn.
2) Added check for domains on src and target, Undefined & destoryed domain on src and target
   depending on their existence.

Verified with KVM.
The test case will not pass for KVM since the guest information needs to have emulator
information without which the remote migration fails.
The support to pass the emulator information via VirtualSystemMigrationSettingData is
not yet available.

Signed-off-by: Deepti B. Kalakeri <deeptik at linux.vnet.ibm.com>

diff -r c272bb5f4c9f -r 8a282c8879a9 suites/libvirt-cim/cimtest/VirtualSystemMigrationService/06_remote_live_migration.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/suites/libvirt-cim/cimtest/VirtualSystemMigrationService/06_remote_live_migration.py	Mon Mar 16 00:24:17 2009 -0700
@@ -0,0 +1,116 @@
+#!/usr/bin/python
+#
+# Copyright 2009 IBM Corp.
+#
+# Authors:
+#   Deepti B. Kalakeri <deeptik at linux.vnet.ibm.com> 
+#    
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+#
+#
+# This testcase is used to verify the live remote migration.
+#
+#                                                      Date :  12-03-09
+#
+
+import sys
+import os
+from  socket import gethostname, gethostbyaddr
+from XenKvmLib import vxml
+from XenKvmLib.xm_virt_util import domain_list
+from XenKvmLib.common_util import poll_for_state_change
+from CimTest.Globals import logger
+from XenKvmLib.const import do_main
+from CimTest.ReturnCodes import PASS, FAIL, SKIP
+from XenKvmLib.classes import get_typed_class
+from XenKvmLib.vsmigrations import local_remote_migrate
+
+sup_types = ['KVM', 'Xen']
+
+REQUESTED_STATE = 2
+
+def setup_guest(test_dom, ip, virt):
+    virt_xml = vxml.get_class(virt)
+    cxml = virt_xml(test_dom)
+    ret = cxml.cim_define(ip)
+    if not ret:
+        logger.error("Error define domain %s", test_dom)
+        return FAIL, cxml
+
+    status = cxml.cim_start(ip)
+    if status != PASS:
+        cxml.undefine(test_dom)
+        logger.error("Error to start domain %s", test_dom)
+        return FAIL, cxml
+
+    status, dom_cs = poll_for_state_change(ip, virt, test_dom,
+                                           REQUESTED_STATE)
+    if status != PASS:
+        cxml.cim_destroy(test_dom)
+        cxml.undefine(test_dom)
+        logger.error("'%s' didn't change state as expected" % test_dom)
+        return FAIL, cxml
+
+    return PASS, cxml
+
+ at do_main(sup_types)
+def main():
+    options = main.options
+    virt = options.virt
+    s_sysname = gethostbyaddr(options.ip)[0]
+    t_sysname = gethostbyaddr(options.t_url)[0] 
+    if options.virt == 'KVM' and (t_sysname == s_sysname or \
+       t_sysname in s_sysname):
+        logger.info("Libvirt does not support local migratoin for KVM")
+        return SKIP
+
+    status = FAIL
+    test_dom = 'VM_frm_' + gethostname()
+
+    try:
+        status, cxml = setup_guest(test_dom, s_sysname, virt)
+        if status != PASS:
+            logger.error("Error setting up the guest")
+            return status
+
+        # Migrate the test_dom to t_sysname.
+        # local_remote_migrate executes live migration by default
+        # Enable remote migration by setting remote_migrate=1
+        status = local_remote_migrate(s_sysname, t_sysname, virt,
+                                      remote_migrate=1, guest_name=test_dom)
+    except Exception, details:
+        logger.error("Exception details :%s", details)
+        status = FAIL
+
+    # Clean the domain on target machine.
+    # This req when migration is successful, also when migration is not
+    # completely successful VM might be created on the target machine 
+    # and hence need to clean.
+    target_list = domain_list(t_sysname, virt)
+    if target_list  != None and test_dom in target_list:
+        cxml.cim_destroy(t_sysname)
+        cxml.undefine(t_sysname)
+
+    # Remote Migration not Successful, clean the domain on src machine
+    src_list = domain_list(s_sysname, virt)
+    if src_list != None and test_dom in src_list:
+        cxml.cim_destroy(s_sysname)
+        cxml.undefine(s_sysname)
+
+    return status
+
+if __name__ == "__main__":
+    sys.exit(main())




More information about the Libvirt-cim mailing list