summaryrefslogtreecommitdiff
path: root/tests/virtio-blk-test.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2014-09-29 16:40:11 +0100
committerPeter Maydell <peter.maydell@linaro.org>2014-09-29 17:31:08 +0100
commite8c81b4d8a5a2fd125e559cb02b8a87598419041 (patch)
treea7fc7c59c24b280e203d4b5b1694c5df1c770aa4 /tests/virtio-blk-test.c
parented9114356b587b362f5ed10e75366a4f07ed32af (diff)
downloadqemu-e8c81b4d8a5a2fd125e559cb02b8a87598419041.tar.gz
libqos: improve event_index test with timeout
The virtio event_index feature lets the device driver tell the device how many requests to process before raising the next interrupt. virtio-blk-test.c tries to verify that the device does not raise an interrupt unnecessarily. Unfortunately the test has a race condition. It spins checking for an interrupt up to 100 times and then assumes the request has finished. On a slow host the I/O request could still be in flight and the test would fail. This patch waits for the request to complete, or until a 30-second timeout is reached. If an interrupt is raised while waiting the test fails since the device was not supposed to raise interrupts. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests/virtio-blk-test.c')
-rw-r--r--tests/virtio-blk-test.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c
index 588666cff1..0e3bfa7eb2 100644
--- a/tests/virtio-blk-test.c
+++ b/tests/virtio-blk-test.c
@@ -42,6 +42,7 @@
#define TEST_IMAGE_SIZE (64 * 1024 * 1024)
#define QVIRTIO_BLK_TIMEOUT 100
+#define QVIRTIO_BLK_TIMEOUT_US (30 * 1000 * 1000)
#define PCI_SLOT 0x04
#define PCI_FN 0x00
@@ -595,10 +596,9 @@ static void pci_idx(void)
qvirtqueue_kick(&qvirtio_pci, &dev->vdev, &vqpci->vq, free_head);
/* No notification expected */
- g_assert(!qvirtio_wait_queue_isr(&qvirtio_pci, &dev->vdev, &vqpci->vq,
- QVIRTIO_BLK_TIMEOUT));
-
- status = readb(req_addr + 528);
+ status = qvirtio_wait_status_byte_no_isr(&qvirtio_pci, &dev->vdev,
+ &vqpci->vq, req_addr + 528,
+ QVIRTIO_BLK_TIMEOUT_US);
g_assert_cmpint(status, ==, 0);
guest_free(alloc, req_addr);