From patchwork Fri Jan 13 21:49:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Harper X-Patchwork-Id: 136021 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 42A86B6FD0 for ; Sat, 14 Jan 2012 08:51:50 +1100 (EST) Received: from localhost ([::1]:48252 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rlp2I-0007tL-OH for incoming@patchwork.ozlabs.org; Fri, 13 Jan 2012 16:51:46 -0500 Received: from eggs.gnu.org ([140.186.70.92]:51537) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rlp1t-0007lo-CS for qemu-devel@nongnu.org; Fri, 13 Jan 2012 16:51:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rlp1s-0005uU-AO for qemu-devel@nongnu.org; Fri, 13 Jan 2012 16:51:21 -0500 Received: from e9.ny.us.ibm.com ([32.97.182.139]:44859) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rlp1s-0005uQ-7z for qemu-devel@nongnu.org; Fri, 13 Jan 2012 16:51:20 -0500 Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 13 Jan 2012 16:51:18 -0500 Received: from d01relay04.pok.ibm.com (9.56.227.236) by e9.ny.us.ibm.com (192.168.1.109) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 13 Jan 2012 16:51:17 -0500 Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q0DLpGia202468 for ; Fri, 13 Jan 2012 16:51:16 -0500 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q0DLpG1J013704 for ; Fri, 13 Jan 2012 19:51:16 -0200 Received: from localhost ([9.12.226.92]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q0DLpF1S013651; Fri, 13 Jan 2012 19:51:15 -0200 From: Ryan Harper To: qemu-devel@nongnu.org Date: Fri, 13 Jan 2012 15:49:37 -0600 Message-Id: <1326491377-13054-1-git-send-email-ryanh@us.ibm.com> X-Mailer: git-send-email 1.7.6 x-cbid: 12011321-7182-0000-0000-0000008ACCB6 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 32.97.182.139 X-Mailman-Approved-At: Fri, 13 Jan 2012 16:51:38 -0500 Cc: Ryan Harper Subject: [Qemu-devel] [PATCH] Add virtio-blk-drive-serial test X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org We can test out the virtio-blk drive serial number by generating and then reading it back via the file in sysfs. Signed-off-by: Ryan Harper --- tests/virtio-blk-drive-serial.sh | 40 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 40 insertions(+), 0 deletions(-) create mode 100755 tests/virtio-blk-drive-serial.sh diff --git a/tests/virtio-blk-drive-serial.sh b/tests/virtio-blk-drive-serial.sh new file mode 100755 index 0000000..0586f97 --- /dev/null +++ b/tests/virtio-blk-drive-serial.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +serial="0123456789abcdefghi" + +in_host() { + tmpdisk=$tmpdir/disk.img + qemu-img create -f qcow2 $tmpdisk 10G + + qemu -nographic -enable-kvm \ + -drive file=$tmpdisk,if=none,id=drive-virtio-disk0,format=raw,cache=none,serial=$serial \ + -device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0 + rc=$? + + rm $tmpdisk + return $rc +} + +in_guest() { + sysfspath=/sys/block/vda + if ! test -e $sysfspath; then + echo "Device not visible!" + return 1 + fi + + guest_serial=`cat $sysfspath/serial` + + if test "$guest_serial" != "$serial"; then + echo "drive has wrong serial!" + echo "Expected '$serial', got '$guest_serial'" + return 2 + fi + + return 0 +} + +if test $QEMU_TEST; then + in_host +else + in_guest +fi