kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* kvm-autotest new test, save and load
@ 2009-04-06 19:41 David Huff
  2009-04-06 19:41 ` [PATCH kvm-autotest] new test, saves and reloads a guest, from Red Hat QE David Huff
  2009-04-06 23:54 ` kvm-autotest new test, save and load Charles Duffy
  0 siblings, 2 replies; 3+ messages in thread
From: David Huff @ 2009-04-06 19:41 UTC (permalink / raw)
  To: kvm


Submitting new test for review and comments. 
This test was originally developed by the Red Hat QE team. 
It starts a new guest saves it and reloads the saved state.  

looking for comments and or improvements that can be made to this test.

-D

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH kvm-autotest]  new test, saves and reloads a guest, from Red Hat QE
  2009-04-06 19:41 kvm-autotest new test, save and load David Huff
@ 2009-04-06 19:41 ` David Huff
  2009-04-06 23:54 ` kvm-autotest new test, save and load Charles Duffy
  1 sibling, 0 replies; 3+ messages in thread
From: David Huff @ 2009-04-06 19:41 UTC (permalink / raw)
  To: kvm; +Cc: David Huff

---
 client/tests/kvm_runtest_2/kvm_runtest_2.py     |    1 +
 client/tests/kvm_runtest_2/kvm_tests.cfg.sample |    6 ++
 client/tests/kvm_runtest_2/kvm_tests.py         |   97 +++++++++++++++++++++++
 3 files changed, 104 insertions(+), 0 deletions(-)

diff --git a/client/tests/kvm_runtest_2/kvm_runtest_2.py b/client/tests/kvm_runtest_2/kvm_runtest_2.py
index c53877f..c83dce9 100644
--- a/client/tests/kvm_runtest_2/kvm_runtest_2.py
+++ b/client/tests/kvm_runtest_2/kvm_runtest_2.py
@@ -34,6 +34,7 @@ class kvm_runtest_2(test.test):
                 "migration":    test_routine("kvm_tests",           "run_migration"),
                 "yum_update":   test_routine("kvm_tests",           "run_yum_update"),
                 "autotest":     test_routine("kvm_tests",           "run_autotest"),
+                "saveload":     test_routine("kvm_tests",           "run_save_load"),
                 "kvm_install":  test_routine("kvm_install",         "run_kvm_install"),
                 "linux_s3":     test_routine("kvm_tests",           "run_linux_s3"),
                 }
diff --git a/client/tests/kvm_runtest_2/kvm_tests.cfg.sample b/client/tests/kvm_runtest_2/kvm_tests.cfg.sample
index 5619fa8..869398a 100644
--- a/client/tests/kvm_runtest_2/kvm_tests.cfg.sample
+++ b/client/tests/kvm_runtest_2/kvm_tests.cfg.sample
@@ -48,6 +48,12 @@ variants:
         reboot = yes
         extra_params += " -snapshot"
         kill_vm_on_error = yes
+        
+    - saveload:	install
+    	type = saveload
+		pre_command = "if [ -f kvm_save_test_file ] ; then rm -rf kvm_save_test_file; fi"
+		do_command  = "touch kvm_save_test_file
+		verify_command = "[ -f kvm_save_test_file ]"
 
     - migrate:      install setup
         type = migration
diff --git a/client/tests/kvm_runtest_2/kvm_tests.py b/client/tests/kvm_runtest_2/kvm_tests.py
index 0d19af6..463cc84 100644
--- a/client/tests/kvm_runtest_2/kvm_tests.py
+++ b/client/tests/kvm_runtest_2/kvm_tests.py
@@ -449,3 +449,100 @@ def run_linux_s3(test, params, env):
     kvm_log.info("VM resumed after S3")
 
     session.close()
+    
+def run_save_load(test, params, env):
+    # state testing, save and load vm state
+    vm = kvm_utils.env_get_vm(env, params.get("main_vm"))
+    if not vm:
+        message = "VM object not found in environment"
+        kvm_log.error(message)
+        raise error.TestError, message
+    if not vm.is_alive():
+        message = "VM seems to be dead; Test requires a living VM"
+        kvm_log.error(message)
+        raise error.TestError, message
+
+    kvm_log.info("Waiting for guest to be up...")
+
+    pxssh = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
+    if not pxssh:
+        message = "Could not log into guest"
+        kvm_log.error(message)
+        raise error.TestFail, message
+
+    pre_command=params.get("pre_command")
+    do_command=params.get("do_command")
+    verify_command=params.get("verify_command")
+
+    # do preparation
+    kvm_log.info("Logged in")
+    kvm_log.info("Doing preparation ... %s" % pre_command)
+    if not pxssh.send_command(pre_command):
+        message = "%s failed" % pre_command
+        kvm_log.error(message)
+        raise error.TestFail, message
+    pxssh.close()
+    kvm_log.info("Logged out")
+
+    # save state
+    kvm_log.info("Saving VM state ...")
+    vm.send_monitor_cmd('savevm test1')
+    s, o = vm.send_monitor_cmd('info snapshots')
+    if not 'test1' in o:
+        message = "Saveing VM state error %s" % o
+        kvm_log.error(message)
+        raise error.TestFail, message
+    kvm_log.info(o)
+    kvm_log.info("VM state saved")
+
+    kvm_log.info("Destroying VM ...")
+    vm.destroy();
+    kvm_log.info("VM Destroyed")
+    
+    kvm_log.info("Booting VM...")
+    if not vm.create():
+        message = "Could no recreate VM instance"
+        kvm_log.error(message)
+        raise error.TestError, message
+    kvm_log.info("VM recreated")    
+
+    # do modification
+    pxssh = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
+    if not pxssh:
+        message = "Could not log into guest"
+        kvm_log.error(message)
+        raise error.TestFail, message
+    kvm_log.info("Logged in")
+    kvm_log.info("Doing modification %s" % do_command)
+    if not pxssh.send_command(do_command):
+        message = "%s failed" % do_command
+        kvm_log.error(message)
+        raise error.TestFail, message
+    pxssh.close()
+    kvm_log.info("Logged out")
+    
+    # load state
+    kvm_log.info("Loading VM state ...")
+    s, o = vm.send_monitor_cmd('loadvm test1')
+    kvm_log.info(o)
+    if "Error" in o:
+        message = "VM state load failed: %s" % o
+        kvm_log.error(message)
+        raise error.TestFail, message
+    kvm_log.info("VM state loaded")
+
+    # verify the status
+    pxssh = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
+    if not pxssh:
+        message = "Could not log into guest"
+        kvm_log.error(message)
+        raise error.TestFail, message
+    kvm_log.info("Verifying ... %s" % verify_command)
+    if pxssh.send_command(verify_command):
+        message = "Loaded state does not match previous saved one"
+        kvm_log.error(message)
+        raise error.TestFail, message
+
+    vm.send_command("delvm test1")
+    
+    pxssh.close()
-- 
1.6.0.6


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: kvm-autotest new test, save and load
  2009-04-06 19:41 kvm-autotest new test, save and load David Huff
  2009-04-06 19:41 ` [PATCH kvm-autotest] new test, saves and reloads a guest, from Red Hat QE David Huff
@ 2009-04-06 23:54 ` Charles Duffy
  1 sibling, 0 replies; 3+ messages in thread
From: Charles Duffy @ 2009-04-06 23:54 UTC (permalink / raw)
  To: kvm

David Huff wrote:
> Submitting new test for review and comments. 
> This test was originally developed by the Red Hat QE team. 
> It starts a new guest saves it and reloads the saved state.  
> 
> looking for comments and or improvements that can be made to this test.

I have some code (aimed at testing software within the guest, rather 
than kvm itself) which does this kind of operation quite frequently; the 
most common case where I've seen failures happen is when writes are 
active while state is being saved.

One enhancement might be to test the integrity of block device writes 
being done during the save/restore process itself -- for instance, write 
a file of all high bits, start a process overwriting it with all low 
bits, run the save and restore before the latter process has completed, 
and ensure that after the migration is complete and the process has 
finished, the file contains nothing but 0s.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-04-06 23:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-06 19:41 kvm-autotest new test, save and load David Huff
2009-04-06 19:41 ` [PATCH kvm-autotest] new test, saves and reloads a guest, from Red Hat QE David Huff
2009-04-06 23:54 ` kvm-autotest new test, save and load Charles Duffy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).