From: Amos Kong <akong@redhat.com>
To: autotest@test.kernel.org, lmr@redhat.com, kraxel@redhat.com,
kvm@vger.kernel.org
Subject: [PATCH v2] KVM-test: Add subtest: usb
Date: Tue, 02 Aug 2011 19:47:04 +0800 [thread overview]
Message-ID: <20110802114704.16296.14331.stgit@t> (raw)
In-Reply-To: <4E3656E5.4070000@redhat.com>
This test adds a usb storage for the guest, and do some check from monitor and
inside the guest.
Changes from v1:
- use old options to add a usb disk to guest
'-usbdevice disk:format=qcow2:/tmp/usbdevice.qcow2'
- identify device name of new disk by '/dev/disk/by-path/'
- match device with the detail output of 'lsusb -v'
- create disk image by pre_cmd
CC: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Amos Kong <akong@redhat.com>
---
client/tests/kvm/tests/usb.py | 50 ++++++++++++++++++++++++++++++++
client/tests/kvm/tests_base.cfg.sample | 9 ++++++
2 files changed, 59 insertions(+), 0 deletions(-)
create mode 100644 client/tests/kvm/tests/usb.py
diff --git a/client/tests/kvm/tests/usb.py b/client/tests/kvm/tests/usb.py
new file mode 100644
index 0000000..d1849de
--- /dev/null
+++ b/client/tests/kvm/tests/usb.py
@@ -0,0 +1,50 @@
+import logging
+from autotest_lib.client.common_lib import error
+
+
+@error.context_aware
+def run_usb(test, params, env):
+ """
+ Test usb device of guest
+
+ 1) create a image file by qemu-img
+ 2) boot up a guest add this file as a usb device
+ 3) check usb device information by execute monitor/guest command
+
+ @param test: kvm test object
+ @param params: Dictionary with the test parameters
+ @param env: Dictionary with test environment.
+ """
+ vm = env.get_vm(params["main_vm"])
+ vm.create()
+
+ session = vm.wait_for_login(timeout=int(params.get("login_timeout", 360)))
+
+ output = vm.monitor.cmd("info usb")
+ if "Product QEMU USB MSD" not in output:
+ logging.debug(output)
+ raise error.TestFail("Could not find mass storage device")
+
+ output = session.get_command_output("lsusb -v")
+ #no bus specified, default using "usb.0" for "usb-storage"
+ for i in ["ID 0000:0000", "Mass Storage", "SCSI", "QEMU USB HARDDRIVE"]:
+ if i not in output:
+ logging.debug(output)
+ raise error.TestFail("No '%s' in the output of 'lsusb -v'" % i)
+
+ output = session.get_command_output("fdisk -l")
+ if params.get("fdisk_string") not in output:
+ logging.debug(output)
+ raise error.TestFail("Could not realise the usb device")
+
+ error.context("Formating usb disk")
+ devname = session.get_command_output("ls /dev/disk/by-path/*|grep usb")
+ session.cmd("yes |mkfs %s" % devname,
+ timeout=int(params.get("format_timeout")))
+
+ error.context("Checking if exist I/O error in dmesg")
+ output = session.get_command_output("dmesg")
+ if "Buffer I/O error" in output:
+ logging.debug(output)
+ raise error.TestFail("Exists I/O error when format usb device")
+ session.close()
diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
index d597b52..a4e9a93 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -1115,6 +1115,15 @@ variants:
image_snapshot = yes
only Linux
+ - usb: install setup image_copy unattended_install.cdrom
+ type = usb
+ kill_vm = yes
+ format_timeout = 400
+ extra_params += " -usbdevice disk:format=qcow2:/tmp/usbdevice.qcow2"
+ pre_command += "qemu-img create -f qcow2 /tmp/usbdevice.qcow2 10M;"
+ fdisk_string = "Units = cylinders of 20 * 512 = 10240 bytes"
+ only Linux
+
# NICs
variants:
next prev parent reply other threads:[~2011-08-02 11:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-29 4:53 [RFC PATCH] KVM-test: Add subtest: usb Amos Kong
2011-08-01 7:33 ` Gerd Hoffmann
2011-08-02 11:10 ` Amos Kong
2011-08-02 14:24 ` Gerd Hoffmann
2011-08-02 11:47 ` Amos Kong [this message]
2011-08-03 5:43 ` [PATCH v3] " Amos Kong
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=20110802114704.16296.14331.stgit@t \
--to=akong@redhat.com \
--cc=autotest@test.kernel.org \
--cc=kraxel@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=lmr@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.