* [Qemu-devel] [PATCH] Add virtio-blk-drive-serial test
@ 2012-01-13 21:49 Ryan Harper
2012-01-14 1:03 ` Zhi Yong Wu
2012-01-15 14:33 ` Anthony Liguori
0 siblings, 2 replies; 6+ messages in thread
From: Ryan Harper @ 2012-01-13 21:49 UTC (permalink / raw)
To: qemu-devel; +Cc: Ryan Harper
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>
---
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
--
1.7.6
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] Add virtio-blk-drive-serial test
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:33 ` Anthony Liguori
1 sibling, 1 reply; 6+ messages in thread
From: Zhi Yong Wu @ 2012-01-14 1:03 UTC (permalink / raw)
To: Ryan Harper; +Cc: QEMU Developers
On Sat, Jan 14, 2012 at 5:49 AM, Ryan Harper <ryanh@us.ibm.com> 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>
> ---
> 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
> +}
How will you make in_guest() run in that guest system?
> +
> +if test $QEMU_TEST; then
> + in_host
> +else
> + in_guest
> +fi
> --
> 1.7.6
>
>
--
Regards,
Zhi Yong Wu
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] Add virtio-blk-drive-serial test
2012-01-14 1:03 ` Zhi Yong Wu
@ 2012-01-14 1:25 ` Zhi Yong Wu
2012-01-15 14:39 ` Anthony Liguori
0 siblings, 1 reply; 6+ messages in thread
From: Zhi Yong Wu @ 2012-01-14 1:25 UTC (permalink / raw)
To: Ryan Harper; +Cc: QEMU Developers
On Sat, Jan 14, 2012 at 9:03 AM, Zhi Yong Wu <zwu.kernel@gmail.com> wrote:
> On Sat, Jan 14, 2012 at 5:49 AM, Ryan Harper <ryanh@us.ibm.com> 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>
>> ---
>> 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
>> +}
> How will you make in_guest() run in that guest system?
>From the code below, i guess that qtest framework make sure it.
>> +
>> +if test $QEMU_TEST; then
>> + in_host
>> +else
>> + in_guest
>> +fi
>> --
>> 1.7.6
>>
>>
>
>
>
> --
> Regards,
>
> Zhi Yong Wu
--
Regards,
Zhi Yong Wu
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] Add virtio-blk-drive-serial test
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-15 14:33 ` Anthony Liguori
1 sibling, 0 replies; 6+ messages in thread
From: Anthony Liguori @ 2012-01-15 14:33 UTC (permalink / raw)
To: Ryan Harper; +Cc: qemu-devel
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] Add virtio-blk-drive-serial test
2012-01-14 1:25 ` Zhi Yong Wu
@ 2012-01-15 14:39 ` Anthony Liguori
2012-01-16 1:57 ` Zhi Yong Wu
0 siblings, 1 reply; 6+ messages in thread
From: Anthony Liguori @ 2012-01-15 14:39 UTC (permalink / raw)
To: Zhi Yong Wu; +Cc: Ryan Harper, QEMU Developers
On 01/13/2012 07:25 PM, Zhi Yong Wu wrote:
> On Sat, Jan 14, 2012 at 9:03 AM, Zhi Yong Wu<zwu.kernel@gmail.com> wrote:
>> On Sat, Jan 14, 2012 at 5:49 AM, Ryan Harper<ryanh@us.ibm.com> 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>
>>> ---
>>> 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
>>> +}
>> How will you make in_guest() run in that guest system?
>> From the code below, i guess that qtest framework make sure it.
qemu-test. qtest is something different.
The script is copied into the initramfs used to run the guest. QEMU_TEST=1 only
in the host so the code below invokes in_guest only in the guest.
Regards,
Anthony Liguori
>>> +
>>> +if test $QEMU_TEST; then
>>> + in_host
>>> +else
>>> + in_guest
>>> +fi
>>> --
>>> 1.7.6
>>>
>>>
>>
>>
>>
>> --
>> Regards,
>>
>> Zhi Yong Wu
>
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] Add virtio-blk-drive-serial test
2012-01-15 14:39 ` Anthony Liguori
@ 2012-01-16 1:57 ` Zhi Yong Wu
0 siblings, 0 replies; 6+ messages in thread
From: Zhi Yong Wu @ 2012-01-16 1:57 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Ryan Harper, QEMU Developers
On Sun, Jan 15, 2012 at 10:39 PM, Anthony Liguori <anthony@codemonkey.ws> wrote:
> On 01/13/2012 07:25 PM, Zhi Yong Wu wrote:
>>
>> On Sat, Jan 14, 2012 at 9:03 AM, Zhi Yong Wu<zwu.kernel@gmail.com> wrote:
>>>
>>> On Sat, Jan 14, 2012 at 5:49 AM, Ryan Harper<ryanh@us.ibm.com> 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>
>>>> ---
>>>> 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
>>>> +}
>>>
>>> How will you make in_guest() run in that guest system?
>>> From the code below, i guess that qtest framework make sure it.
>
>
> qemu-test. qtest is something different.
>
> The script is copied into the initramfs used to run the guest. QEMU_TEST=1
> only in the host so the code below invokes in_guest only in the guest.
thanks.
>
> Regards,
>
> Anthony Liguori
>
>
>>>> +
>>>> +if test $QEMU_TEST; then
>>>> + in_host
>>>> +else
>>>> + in_guest
>>>> +fi
>>>> --
>>>> 1.7.6
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Regards,
>>>
>>> Zhi Yong Wu
>>
>>
>>
>>
>
--
Regards,
Zhi Yong Wu
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-01-16 1:57 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).