mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
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>
This commit is contained in:
parent
ed9114356b
commit
e8c81b4d8a
3 changed files with 31 additions and 4 deletions
|
@ -91,6 +91,28 @@ bool qvirtio_wait_queue_isr(const QVirtioBus *bus, QVirtioDevice *d,
|
|||
return timeout != 0;
|
||||
}
|
||||
|
||||
/* Wait for the status byte at given guest memory address to be set
|
||||
*
|
||||
* The virtqueue interrupt must not be raised, making this useful for testing
|
||||
* event_index functionality.
|
||||
*/
|
||||
uint8_t qvirtio_wait_status_byte_no_isr(const QVirtioBus *bus,
|
||||
QVirtioDevice *d,
|
||||
QVirtQueue *vq,
|
||||
uint64_t addr,
|
||||
gint64 timeout_us)
|
||||
{
|
||||
gint64 start_time = g_get_monotonic_time();
|
||||
uint8_t val;
|
||||
|
||||
while ((val = readb(addr)) == 0xff) {
|
||||
clock_step(100);
|
||||
g_assert(!bus->get_queue_isr_status(d, vq));
|
||||
g_assert(g_get_monotonic_time() - start_time <= timeout_us);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
bool qvirtio_wait_config_isr(const QVirtioBus *bus, QVirtioDevice *d,
|
||||
uint64_t timeout)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue