From patchwork Mon Apr 6 19:41:03 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Huff X-Patchwork-Id: 16628 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n36JflYD002827 for ; Mon, 6 Apr 2009 19:41:47 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756993AbZDFTlc (ORCPT ); Mon, 6 Apr 2009 15:41:32 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757502AbZDFTlb (ORCPT ); Mon, 6 Apr 2009 15:41:31 -0400 Received: from mx2.redhat.com ([66.187.237.31]:37282 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756827AbZDFTl2 (ORCPT ); Mon, 6 Apr 2009 15:41:28 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n36JfR5V001597 for ; Mon, 6 Apr 2009 15:41:27 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n36JfRhG002591; Mon, 6 Apr 2009 15:41:28 -0400 Received: from localhost.localdomain (dhcp231-89.rdu.redhat.com [10.11.231.89]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n36JfQFf028999; Mon, 6 Apr 2009 15:41:26 -0400 From: David Huff To: kvm@vger.kernel.org Cc: David Huff Subject: [PATCH kvm-autotest] new test, saves and reloads a guest, from Red Hat QE Date: Mon, 6 Apr 2009 15:41:03 -0400 Message-Id: <1239046863-11939-2-git-send-email-dhuff@redhat.com> In-Reply-To: <1239046863-11939-1-git-send-email-dhuff@redhat.com> References: <1239046863-11939-1-git-send-email-dhuff@redhat.com> X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org --- 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()