From patchwork Thu Apr 15 19:09:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 92816 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o3FJADf2008278 for ; Thu, 15 Apr 2010 19:10:13 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756123Ab0DOTJt (ORCPT ); Thu, 15 Apr 2010 15:09:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41978 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755843Ab0DOTJs (ORCPT ); Thu, 15 Apr 2010 15:09:48 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o3FJ9lkv001339 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 15 Apr 2010 15:09:47 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o3FJ9lwf009483; Thu, 15 Apr 2010 15:09:47 -0400 Received: from amt.cnet (vpn-10-211.rdu.redhat.com [10.11.10.211]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o3FJ9kKA004468; Thu, 15 Apr 2010 15:09:46 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id B266868A0C7; Thu, 15 Apr 2010 16:09:41 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id o3FJ9eAs005404; Thu, 15 Apr 2010 16:09:40 -0300 Date: Thu, 15 Apr 2010 16:09:40 -0300 From: Marcelo Tosatti To: Lucas Meneghel Rodrigues Cc: kvm Subject: KVM autotest: add boot_savevm test Message-ID: <20100415190940.GA5303@amt.cnet> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-08-17) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 15 Apr 2010 19:10:15 +0000 (UTC) Index: autotest/client/tests/kvm/tests/boot_savevm.py =================================================================== --- /dev/null +++ autotest/client/tests/kvm/tests/boot_savevm.py @@ -0,0 +1,54 @@ +import logging, time +from autotest_lib.client.common_lib import error +import kvm_subprocess, kvm_test_utils, kvm_utils + +def run_boot_savevm(test, params, env): + """ + KVM boot savevm test: + 1) Start guest + 2) Periodically savevm/loadvm + 4) Log into the guest to verify it's up, fail after timeout seconds + + @param test: kvm test object + @param params: Dictionary with the test parameters + @param env: Dictionary with test environment. + """ + vm = kvm_test_utils.get_living_vm(env, params.get("main_vm")) + savevm_delay = float(params.get("savevm_delay")) + savevm_login_delay = float(params.get("savevm_login_delay")) + logging.info("savevm_delay = %f" % savevm_delay) + login_expire = time.time() + savevm_login_delay + end_time = time.time() + float(params.get("savevm_timeout")) + + while time.time() < end_time: + time.sleep(savevm_delay) + + s, o = vm.send_monitor_cmd("stop") + if s: + logging.error("stop failed: %r" % o) + s, o = vm.send_monitor_cmd("savevm 1") + if s: + logging.error("savevm failed: %r" % o) + s, o = vm.send_monitor_cmd("system_reset") + if s: + logging.error("system_reset: %r" % o) + s, o = vm.send_monitor_cmd("loadvm 1") + if s: + logging.error("loadvm failed: %r" % o) + s, o = vm.send_monitor_cmd("cont") + if s: + logging.error("cont failed: %r" % o) + + # Log in + if (time.time() > login_expire): + login_expire = time.time() + savevm_login_delay + logging.info("Logging in after loadvm...") + session = kvm_utils.wait_for(vm.remote_login, 1, 0, 1) + if not session: + logging.info("Failed to login") + else: + logging.info("Logged in to guest!") + break + + if (time.time() > end_time): + raise error.TestFail("fail: timeout") Index: autotest/client/tests/kvm/tests_base.cfg.sample =================================================================== --- autotest.orig/client/tests/kvm/tests_base.cfg.sample +++ autotest/client/tests/kvm/tests_base.cfg.sample @@ -105,6 +105,15 @@ variants: iterations = 2 used_mem = 1024 + - boot_savevm: install setup unattended_install + type = boot_savevm + savevm_delay = 0.3 + savevm_login_delay = 120 + savevm_timeout = 2000 + kill_vm_on_error = yes + kill_vm_gracefully = yes + kill_vm = yes + - autotest: install setup unattended_install type = autotest test_timeout = 1800