From patchwork Wed Jan 12 11:45:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amos Kong X-Patchwork-Id: 473851 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0CBjxZ5006172 for ; Wed, 12 Jan 2011 11:45:59 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752796Ab1ALLpz (ORCPT ); Wed, 12 Jan 2011 06:45:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:31252 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752136Ab1ALLpy (ORCPT ); Wed, 12 Jan 2011 06:45:54 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0CBjqfB018094 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 12 Jan 2011 06:45:53 -0500 Received: from localhost6.localdomain6 (dhcp-65-77.nay.redhat.com [10.66.65.77]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p0CBjoQ3014065; Wed, 12 Jan 2011 06:45:51 -0500 Subject: [PATCH] KVM-test: Add a ENOSPC subtest To: autotest@test.kernel.org From: Amos Kong Cc: kwolf@redhat.com, kvm@vger.kernel.org Date: Wed, 12 Jan 2011 19:45:48 +0800 Message-ID: <20110112114548.15348.15923.stgit@localhost6.localdomain6> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 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.6 (demeter1.kernel.org [140.211.167.41]); Wed, 12 Jan 2011 11:46:18 +0000 (UTC) diff --git a/client/tests/kvm/scripts/check_image.py b/client/tests/kvm/scripts/check_image.py old mode 100644 new mode 100755 diff --git a/client/tests/kvm/tests/enospc.py b/client/tests/kvm/tests/enospc.py new file mode 100644 index 0000000..28b5988 --- /dev/null +++ b/client/tests/kvm/tests/enospc.py @@ -0,0 +1,56 @@ +import logging, commands, time, os +from autotest_lib.client.common_lib import error +import kvm_test_utils + + +def run_enospc(test, params, env): + """ + ENOSPC test + + 1) Create a virtual disk on lvm + 2) Boot up guest with two disks + 3) Continually write data to second disk + 4) Check images and extend second disk when no space + 5) Continue paused guest + 6) Repeat step 3~5 several times + + @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")) + timeout = int(params.get("login_timeout", 360)) + session_serial = kvm_test_utils.wait_for_login(vm, timeout=timeout, + serial=True) + devname = params.get("devname", "/dev/hdb") + if params.get("drive_format") == "virtio": + devname = "/dev/vdb" + cmd = params.get("background_cmd") + session_serial.sendline(cmd % devname) + + i = 0 + pause_n = 0 + while i < int(params.get("repeat_time", 40)): + status = vm.monitor.cmd("info status") + logging.debug("VM status: %s" % status) + if "paused" in status: + pause_n += 1 + script_path = os.path.join(test.bindir, "scripts/check_image.py") + s, o = commands.getstatusoutput('python %s' % script_path) + if s != 0: + logging.debug(o) + vm.monitor.cmd("cont") + #raise error.TestFail("Image check failed!") + cmd = "lvextend -L +200M /dev/vgtest/lvtest" + logging.info("Guest paused, extend lvm size, cmd: %s" % cmd) + commands.getoutput(cmd) + logging.info("Continue guest") + vm.monitor.cmd("cont") + time.sleep(10) + i += 1 + + logging.info("Guest paused %s times" % pause_n) + if pause_n == 0: + raise error.TestFail("Guest doesn't become paused") + + logging.info("The final VM status: %s" % vm.monitor.cmd("info status")) diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample index c5d9ca3..17e0e43 100644 --- a/client/tests/kvm/tests_base.cfg.sample +++ b/client/tests/kvm/tests_base.cfg.sample @@ -591,6 +591,20 @@ variants: - fmt_raw: image_format_stg = raw + - enospc: + type = enospc + images += " stg" + drive_werror = stop + drive_cache = none + image_name_stg = enospc + image_format_stg = qcow2 + image_boot_stg = no + image_snapshot_stg = no + background_cmd = "nohup dd if=/dev/zero of=%s bs=1024 &" + pre_command += "qemu-img create -f raw /tmp/enospc.raw 10G && losetup /dev/loop0 /tmp/enospc.raw && pvcreate /dev/loop0 && vgcreate vgtest /dev/loop0 && lvcreate -L200M -n lvtest vgtest && qemu-img create -f qcow2 /dev/vgtest/lvtest 10G && ln -s /dev/vgtest/lvtest /tmp/kvm_autotest_root/images/enospc.qcow2;" + post_command += "lvremove -f vgtest; losetup -d /dev/loop0; rm -rf /tmp/enospc.raw /tmp/kvm_autotest_root/images/enospc.qcow2;" + kill_vm = yes + - qmp_basic: install setup unattended_install.cdrom type = qmp_basic