From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B1C4C3A5A5 for ; Tue, 3 Sep 2019 08:53:57 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2E22321883 for ; Tue, 3 Sep 2019 08:53:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2E22321883 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:43016 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i54ZY-0006wT-Ai for qemu-devel@archiver.kernel.org; Tue, 03 Sep 2019 04:53:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56288) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i54YP-00069R-6T for qemu-devel@nongnu.org; Tue, 03 Sep 2019 04:52:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i54YK-00053X-KS for qemu-devel@nongnu.org; Tue, 03 Sep 2019 04:52:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53258) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i54YK-00053D-Cf for qemu-devel@nongnu.org; Tue, 03 Sep 2019 04:52:40 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B2431189DADE for ; Tue, 3 Sep 2019 08:52:38 +0000 (UTC) Received: from [10.36.116.225] (ovpn-116-225.ams2.redhat.com [10.36.116.225]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B8A260C83; Tue, 3 Sep 2019 08:52:32 +0000 (UTC) To: Thomas Huth , qemu-devel@nongnu.org References: <20190903061849.21493-1-thuth@redhat.com> <20190903061849.21493-4-thuth@redhat.com> From: Laurent Vivier Openpgp: preference=signencrypt Autocrypt: addr=lvivier@redhat.com; prefer-encrypt=mutual; keydata= mQINBFYFJhkBEAC2me7w2+RizYOKZM+vZCx69GTewOwqzHrrHSG07MUAxJ6AY29/+HYf6EY2 WoeuLWDmXE7A3oJoIsRecD6BXHTb0OYS20lS608anr3B0xn5g0BX7es9Mw+hV/pL+63EOCVm SUVTEQwbGQN62guOKnJJJfphbbv82glIC/Ei4Ky8BwZkUuXd7d5NFJKC9/GDrbWdj75cDNQx UZ9XXbXEKY9MHX83Uy7JFoiFDMOVHn55HnncflUncO0zDzY7CxFeQFwYRbsCXOUL9yBtqLer Ky8/yjBskIlNrp0uQSt9LMoMsdSjYLYhvk1StsNPg74+s4u0Q6z45+l8RAsgLw5OLtTa+ePM JyS7OIGNYxAX6eZk1+91a6tnqfyPcMbduxyBaYXn94HUG162BeuyBkbNoIDkB7pCByed1A7q q9/FbuTDwgVGVLYthYSfTtN0Y60OgNkWCMtFwKxRaXt1WFA5ceqinN/XkgA+vf2Ch72zBkJL RBIhfOPFv5f2Hkkj0MvsUXpOWaOjatiu0fpPo6Hw14UEpywke1z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Smd+hC3mcQ+4iX5bBPBPM oDqSoLt5w9GoQQ6gDVP2ZjTWqwSRMLzNr37rJjZ1pt0DCMMTbiYIUcrhX8eveCJtY7NGWNyx FCRkhxRuGcpwPmRVDwOl39MB3iTsRighiMnijkbLXiKoJ5CDVvX5yicNqYJPKh5MFXN1bvsB kmYiStMRbrD0HoY1kx5/VozBtc70OU0EB8Wrv9hZD+Ofp0T3KOr1RUHvCZoLURfFhSQ= Message-ID: <519996c7-cfdc-4ab3-7805-f23b5df3d9a3@redhat.com> 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 MIME-Version: 1.0 In-Reply-To: <20190903061849.21493-4-thuth@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.63]); Tue, 03 Sep 2019 08:52:38 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: Re: [Qemu-devel] [PATCH 3/6] tests/libqos: Replace clock_step with qtest_clock_step in virtio code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Stefan Hajnoczi Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 > --- > 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