[KVM-AUTOTEST PATCH 05/28] KVM test: vmstop: use kvm_utils.Thread

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

 



Signed-off-by: Michael Goldish <mgoldish@xxxxxxxxxx>
---
 client/tests/kvm/tests/vmstop.py |   61 ++++++++++++++++++-------------------
 1 files changed, 30 insertions(+), 31 deletions(-)

diff --git a/client/tests/kvm/tests/vmstop.py b/client/tests/kvm/tests/vmstop.py
index 703c881..876c3ef 100644
--- a/client/tests/kvm/tests/vmstop.py
+++ b/client/tests/kvm/tests/vmstop.py
@@ -29,55 +29,54 @@ def run_vmstop(test, params, env):
 
     guest_path = params.get("guest_path", "/tmp")
     file_size = params.get("file_size", "1000")
-    bg = None
 
     try:
         utils.run("dd if=/dev/zero of=/tmp/file bs=1M count=%s" % file_size)
         # Transfer file from host to guest, we didn't expect the finish of
         # transfer, we just let it to be a kind of stress in guest.
-        bg = kvm_test_utils.BackgroundTest(vm.copy_files_to,
-                                           ("/tmp/file", guest_path,
-                                            0, 60))
+        bg = kvm_utils.Thread(vm.copy_files_to, ("/tmp/file",
+                                                 guest_path, 0, 60))
         logging.info("Start the background transfer")
         bg.start()
 
-        # wait for the transfer start
-        time.sleep(5)
-        logging.info("Stop the VM")
-        vm.monitor.cmd("stop")
+        try:
+            # wait for the transfer start
+            time.sleep(5)
+            logging.info("Stop the VM")
+            vm.monitor.cmd("stop")
 
-        # check with monitor
-        logging.info("Check the status through monitor")
-        if "paused" not in vm.monitor.info("status"):
-            raise error.TestFail("Guest did not pause after sending stop")
+            # check with monitor
+            logging.info("Check the status through monitor")
+            if "paused" not in vm.monitor.info("status"):
+                raise error.TestFail("Guest did not pause after sending stop")
 
-        # check through session
-        logging.info("Check the session")
-        if session.is_responsive():
-            raise error.TestFail("Session still alive after sending stop")
+            # check through session
+            logging.info("Check the session")
+            if session.is_responsive():
+                raise error.TestFail("Session still alive after sending stop")
 
-        # Check with the migration file
-        logging.info("Save and check the state files")
-        for p in [save1, save2]:
-            vm.save_to_file(p)
-            time.sleep(1)
-            if not os.path.isfile(p):
-                raise error.TestFail("VM failed to save state file %s" % p)
+            # Check with the migration file
+            logging.info("Save and check the state files")
+            for p in [save1, save2]:
+                vm.save_to_file(p)
+                time.sleep(1)
+                if not os.path.isfile(p):
+                    raise error.TestFail("VM failed to save state file %s" % p)
 
-        # Fail if we see deltas
-        md5_save1 = utils.hash_file(save1)
-        md5_save2 = utils.hash_file(save2)
-        if md5_save1 != md5_save2:
-            raise error.TestFail("The produced state files differ")
+            # Fail if we see deltas
+            md5_save1 = utils.hash_file(save1)
+            md5_save2 = utils.hash_file(save2)
+            if md5_save1 != md5_save2:
+                raise error.TestFail("The produced state files differ")
+        finally:
+            bg.join()
 
     finally:
+        session.close()
         if clean_save:
             logging.debug("Clean the state files")
             if os.path.isfile(save1):
                 os.remove(save1)
             if os.path.isfile(save2):
                 os.remove(save2)
-        if bg:
-            bg.join()
         vm.monitor.cmd("cont")
-        session.close()
-- 
1.7.3.3

--
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