[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] qemu-test: add test for device_add
From: |
Anthony Liguori |
Subject: |
[Qemu-devel] [PATCH] qemu-test: add test for device_add |
Date: |
Mon, 19 Dec 2011 16:47:01 -0600 |
This does a simple test using device_add to add a block device. It uses a mix
of hmp and qmp commands because there is not yet a drive_add equivalent for
qmp.
Signed-off-by: Anthony Liguori <address@hidden>
---
kernel-3.0.config | 2 +-
tests/device-add.sh | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 71 insertions(+), 1 deletions(-)
create mode 100755 tests/device-add.sh
diff --git a/kernel-3.0.config b/kernel-3.0.config
index 673c192..74d6019 100644
--- a/kernel-3.0.config
+++ b/kernel-3.0.config
@@ -539,7 +539,7 @@ CONFIG_YENTA_TOSHIBA=y
CONFIG_PCCARD_NONSTATIC=y
CONFIG_HOTPLUG_PCI=y
# CONFIG_HOTPLUG_PCI_FAKE is not set
-# CONFIG_HOTPLUG_PCI_ACPI is not set
+CONFIG_HOTPLUG_PCI_ACPI=y
# CONFIG_HOTPLUG_PCI_CPCI is not set
# CONFIG_HOTPLUG_PCI_SHPC is not set
# CONFIG_RAPIDIO is not set
diff --git a/tests/device-add.sh b/tests/device-add.sh
new file mode 100755
index 0000000..52ffbf0
--- /dev/null
+++ b/tests/device-add.sh
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+canary="** waiting for hotplug **"
+
+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
+ 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
+ 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
+}
+
+if test $QEMU_TEST; then
+ in_host
+else
+ in_guest
+fi
--
1.7.4.1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemu-devel] [PATCH] qemu-test: add test for device_add,
Anthony Liguori <=