From patchwork Thu Apr 15 15:10:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: pradeep kumar X-Patchwork-Id: 92759 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 o3FFANjV004072 for ; Thu, 15 Apr 2010 15:10:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754318Ab0DOPKV (ORCPT ); Thu, 15 Apr 2010 11:10:21 -0400 Received: from e3.ny.us.ibm.com ([32.97.182.143]:36662 "EHLO e3.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754270Ab0DOPKU (ORCPT ); Thu, 15 Apr 2010 11:10:20 -0400 Received: from d01relay01.pok.ibm.com (d01relay01.pok.ibm.com [9.56.227.233]) by e3.ny.us.ibm.com (8.14.3/8.13.1) with ESMTP id o3FEwChv030573 for ; Thu, 15 Apr 2010 10:58:12 -0400 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay01.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o3FFAIGq151338 for ; Thu, 15 Apr 2010 11:10:18 -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 o3FFAHsX005641 for ; Thu, 15 Apr 2010 12:10:18 -0300 Received: from [9.124.158.31] ([9.124.158.31]) by d01av02.pok.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id o3FFAFHR005485; Thu, 15 Apr 2010 12:10:16 -0300 Message-ID: <4BC72C57.3090602@linux.vnet.ibm.com> Date: Thu, 15 Apr 2010 20:40:15 +0530 From: pradeep User-Agent: Thunderbird 2.0.0.24 (X11/20100317) MIME-Version: 1.0 To: Lucas Meneghel Rodrigues CC: 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> <4BBEEF05.5080809@linux.vnet.ibm.com> <4BC2FE0A.6050103@linux.vnet.ibm.com> In-Reply-To: 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 15:10:26 +0000 (UTC) diff -purN autotest/client/tests/kvm/tests/balloon_check.py autotest-new/client/tests/kvm/tests/balloon_check.py --- autotest/client/tests/kvm/tests/balloon_check.py 1969-12-31 19:00:00.000000000 -0500 +++ autotest-new/client/tests/kvm/tests/balloon_check.py 2010-04-15 18:50:09.000000000 -0400 @@ -0,0 +1,51 @@ +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) Change the memory between 60% to 95% of memory of guest using ballooning + 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) + + + #Check if info balloon works or not. + status, output = vm.send_monitor_cmd("info balloon") + if status != 0: + logging.error("qemu monitor command failed: info balloon") + fail += 1 + + #Reduce memory to random size between 60% to 95% of actual memory + percent = random.uniform(0.6, 0.95) + new_mem = int(percent*actual_mem) + vm.send_monitor_cmd("balloon %s" % new_mem) + time.sleep(20) + status, output = vm.send_monitor_cmd("info balloon") + ballooned_mem = int(re.findall("\d+",output)[0]) + if ballooned_mem != new_mem: + logging.error("memory ballooning failed while changing memory from %s to %s" %actual_mem %new_mem) + fail += 1 + + #Checking for test result + if fail != 0: + raise error.TestFail("Memory ballooning test failed ") + session.close() diff -purN autotest/client/tests/kvm/tests_base.cfg.sample autotest-new/client/tests/kvm/tests_base.cfg.sample --- autotest/client/tests/kvm/tests_base.cfg.sample 2010-04-15 09:14:10.000000000 -0400 +++ autotest-new/client/tests/kvm/tests_base.cfg.sample 2010-04-15 18:50:35.000000000 -0400 @@ -171,6 +171,10 @@ variants: drift_threshold = 10 drift_threshold_single = 3 + - balloon_check: install setup unattended_install + type = balloon_check + extra_params += "-balloon virtio" + - stress_boot: install setup unattended_install type = stress_boot max_vms = 5