diff options
Diffstat (limited to 'tests/libqos')
-rw-r--r-- | tests/libqos/virtio.c | 30 | ||||
-rw-r--r-- | tests/libqos/virtio.h | 8 |
2 files changed, 20 insertions, 18 deletions
diff --git a/tests/libqos/virtio.c b/tests/libqos/virtio.c index 009325dd02..a061289249 100644 --- a/tests/libqos/virtio.c +++ b/tests/libqos/virtio.c @@ -78,17 +78,18 @@ void qvirtio_set_driver_ok(const QVirtioBus *bus, QVirtioDevice *d) QVIRTIO_DRIVER_OK | QVIRTIO_DRIVER | QVIRTIO_ACKNOWLEDGE); } -bool qvirtio_wait_queue_isr(const QVirtioBus *bus, QVirtioDevice *d, - QVirtQueue *vq, uint64_t timeout) +void qvirtio_wait_queue_isr(const QVirtioBus *bus, QVirtioDevice *d, + QVirtQueue *vq, gint64 timeout_us) { - do { + gint64 start_time = g_get_monotonic_time(); + + for (;;) { clock_step(100); if (bus->get_queue_isr_status(d, vq)) { - break; /* It has ended */ + return; } - } while (--timeout); - - return timeout != 0; + g_assert(g_get_monotonic_time() - start_time <= timeout_us); + } } /* Wait for the status byte at given guest memory address to be set @@ -113,17 +114,18 @@ uint8_t qvirtio_wait_status_byte_no_isr(const QVirtioBus *bus, return val; } -bool qvirtio_wait_config_isr(const QVirtioBus *bus, QVirtioDevice *d, - uint64_t timeout) +void qvirtio_wait_config_isr(const QVirtioBus *bus, QVirtioDevice *d, + gint64 timeout_us) { - do { + gint64 start_time = g_get_monotonic_time(); + + for (;;) { clock_step(100); if (bus->get_config_isr_status(d)) { - break; /* It has ended */ + return; } - } while (--timeout); - - return timeout != 0; + g_assert(g_get_monotonic_time() - start_time <= timeout_us); + } } void qvring_init(const QGuestAllocator *alloc, QVirtQueue *vq, uint64_t addr) diff --git a/tests/libqos/virtio.h b/tests/libqos/virtio.h index bc7518e880..29fbacbc99 100644 --- a/tests/libqos/virtio.h +++ b/tests/libqos/virtio.h @@ -160,15 +160,15 @@ void qvirtio_set_acknowledge(const QVirtioBus *bus, QVirtioDevice *d); void qvirtio_set_driver(const QVirtioBus *bus, QVirtioDevice *d); void qvirtio_set_driver_ok(const QVirtioBus *bus, QVirtioDevice *d); -bool qvirtio_wait_queue_isr(const QVirtioBus *bus, QVirtioDevice *d, - QVirtQueue *vq, uint64_t timeout); +void qvirtio_wait_queue_isr(const QVirtioBus *bus, QVirtioDevice *d, + QVirtQueue *vq, gint64 timeout_us); uint8_t qvirtio_wait_status_byte_no_isr(const QVirtioBus *bus, QVirtioDevice *d, QVirtQueue *vq, uint64_t addr, gint64 timeout_us); -bool qvirtio_wait_config_isr(const QVirtioBus *bus, QVirtioDevice *d, - uint64_t timeout); +void qvirtio_wait_config_isr(const QVirtioBus *bus, QVirtioDevice *d, + gint64 timeout_us); QVirtQueue *qvirtqueue_setup(const QVirtioBus *bus, QVirtioDevice *d, QGuestAllocator *alloc, uint16_t index); |