From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:59768) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RmR94-0004lb-On for qemu-devel@nongnu.org; Sun, 15 Jan 2012 09:33:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RmR91-0005Ma-3n for qemu-devel@nongnu.org; Sun, 15 Jan 2012 09:33:18 -0500 Received: from mail-yx0-f173.google.com ([209.85.213.173]:38463) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RmR91-0005MW-18 for qemu-devel@nongnu.org; Sun, 15 Jan 2012 09:33:15 -0500 Received: by yenl8 with SMTP id l8so1092945yen.4 for ; Sun, 15 Jan 2012 06:33:14 -0800 (PST) Message-ID: <4F12E3A7.4080702@codemonkey.ws> Date: Sun, 15 Jan 2012 08:33:11 -0600 From: Anthony Liguori MIME-Version: 1.0 References: <1326491377-13054-1-git-send-email-ryanh@us.ibm.com> In-Reply-To: <1326491377-13054-1-git-send-email-ryanh@us.ibm.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] Add virtio-blk-drive-serial test List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ryan Harper Cc: qemu-devel@nongnu.org On 01/13/2012 03:49 PM, Ryan Harper wrote: > 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 Applied. Thanks. Regards, Anthony Liguori > --- > 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