From: Anthony Liguori <aliguori@us.ibm.com>
To: qemu-devel@nongnu.org
Cc: Anthony Liguori <aliguori@us.ibm.com>
Subject: [Qemu-devel] [PATCH] qemu-test: add device-del test case
Date: Fri, 13 Jan 2012 07:47:51 -0600 [thread overview]
Message-ID: <1326462471-8323-1-git-send-email-aliguori@us.ibm.com> (raw)
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
reply other threads:[~2012-01-13 13:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1326462471-8323-1-git-send-email-aliguori@us.ibm.com \
--to=aliguori@us.ibm.com \
--cc=qemu-devel@nongnu.org \
/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).