[PATCH 2/3] KVM test: Test reboot during migration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This test is simple: it's doing the migration and guest rebooting in the same
time and then check the completion of migration and verify the guest state by
loggin it again after reboot.

Signed-off-by: Jason Wang <jasowang@xxxxxxxxxx>
---
 client/tests/kvm/tests/migration_with_reboot.py |   45 +++++++++++++++++++++++
 client/tests/kvm/tests_base.cfg.sample          |    5 +++
 2 files changed, 50 insertions(+), 0 deletions(-)
 create mode 100644 client/tests/kvm/tests/migration_with_reboot.py

diff --git a/client/tests/kvm/tests/migration_with_reboot.py b/client/tests/kvm/tests/migration_with_reboot.py
new file mode 100644
index 0000000..985cb3a
--- /dev/null
+++ b/client/tests/kvm/tests/migration_with_reboot.py
@@ -0,0 +1,45 @@
+import logging, time
+import threading
+from autotest_lib.client.common_lib import error
+import kvm_subprocess, kvm_test_utils, kvm_utils
+
+
+def run_migration_with_reboot(test, params, env):
+    """
+    KVM migration test:
+    1) Get a live VM and clone it.
+    2) Verify that the source VM supports migration.  If it does, proceed with
+            the test.
+    3) Reboot the VM
+    4) Send a migration command to the source VM and wait until it's finished.
+    5) Kill off the source VM.
+    6) Log into the destination VM after the migration is finished.
+
+    @param test: kvm test object.
+    @param params: Dictionary with test parameters.
+    @param env: Dictionary with the test environment.
+    """
+    vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
+    timeout = int(params.get("login_timeout", 360))
+    session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
+
+    mig_timeout = float(params.get("mig_timeout", "3600"))
+    mig_protocol = params.get("migration_protocol", "tcp")
+    mig_cancel = bool(params.get("mig_cancel"))
+    bg = None
+
+    try:
+        # reboot the VM in background
+        bg = kvm_test_utils.BackgroundTest(kvm_test_utils.reboot, (vm, session))
+        bg.start()
+
+        while bg.is_alive():
+            # Migrate the VM
+            dest_vm = kvm_test_utils.migrate(vm, env, mig_timeout, mig_protocol,
+                                             False)
+            vm = dest_vm
+
+    finally:
+        if bg:
+            bg.join()
+        session.close()
diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
index c8fbf50..1565dce 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -150,6 +150,11 @@ variants:
             - mig_cancel:
                 migration_protocol = "tcp"
                 mig_cancel = True
+        variants:
+            - @default:
+            - with_reboot:
+                iterations = 1
+                type = migration_with_reboot
 
     - boot_savevm: install setup unattended_install.cdrom
         type = boot_savevm

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux