From patchwork Wed Aug 3 05:43:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amos Kong X-Patchwork-Id: 1030532 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p735dJqu006081 for ; Wed, 3 Aug 2011 05:39:19 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754650Ab1HCFjQ (ORCPT ); Wed, 3 Aug 2011 01:39:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42843 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754634Ab1HCFjP (ORCPT ); Wed, 3 Aug 2011 01:39:15 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p735dEUZ018469 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 3 Aug 2011 01:39:15 -0400 Received: from [127.0.0.1] (dhcp-8-167.nay.redhat.com [10.66.8.167]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p735dCSR017521; Wed, 3 Aug 2011 01:39:13 -0400 Subject: [PATCH v3] KVM-test: Add subtest: usb To: autotest@test.kernel.org, lmr@redhat.com, kraxel@redhat.com, kvm@vger.kernel.org From: Amos Kong Date: Wed, 03 Aug 2011 13:43:43 +0800 Message-ID: <20110803054343.27117.75300.stgit@t> In-Reply-To: <20110802114704.16296.14331.stgit@t> References: <20110802114704.16296.14331.stgit@t> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 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, 03 Aug 2011 05:39:19 +0000 (UTC) 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 Changes from v2: - reuse the new interface to add a usb disk to guest - report a rh-bug 727725 CC: Gerd Hoffmann Signed-off-by: Amos Kong --- client/tests/kvm/tests/usb.py | 50 ++++++++++++++++++++++++++++++++ client/tests/kvm/tests_base.cfg.sample | 15 ++++++++++ 2 files changed, 65 insertions(+), 0 deletions(-) create mode 100644 client/tests/kvm/tests/usb.py -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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 ccc17f6..1392898 100644 --- a/client/tests/kvm/tests_base.cfg.sample +++ b/client/tests/kvm/tests_base.cfg.sample @@ -1122,6 +1122,21 @@ variants: kill_vm_gracefully = no # Do not define test variants below shutdown + - 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: