qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <lvivier@redhat.com>
To: Thomas Huth <thuth@redhat.com>, qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>
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	[thread overview]
Message-ID: <519996c7-cfdc-4ab3-7805-f23b5df3d9a3@redhat.com> (raw)
In-Reply-To: <20190903061849.21493-4-thuth@redhat.com>

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 <thuth@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);

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	other threads:[~2019-09-03  8:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-03  6:18 [Qemu-devel] [PATCH 0/6] Make the core libqtest library independe from global_qtest Thomas Huth
2019-09-03  6:18 ` [Qemu-devel] [PATCH 1/6] tests/migration: Do not use functions anymore that rely on global_qtest Thomas Huth
2019-09-03  8:12   ` Laurent Vivier
2019-09-03  6:18 ` [Qemu-devel] [PATCH 2/6] tests/libqos/e1000e: Make e1000e libqos functions independent from global_qtest Thomas Huth
2019-09-03  8:34   ` Laurent Vivier
2019-09-03  6:18 ` [Qemu-devel] [PATCH 3/6] tests/libqos: Replace clock_step with qtest_clock_step in virtio code Thomas Huth
2019-09-03  8:52   ` Laurent Vivier [this message]
2019-09-03  6:18 ` [Qemu-devel] [PATCH 4/6] tests: Remove unnecessary global_qtest references Thomas Huth
2019-09-03  6:18 ` [Qemu-devel] [PATCH 5/6] tests/libqtest: Move global_test wrapper function into a separate header Thomas Huth
2019-09-03  6:18 ` [Qemu-devel] [PATCH 6/6] tests/libqtest: Use libqtest-single.h in tests that require global_qtest Thomas Huth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=519996c7-cfdc-4ab3-7805-f23b5df3d9a3@redhat.com \
    --to=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).