aboutsummaryrefslogtreecommitdiff
path: root/tests/libqos/virtio.c
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2019-09-03 08:18:46 +0200
committerThomas Huth <thuth@redhat.com>2019-09-05 13:18:52 +0200
commitb57ebd57b43db5456b850a81a2ef46b03b8716ca (patch)
tree3b17a6ee9613f599a0ebff783c58ae6dda6ca730 /tests/libqos/virtio.c
parent4d81d77efdce7096e8bbdc18a06cf9b3d376c3cb (diff)
tests/libqos: Replace clock_step with qtest_clock_step in virtio code
Library functions should not rely on functions that require global_qtest (since they might get used in tests that deal with multiple states). Commit 1999a70a05ad603d ("Make generic virtio code independent from global_qtest") already tried to clean the libqos virtio code, but I missed to replace the clock_step() function. Thus change it now to qtest_clock_step() instead. The logic of the qvirtio_wait_config_isr() function is now pushed to the virtio-mmio.c and virtio-pci.c files instead, since we can get the QTestState here easily. Message-Id: <20190904130047.25808-4-thuth@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests/libqos/virtio.c')
-rw-r--r--tests/libqos/virtio.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/tests/libqos/virtio.c b/tests/libqos/virtio.c
index 91ce06954b..0ae9956fc8 100644
--- a/tests/libqos/virtio.c
+++ b/tests/libqos/virtio.c
@@ -82,13 +82,13 @@ void qvirtio_set_driver_ok(QVirtioDevice *d)
VIRTIO_CONFIG_S_DRIVER | VIRTIO_CONFIG_S_ACKNOWLEDGE);
}
-void qvirtio_wait_queue_isr(QVirtioDevice *d,
+void qvirtio_wait_queue_isr(QTestState *qts, QVirtioDevice *d,
QVirtQueue *vq, gint64 timeout_us)
{
gint64 start_time = g_get_monotonic_time();
for (;;) {
- clock_step(100);
+ qtest_clock_step(qts, 100);
if (d->bus->get_queue_isr_status(d, vq)) {
return;
}
@@ -109,8 +109,8 @@ uint8_t qvirtio_wait_status_byte_no_isr(QTestState *qts, QVirtioDevice *d,
gint64 start_time = g_get_monotonic_time();
uint8_t val;
- while ((val = readb(addr)) == 0xff) {
- clock_step(100);
+ while ((val = qtest_readb(qts, addr)) == 0xff) {
+ qtest_clock_step(qts, 100);
g_assert(!d->bus->get_queue_isr_status(d, vq));
g_assert(g_get_monotonic_time() - start_time <= timeout_us);
}
@@ -137,7 +137,7 @@ void qvirtio_wait_used_elem(QTestState *qts, QVirtioDevice *d,
for (;;) {
uint32_t got_desc_idx;
- clock_step(100);
+ qtest_clock_step(qts, 100);
if (d->bus->get_queue_isr_status(d, vq) &&
qvirtqueue_get_buf(qts, vq, &got_desc_idx, len)) {
@@ -151,15 +151,7 @@ void qvirtio_wait_used_elem(QTestState *qts, QVirtioDevice *d,
void qvirtio_wait_config_isr(QVirtioDevice *d, gint64 timeout_us)
{
- gint64 start_time = g_get_monotonic_time();
-
- for (;;) {
- clock_step(100);
- if (d->bus->get_config_isr_status(d)) {
- return;
- }
- g_assert(g_get_monotonic_time() - start_time <= timeout_us);
- }
+ d->bus->wait_config_isr_status(d, timeout_us);
}
void qvring_init(QTestState *qts, const QGuestAllocator *alloc, QVirtQueue *vq,