From: Anthony Liguori <anthony@codemonkey.ws>
To: Ryan Harper <ryanh@us.ibm.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] Add virtio-blk-drive-serial test
Date: Sun, 15 Jan 2012 08:33:11 -0600 [thread overview]
Message-ID: <4F12E3A7.4080702@codemonkey.ws> (raw)
In-Reply-To: <1326491377-13054-1-git-send-email-ryanh@us.ibm.com>
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<ryanh@us.ibm.com>
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
prev parent reply other threads:[~2012-01-15 14:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-13 21:49 [Qemu-devel] [PATCH] Add virtio-blk-drive-serial test Ryan Harper
2012-01-14 1:03 ` Zhi Yong Wu
2012-01-14 1:25 ` Zhi Yong Wu
2012-01-15 14:39 ` Anthony Liguori
2012-01-16 1:57 ` Zhi Yong Wu
2012-01-15 14:33 ` Anthony Liguori [this message]
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=4F12E3A7.4080702@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=qemu-devel@nongnu.org \
--cc=ryanh@us.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).