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.
Signed-off-by: Thomas Huth <th...@redhat.com> --- tests/libqos/virtio.c | 15 ++++++++------- tests/libqos/virtio.h | 5 +++-- tests/virtio-blk-test.c | 8 +++++--- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/tests/libqos/virtio.c b/tests/libqos/virtio.c index 91ce06954b..5a2ed7a1a5 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)) { @@ -149,12 +149,13 @@ void qvirtio_wait_used_elem(QTestState *qts, QVirtioDevice *d, } } -void qvirtio_wait_config_isr(QVirtioDevice *d, gint64 timeout_us) +void qvirtio_wait_config_isr(QTestState *qts, QVirtioDevice *d, + gint64 timeout_us) { gint64 start_time = g_get_monotonic_time(); for (;;) { - clock_step(100); + qtest_clock_step(qts, 100); if (d->bus->get_config_isr_status(d)) { return; } diff --git a/tests/libqos/virtio.h b/tests/libqos/virtio.h index 037176dbd8..1a93f9b1de 100644 --- a/tests/libqos/virtio.h +++ b/tests/libqos/virtio.h @@ -112,7 +112,7 @@ void qvirtio_set_acknowledge(QVirtioDevice *d); void qvirtio_set_driver(QVirtioDevice *d); void qvirtio_set_driver_ok(QVirtioDevice *d); -void qvirtio_wait_queue_isr(QVirtioDevice *d, +void qvirtio_wait_queue_isr(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq, gint64 timeout_us); uint8_t qvirtio_wait_status_byte_no_isr(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq, @@ -123,7 +123,8 @@ void qvirtio_wait_used_elem(QTestState *qts, QVirtioDevice *d, uint32_t desc_idx, uint32_t *len, gint64 timeout_us); -void qvirtio_wait_config_isr(QVirtioDevice *d, gint64 timeout_us); +void qvirtio_wait_config_isr(QTestState *qts, QVirtioDevice *d, + gint64 timeout_us); QVirtQueue *qvirtqueue_setup(QVirtioDevice *d, QGuestAllocator *alloc, uint16_t index); void qvirtqueue_cleanup(const QVirtioBus *bus, QVirtQueue *vq, diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c index 982ff1538c..247fef0b0f 100644 --- a/tests/virtio-blk-test.c +++ b/tests/virtio-blk-test.c @@ -435,6 +435,7 @@ static void config(void *obj, void *data, QGuestAllocator *t_alloc) QVirtioDevice *dev = blk_if->vdev; int n_size = TEST_IMAGE_SIZE / 2; uint64_t capacity; + QTestState *qts = global_qtest; capacity = qvirtio_config_readq(dev, 0); g_assert_cmpint(capacity, ==, TEST_IMAGE_SIZE / 512); @@ -444,7 +445,7 @@ static void config(void *obj, void *data, QGuestAllocator *t_alloc) qmp_discard_response("{ 'execute': 'block_resize', " " 'arguments': { 'device': 'drive0', " " 'size': %d } }", n_size); - qvirtio_wait_config_isr(dev, QVIRTIO_BLK_TIMEOUT_US); + qvirtio_wait_config_isr(qts, dev, QVIRTIO_BLK_TIMEOUT_US); capacity = qvirtio_config_readq(dev, 0); g_assert_cmpint(capacity, ==, n_size / 512); @@ -494,7 +495,7 @@ static void msix(void *obj, void *u_data, QGuestAllocator *t_alloc) " 'arguments': { 'device': 'drive0', " " 'size': %d } }", n_size); - qvirtio_wait_config_isr(dev, QVIRTIO_BLK_TIMEOUT_US); + qvirtio_wait_config_isr(qts, dev, QVIRTIO_BLK_TIMEOUT_US); capacity = qvirtio_config_readq(dev, 0); g_assert_cmpint(capacity, ==, n_size / 512); @@ -737,6 +738,7 @@ static void resize(void *obj, void *data, QGuestAllocator *t_alloc) int n_size = TEST_IMAGE_SIZE / 2; uint64_t capacity; QVirtQueue *vq; + QTestState *qts = global_qtest; vq = qvirtqueue_setup(dev, t_alloc, 0); @@ -746,7 +748,7 @@ static void resize(void *obj, void *data, QGuestAllocator *t_alloc) " 'arguments': { 'device': 'drive0', " " 'size': %d } }", n_size); - qvirtio_wait_queue_isr(dev, vq, QVIRTIO_BLK_TIMEOUT_US); + qvirtio_wait_queue_isr(qts, dev, vq, QVIRTIO_BLK_TIMEOUT_US); capacity = qvirtio_config_readq(dev, 0); g_assert_cmpint(capacity, ==, n_size / 512); -- 2.18.1