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

Deepti B. Kalakeri deeptik at linux.vnet.ibm.com
Thu Mar 12 10:32:19 UTC 2009


# HG changeset patch
# User Deepti B. Kalakeri <deeptik at linux.vnet.ibm.com>
# Date 1236853868 25200
# Node ID 89db4ac2378c90fd89845dd09836bfb39cc6e6ed
# Parent  caae383c83ec70e6cb6de9b6e5ccf6d2fcbecb45
[TEST][RFC] Added new tc to verify remote live migration.

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 caae383c83ec -r 89db4ac2378c suites/libvirt-cim/cimtest/VirtualSystemMigrationService/06_remote_migration.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/suites/libvirt-cim/cimtest/VirtualSystemMigrationService/06_remote_migration.py	Thu Mar 12 03:31:08 2009 -0700
@@ -0,0 +1,111 @@
+#!/usr/bin/python
+#
+# Copyright 2008 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
+import time
+import socket
+from XenKvmLib import vxml
+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, \
+                                   get_vs_mig_setting_class
+
+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:
+        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:
+        raise Exception("%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 = os.environ['SRC_IP']
+    t_sysname = os.environ['TARGET_IP']
+    if options.virt == 'KVM' and t_sysname == s_sysname:
+        logger.info("Libvirt does not support local migratoin for KVM")
+        return SKIP
+
+    status = FAIL
+    test_dom = 'VM_frm_' + socket.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
+        vsms_cn = get_vs_mig_setting_class(virt) 
+        vsmservice = vsms_cn(s_sysname, virt)
+        status = local_remote_migrate(vsmservice, s_sysname, t_sysname, virt,
+                                      remote_migrate=1, guest_name=test_dom)
+    except Exception,details:
+        logger.error("Exception details :%s", details)
+        cxml.cim_destroy(s_sysname)
+        cxml.undefine(s_sysname)
+        return FAIL
+
+    if status == PASS:
+        # Remote Migration Successful, clean the domain on target machine
+        cxml.cim_destroy(t_sysname)
+        cxml.undefine(t_sysname)
+    else:
+        # Remote Migration not Successful, clean the domain on src machine
+        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