From patchwork Fri Apr 9 09:10:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: pradeep kumar X-Patchwork-Id: 91667 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 o399AaxY009731 for ; Fri, 9 Apr 2010 09:10:36 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755115Ab0DIJKe (ORCPT ); Fri, 9 Apr 2010 05:10:34 -0400 Received: from e4.ny.us.ibm.com ([32.97.182.144]:49137 "EHLO e4.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754478Ab0DIJKd (ORCPT ); Fri, 9 Apr 2010 05:10:33 -0400 Received: from d01relay03.pok.ibm.com (d01relay03.pok.ibm.com [9.56.227.235]) by e4.ny.us.ibm.com (8.14.3/8.13.1) with ESMTP id o398wn6E012611 for ; Fri, 9 Apr 2010 04:58:49 -0400 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay03.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o399AW8M138496 for ; Fri, 9 Apr 2010 05:10:32 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id o399AVDv008453 for ; Fri, 9 Apr 2010 06:10:32 -0300 Received: from [9.124.158.31] (skywalker-laptop.in.ibm.com [9.124.158.31] (may be forged)) by d01av02.pok.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id o399AU7B008425; Fri, 9 Apr 2010 06:10:30 -0300 Message-ID: <4BBEEF05.5080809@linux.vnet.ibm.com> Date: Fri, 09 Apr 2010 14:40:29 +0530 From: pradeep User-Agent: Thunderbird 2.0.0.24 (X11/20100317) MIME-Version: 1.0 To: Lucas Meneghel Rodrigues , autotest@test.kernel.org, kvm@vger.kernel.org Subject: Re: [Autotest] [PATCH] KVM test: Memory ballooning test for KVM guest References: <4B743E97.4040102@linux.vnet.ibm.com> <1265913451.2299.26.camel@localhost.localdomain> In-Reply-To: <1265913451.2299.26.camel@localhost.localdomain> 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]); Fri, 09 Apr 2010 09:11:05 +0000 (UTC) diff -uprN autotest-old/client/tests/kvm/tests/balloon_check.py autotest/client/tests/kvm/tests/balloon_check.py --- autotest-old/client/tests/kvm/tests/balloon_check.py 1969-12-31 19:00:00.000000000 -0500 +++ autotest/client/tests/kvm/tests/balloon_check.py 2010-04-09 12:33:34.000000000 -0400 @@ -0,0 +1,47 @@ +import re, string, logging, random, time +from autotest_lib.client.common_lib import error +import kvm_test_utils, kvm_utils + +def run_balloon_check(test, params, env): + """ + Check Memory ballooning: + 1) Boot a guest + 2) Increase and decrease the memory of guest using balloon command from monitor + 3) check memory info + + @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")) + session = kvm_test_utils.wait_for_login(vm) + fail = 0 + + # Check memory size + logging.info("Memory size check") + expected_mem = int(params.get("mem")) + actual_mem = vm.get_memory_size() + if actual_mem != expected_mem: + logging.error("Memory size mismatch:") + logging.error("Assigned to VM: %s" % expected_mem) + logging.error("Reported by OS: %s" % actual_mem) + + #change memory to random size between 60% to 95% of actual memory + percent = random.uniform(0.6, 0.95) + new_mem = int(percent*expected_mem) + vm.send_monitor_cmd("balloon %s" %new_mem) + time.sleep(20) + status, output = vm.send_monitor_cmd("info balloon") + if status != 0: + logging.error("qemu monitor command failed: info balloon") + + balloon_cmd_mem = int(re.findall("\d+",output)[0]) + if balloon_cmd_mem != new_mem: + logging.error("memory ballooning failed while changing memory to %s" %balloon_cmd_mem) + fail += 1 + + #Checking for test result + if fail != 0: + raise error.TestFail("Memory ballooning test failed ") + session.close() diff -uprN autotest-old/client/tests/kvm/tests_base.cfg.sample autotest/client/tests/kvm/tests_base.cfg.sample --- autotest-old/client/tests/kvm/tests_base.cfg.sample 2010-04-09 12:32:50.000000000 -0400 +++ autotest/client/tests/kvm/tests_base.cfg.sample 2010-04-09 12:53:27.000000000 -0400 @@ -185,6 +185,10 @@ variants: drift_threshold = 10 drift_threshold_single = 3 + - balloon_check: install setup unattended_install boot + type = balloon_check + extra_params += " -balloon virtio" + - stress_boot: install setup unattended_install type = stress_boot max_vms = 5