From patchwork Wed Sep 9 18:12:03 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 46431 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 n89IFh4Y019155 for ; Wed, 9 Sep 2009 18:15:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753968AbZIISPi (ORCPT ); Wed, 9 Sep 2009 14:15:38 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753965AbZIISPg (ORCPT ); Wed, 9 Sep 2009 14:15:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58193 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753919AbZIISPf (ORCPT ); Wed, 9 Sep 2009 14:15:35 -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 n89IFcAU019917; Wed, 9 Sep 2009 14:15:38 -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 n89IFbqS015384; Wed, 9 Sep 2009 14:15:38 -0400 Received: from localhost.localdomain (dhcp-1-188.tlv.redhat.com [10.35.1.188]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n89IFNFV012008; Wed, 9 Sep 2009 14:15:36 -0400 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [PATCH 10/19] KVM test: boot test: add option to reboot using system_reset Date: Wed, 9 Sep 2009 21:12:03 +0300 Message-Id: <1252519932-30733-10-git-send-email-mgoldish@redhat.com> In-Reply-To: <1252519932-30733-9-git-send-email-mgoldish@redhat.com> References: <1252519932-30733-1-git-send-email-mgoldish@redhat.com> <1252519932-30733-2-git-send-email-mgoldish@redhat.com> <1252519932-30733-3-git-send-email-mgoldish@redhat.com> <1252519932-30733-4-git-send-email-mgoldish@redhat.com> <1252519932-30733-5-git-send-email-mgoldish@redhat.com> <1252519932-30733-6-git-send-email-mgoldish@redhat.com> <1252519932-30733-7-git-send-email-mgoldish@redhat.com> <1252519932-30733-8-git-send-email-mgoldish@redhat.com> <1252519932-30733-9-git-send-email-mgoldish@redhat.com> 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 The boot test now behaves as follows: - Normally it just waits for the guest to go up and logs into it. - If reboot_method is specified and equals "shell", the guest is sent a reboot shell command, and the test waits until the guest comes back up. - If reboot method is specified and equals "system_reset", the VM is sent a system_reset monitor command, and the test waits until the guest comes back up. Before sending the system_reset command the test sleeps for a given duration. The duration is controlled by the parameter 'sleep_before_reset'. Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_tests.cfg.sample | 8 +++++++- client/tests/kvm/kvm_tests.py | 32 ++++++++++++++++++++++---------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample index 73e929f..0703e64 100644 --- a/client/tests/kvm/kvm_tests.cfg.sample +++ b/client/tests/kvm/kvm_tests.cfg.sample @@ -58,7 +58,7 @@ variants: - reboot: install setup type = boot - reboot = yes + reboot_method = shell kill_vm_on_error = yes - migrate: install setup @@ -127,6 +127,12 @@ variants: - notepad: autoit_script = autoit/notepad1.au3 + - system_reset: install setup + type = boot + reboot_method = system_reset + sleep_before_reset = 20 + kill_vm_on_error = yes + - shutdown: install setup type = shutdown kill_vm = yes diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py index c2bfb8a..801b84e 100644 --- a/client/tests/kvm/kvm_tests.py +++ b/client/tests/kvm/kvm_tests.py @@ -13,9 +13,9 @@ def run_boot(test, params, env): """ KVM reboot test: 1) Log into a guest - 2) Send a reboot command to the guest - 3) Wait until it's up. - 4) Log into the guest to verify it's up again. + 2) Send a reboot command or a system_reset monitor command (optional) + 3) Wait until the guest is up again + 4) Log into the guest to verify it's up again @param test: kvm test object @param params: Dictionary with the test parameters @@ -33,13 +33,24 @@ def run_boot(test, params, env): if not session: raise error.TestFail("Could not log into guest") - logging.info("Logged in") - - if params.get("reboot") == "yes": - # Send the VM's reboot command - session.sendline(vm.get_params().get("reboot_command")) - logging.info("Reboot command sent; waiting for guest to go down...") + try: + logging.info("Logged in") + if params.get("reboot_method") == "shell": + # Send a reboot command to the guest's shell + session.sendline(vm.get_params().get("reboot_command")) + logging.info("Reboot command sent; waiting for guest to go " + "down...") + elif params.get("reboot_method") == "system_reset": + # Sleep for a while -- give the guest a chance to finish booting + time.sleep(float(params.get("sleep_before_reset", 10))) + # Send a system_reset monitor command + vm.send_monitor_cmd("system_reset") + logging.info("system_reset monitor command sent; waiting for " + "guest to go down...") + else: return + + # Wait for the session to become unresponsive if not kvm_utils.wait_for(lambda: not session.is_responsive(), 120, 0, 1): raise error.TestFail("Guest refuses to go down") @@ -54,7 +65,8 @@ def run_boot(test, params, env): logging.info("Guest is up again") - session.close() + finally: + session.close() def run_shutdown(test, params, env):