From: Amos Kong <akong@redhat.com>
To: autotest@test.kernel.org
Cc: kwolf@redhat.com, kvm@vger.kernel.org
Subject: [PATCH] KVM-test: Add a ENOSPC subtest
Date: Wed, 12 Jan 2011 19:45:48 +0800 [thread overview]
Message-ID: <20110112114548.15348.15923.stgit@localhost6.localdomain6> (raw)
KVM guest always pauses on NOSPACE error, this test
just repeatedly extend guest disk space and resume guest
from paused status.
Signed-off-by: Amos Kong <akong@redhat.com>
---
client/tests/kvm/scripts/check_image.py | 0
client/tests/kvm/tests/enospc.py | 56 +++++++++++++++++++++++++++++++
client/tests/kvm/tests_base.cfg.sample | 14 ++++++++
3 files changed, 70 insertions(+), 0 deletions(-)
mode change 100644 => 100755 client/tests/kvm/scripts/check_image.py
create mode 100644 client/tests/kvm/tests/enospc.py
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
next reply other threads:[~2011-01-12 11:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-12 11:45 Amos Kong [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-01-13 21:43 [PATCH] KVM-test: Add a ENOSPC subtest Lucas Meneghel Rodrigues
2011-01-13 21:46 Lucas Meneghel Rodrigues
2011-01-14 5:28 ` Amos Kong
2011-01-14 8:27 ` Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110112114548.15348.15923.stgit@localhost6.localdomain6 \
--to=akong@redhat.com \
--cc=autotest@test.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=kwolf@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox