* [Qemu-devel] [PATCH] qemu-test: add device-del test case
@ 2012-01-13 13:47 Anthony Liguori
0 siblings, 0 replies; only message in thread
From: Anthony Liguori @ 2012-01-13 13:47 UTC (permalink / raw)
To: qemu-devel; +Cc: Anthony Liguori
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
tests/device-del.sh | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 91 insertions(+), 0 deletions(-)
create mode 100755 tests/device-del.sh
diff --git a/tests/device-del.sh b/tests/device-del.sh
new file mode 100755
index 0000000..3af4e2f
--- /dev/null
+++ b/tests/device-del.sh
@@ -0,0 +1,91 @@
+#!/bin/sh
+
+canary="** waiting for hotplug **"
+canary2="** waiting for remove **"
+
+in_host() {
+ tmpdisk=$tmpdir/disk.img
+
+ # make sure to test various of -device, anonymous, and named
+ extra_arg=`choose "-device virtio-balloon-pci" "-device virtio-balloon-pci,id=balloon0" none`
+
+ if test "$extra_arg" = "none"; then
+ extra_arg=""
+ fi
+
+ qemu-img create -f qcow2 $tmpdisk 10G
+
+ start_qemu -nographic -enable-kvm $extra_arg
+
+ while qemu_is_okay; do
+ if grep "$canary" $tmplog >/dev/null; then
+ out=`hmp drive_add auto file=$tmpdisk,if=none,id=hd0`
+ if test $(echo "$out") != "OK"; then
+ echo "drive_add failed!"
+ echo "$out"
+ rm $tmpdisk
+ kill $pid
+ return 1
+ fi
+
+ qmp device_add --driver=virtio-blk-pci --drive=hd0 --id=hd0
+ rc=$?
+ if test $rc != 0; then
+ echo "device_add failed!"
+ rm $tmpdisk
+ kill $pid
+ return 1
+ fi
+
+ echo "** waiting for guest to see device **"
+
+ while qemu_is_okay; do
+ if grep "$canary2" $tmplog >/dev/null; then
+ qmp device_del --id=hd0
+ rc=$?
+ if test $rc != 0; then
+ echo "device_del failed!"
+ rm $tmpdisk
+ kill $pid
+ return 1
+ fi
+
+ while qemu_is_okay; do
+ sleep 1
+ done
+
+ break
+ fi
+ sleep 1
+ done
+
+ break
+ fi
+ sleep 1
+ done
+
+ get_qemu_status
+ rc=$?
+
+ rm -f $tmpdisk
+
+ return $rc
+}
+
+in_guest() {
+ echo
+ echo "$canary"
+ while ! grep vda /proc/partitions >/dev/null; do
+ sleep 1
+ done
+ echo "$canary2"
+ while grep vda /proc/partitions >/dev/null; do
+ sleep 1
+ done
+}
+
+if test $QEMU_TEST; then
+ in_host
+else
+ in_guest
+fi
--
1.7.4.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2012-01-13 13:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-13 13:47 [Qemu-devel] [PATCH] qemu-test: add device-del test case 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).