All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] KVM-test: Add subtest: usb
@ 2011-07-29  4:53 Amos Kong
  2011-08-01  7:33 ` Gerd Hoffmann
  0 siblings, 1 reply; 6+ messages in thread
From: Amos Kong @ 2011-07-29  4:53 UTC (permalink / raw)
  To: autotest, lmr, kraxel, kvm

This test adds a usb storage for the guest, and do some check from monitor and
inside the guest.
It's not very stable, could you help to review if something is wrong?

@ qemu-kvm -drive file='vm.qcow2',index=0,if=virtio,cache=none
-device usb-ehci,id=ehci
-drive file='/tmp/kvm_autotest_root/images/usbdevice.qcow2',if=none,cache=none,id=usb2.1
-device usb-storage,bus=ehci.0,drive=usb2.1,port=2
12:42:16 INFO | (qemu) *** EHCI support is under development ***

CC: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Amos Kong <akong@redhat.com>
---
 client/tests/kvm/tests/usb.py          |   49 ++++++++++++++++++++++++++++++++
 client/tests/kvm/tests_base.cfg.sample |   15 ++++++++++
 2 files changed, 64 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..2134820
--- /dev/null
+++ b/client/tests/kvm/tests/usb.py
@@ -0,0 +1,49 @@
+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")
+    #no bus specified, default using "usb.0" for "usb-storage"
+    if "ID 0000:0000" not in output:
+        logging.debug(output)
+        raise error.TestFail("No 'ID 0000:0000' in the output of 'lsusb'")
+
+    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")
+    dev_list = session.get_command_output("ls /dev/sd[a-z]")
+    session.cmd("yes |mkfs %s" % dev_list.split()[-1],
+                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..41e2553 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -1115,6 +1115,21 @@ variants:
         image_snapshot = yes
         only Linux
 
+    - usb: install setup image_copy unattended_install.cdrom
+        type = usb
+        kill_vm = yes
+        format_timeout = 400
+        images += " stg"
+        image_name_stg = "usbdevice"
+        image_format_stg = "qcow2"
+        image_boot_stg = no
+        drive_format_stg = "usb2"
+        drive_index_stg = 1
+        create_image_stg = yes
+        image_size_stg = 10M
+        fdisk_string = "Units = cylinders of 20 * 512 = 10240 bytes"
+        only Linux
+
 
 # NICs
 variants:


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-08-03  5:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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   ` [PATCH v2] " Amos Kong
2011-08-03  5:43     ` [PATCH v3] " Amos Kong

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.