From patchwork Wed Oct 14 09:53:36 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 53633 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 n9EA0S75027886 for ; Wed, 14 Oct 2009 10:00:28 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932292AbZJNJyJ (ORCPT ); Wed, 14 Oct 2009 05:54:09 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932278AbZJNJyJ (ORCPT ); Wed, 14 Oct 2009 05:54:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14259 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932263AbZJNJyH (ORCPT ); Wed, 14 Oct 2009 05:54:07 -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 n9E9rfxv032761; Wed, 14 Oct 2009 05:53:41 -0400 Received: from localhost.localdomain (vpn-12-13.rdu.redhat.com [10.11.12.13]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9E9rcHM018961; Wed, 14 Oct 2009 05:53:39 -0400 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues , Ken Cao , Yolkfull Chow Subject: [PATCH] KVM test: Add a kvm subtest guest_s4 Date: Wed, 14 Oct 2009 06:53:36 -0300 Message-Id: <1255514016-8467-1-git-send-email-lmr@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 diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample index cc3228a..9ccc9b5 100644 --- a/client/tests/kvm/kvm_tests.cfg.sample +++ b/client/tests/kvm/kvm_tests.cfg.sample @@ -118,6 +118,15 @@ variants: - linux_s3: install setup type = linux_s3 + - guest_s4: + type = guest_s4 + check_s4_support_cmd = grep -q disk /sys/power/state + test_s4_cmd = "cd /tmp/;nohup tcpdump -q -t ip host localhost" + check_s4_cmd = pgrep tcpdump + set_s4_cmd = echo disk > /sys/power/state + kill_test_s4_cmd = pkill tcpdump + services_up_timeout = 30 + - timedrift: install setup extra_params += " -rtc-td-hack" variants: @@ -507,6 +516,13 @@ variants: # Alternative host load: #host_load_command = "dd if=/dev/urandom of=/dev/null" host_load_instances = 8 + guest_s4: + check_s4_support_cmd = powercfg /hibernate on + test_s4_cmd = start /B ping -n 3000 localhost + check_s4_cmd = tasklist | find /I "ping" + set_s4_cmd = rundll32.exe PowrProf.dll, SetSuspendState + kill_test_s4_cmd = taskkill /IM ping.exe /F + services_up_timeout = 30 nic_hotplug: reference_cmd = ipconfig /all find_pci_cmd = ipconfig /all | find "Description" diff --git a/client/tests/kvm/tests/guest_s4.py b/client/tests/kvm/tests/guest_s4.py new file mode 100644 index 0000000..7147e3b --- /dev/null +++ b/client/tests/kvm/tests/guest_s4.py @@ -0,0 +1,66 @@ +import logging, time +from autotest_lib.client.common_lib import error +import kvm_test_utils, kvm_utils + + +def run_guest_s4(test, params, env): + """ + Suspend guest to disk,supports both Linux & Windows OSes. + + @param test: kvm test object. + @param params: Dictionary with test parameters. + @param env: Dictionary with the test environment. + """ + vm = kvm_test_utils.get_living_vm(env, params.get("main_vm")) + session = kvm_test_utils.wait_for_login(vm) + + logging.info("Checking whether guest OS supports suspend to disk (S4)") + status = session.get_command_status(params.get("check_s4_support_cmd")) + if status is None: + logging.error("Failed to check if guest OS supports S4") + elif status != 0: + raise error.TestFail("Guest OS does not support S4") + + logging.info("Wait until all guest OS services are fully started") + time.sleep(params.get("services_up_timeout")) + + # Start up a program (tcpdump for linux & ping for Windows), as a flag. + # If the program died after suspend, then fails this testcase. + test_s4_cmd = params.get("test_s4_cmd") + session.sendline(test_s4_cmd) + + # Get the second session to start S4 + session2 = kvm_test_utils.wait_for_login(vm) + + check_s4_cmd = params.get("check_s4_cmd") + if session2.get_command_status(check_s4_cmd): + raise error.TestError("Failed to launch '%s' as a background process" % + test_s4_cmd) + logging.info("Launched background command in guest: %s" % test_s4_cmd) + + # Suspend to disk + logging.info("Start suspend to disk now...") + session2.sendline(params.get("set_s4_cmd")) + + if not kvm_utils.wait_for(vm.is_dead, 360, 30, 2): + raise error.TestFail("VM refuses to go down. Suspend failed") + logging.info("VM suspended successfully. Wait before booting it again.") + time.sleep(10) + + # Start vm, and check whether the program is still running + logging.info("Start suspended VM...") + + if not vm.create(): + raise error.TestError("Failed to start VM after suspend to disk") + if not vm.is_alive(): + raise error.TestError("VM seems to be dead after it was suspended") + + # Check whether test command still alive + logging.info("Checking if background command is still alive") + if session2.get_command_status(check_s4_cmd): + raise error.TestFail("Command %s failed. S4 failed" % test_s4_cmd) + + logging.info("VM resumed successfuly after suspend to disk") + session2.sendline(params.get("kill_test_s4_cmd")) + session.close() + session2.close()