From patchwork Wed Sep 9 18:12:04 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 46432 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 n89IFjxQ019166 for ; Wed, 9 Sep 2009 18:15:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753972AbZIISPj (ORCPT ); Wed, 9 Sep 2009 14:15:39 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753965AbZIISPi (ORCPT ); Wed, 9 Sep 2009 14:15:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39252 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753966AbZIISPg (ORCPT ); Wed, 9 Sep 2009 14:15:36 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n89IFdi2019342; Wed, 9 Sep 2009 14:15:39 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n89IFdbi014418; Wed, 9 Sep 2009 14:15:39 -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 n89IFNFW012008; Wed, 9 Sep 2009 14:15:38 -0400 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [PATCH 11/19] KVM test: shutdown test: allow shutting down using system_powerdown Date: Wed, 9 Sep 2009 21:12:04 +0300 Message-Id: <1252519932-30733-11-git-send-email-mgoldish@redhat.com> In-Reply-To: <1252519932-30733-10-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> <1252519932-30733-10-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org In addition to using the shutdown command/program, allow using the system_powerdown monitor command. The behavior is controlled using the shutdown_method parameter, which may equal either "shell" or "system_powerdown". If shutdown_method equals "system_powerdown", the test sleeps a given amount of time (controlled by the parameter sleep_before_powerdown) and then sends the system_powerdown monitor command. Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_tests.cfg.sample | 8 ++++++++ client/tests/kvm/kvm_tests.py | 22 ++++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample index 0703e64..201b0e1 100644 --- a/client/tests/kvm/kvm_tests.cfg.sample +++ b/client/tests/kvm/kvm_tests.cfg.sample @@ -133,8 +133,16 @@ variants: sleep_before_reset = 20 kill_vm_on_error = yes + - system_powerdown: install setup + type = shutdown + shutdown_method = system_powerdown + sleep_before_powerdown = 20 + kill_vm = yes + kill_vm_gracefully = no + - shutdown: install setup type = shutdown + shutdown_method = shell kill_vm = yes kill_vm_gracefully = no diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py index 801b84e..863b863 100644 --- a/client/tests/kvm/kvm_tests.py +++ b/client/tests/kvm/kvm_tests.py @@ -73,8 +73,9 @@ def run_shutdown(test, params, env): """ KVM shutdown test: 1) Log into a guest - 2) Send a shutdown command to the guest - 3) Wait until it's down + 2) Send a shutdown command to the guest, or issue a system_powerdown + monitor command (depending on the value of shutdown_method) + 3) Wait until the guest is down @param test: kvm test object @param params: Dictionary with the test parameters @@ -95,15 +96,24 @@ def run_shutdown(test, params, env): try: logging.info("Logged in") - # Send the VM's shutdown command - session.sendline(vm.get_params().get("shutdown_command")) - - logging.info("Shutdown command sent; waiting for guest to go down...") + if params.get("shutdown_method") == "shell": + # Send a shutdown command to the guest's shell + session.sendline(vm.get_params().get("shutdown_command")) + logging.info("Shutdown command sent; waiting for guest to go " + "down...") + elif params.get("shutdown_method") == "system_powerdown": + # Sleep for a while -- give the guest a chance to finish booting + time.sleep(float(params.get("sleep_before_powerdown", 10))) + # Send a system_powerdown monitor command + vm.send_monitor_cmd("system_powerdown") + logging.info("system_powerdown monitor command sent; waiting for " + "guest to go down...") if not kvm_utils.wait_for(vm.is_dead, 240, 0, 1): raise error.TestFail("Guest refuses to go down") logging.info("Guest is down") + finally: session.close()