qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 3/6] tests/libqos: Replace clock_step with qtest


From: Laurent Vivier
Subject: Re: [Qemu-devel] [PATCH 3/6] tests/libqos: Replace clock_step with qtest_clock_step in virtio code
Date: Tue, 3 Sep 2019 10:52:31 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0

On 03/09/2019 08:18, Thomas Huth wrote:
> 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 <address@hidden>
> ---
>  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);

qvirtio_wait_config_isr() calls get_config_isr_status() that will
extract qts from PCI bus or MMIO structure. I think you should not add a
parameter here and move all the stuff to
qvirtio_mmio_get_config_isr_status() and
qvirtio_pci_get_config_isr_status().

Thanks,
Laurent



reply via email to

[Prev in Thread] Current Thread [Next in Thread]