public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: David Huff <dhuff@redhat.com>
To: kvm@vger.kernel.org
Cc: David Huff <dhuff@redhat.com>
Subject: [PATCH kvm-autotest]  new test, saves and reloads a guest, from Red Hat QE
Date: Mon,  6 Apr 2009 15:41:03 -0400	[thread overview]
Message-ID: <1239046863-11939-2-git-send-email-dhuff@redhat.com> (raw)
In-Reply-To: <1239046863-11939-1-git-send-email-dhuff@redhat.com>

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


  reply	other threads:[~2009-04-06 19:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-06 19:41 kvm-autotest new test, save and load David Huff
2009-04-06 19:41 ` David Huff [this message]
2009-04-06 23:54 ` Charles Duffy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1239046863-11939-2-git-send-email-dhuff@redhat.com \
    --to=dhuff@redhat.com \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox