From patchwork Tue Sep 3 06:18:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 11127237 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9156D14E5 for ; Tue, 3 Sep 2019 06:20:30 +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 6E745215EA for ; Tue, 3 Sep 2019 06:20:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6E745215EA 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:41960 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i52B3-0000NW-2U for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Sep 2019 02:20:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57001) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i529e-0007BH-Es for qemu-devel@nongnu.org; Tue, 03 Sep 2019 02:19:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i529d-0003Xl-Ek for qemu-devel@nongnu.org; Tue, 03 Sep 2019 02:19:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47922) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i529d-0003XG-9b for qemu-devel@nongnu.org; Tue, 03 Sep 2019 02:19:01 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 24FBC307CDFC for ; Tue, 3 Sep 2019 06:19:00 +0000 (UTC) Received: from thuth.com (ovpn-116-80.ams2.redhat.com [10.36.116.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id 59B53600C6; Tue, 3 Sep 2019 06:18:58 +0000 (UTC) From: Thomas Huth To: Laurent Vivier , qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 08:18:44 +0200 Message-Id: <20190903061849.21493-2-thuth@redhat.com> In-Reply-To: <20190903061849.21493-1-thuth@redhat.com> References: <20190903061849.21493-1-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 03 Sep 2019 06:19:00 +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: [Qemu-devel] [PATCH 1/6] tests/migration: Do not use functions anymore that rely on global_qtest 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" The migration tests deal with multiple test states, so we really should not use functions here that rely on the single global_qtest variable. Switch from qtest_start() to qtest_init() to make sure that global_qtest is not set anymore. This also revealed a regression in the migrate() function: It has once been converted to use the qtest_qmp() function, but commit b5bbd3f315d686bd511 ("Clean up string interpolation into QMP, part 2") accidentally reverted it back to qmp(). Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Thomas Huth Reviewed-by: Laurent Vivier --- tests/migration-test.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/migration-test.c b/tests/migration-test.c index b87ba99a9e..a9f81cc185 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -490,7 +490,7 @@ static void migrate(QTestState *who, const char *uri, const char *fmt, ...) g_assert(!qdict_haskey(args, "uri")); qdict_put_str(args, "uri", uri); - rsp = qmp("{ 'execute': 'migrate', 'arguments': %p}", args); + rsp = qtest_qmp(who, "{ 'execute': 'migrate', 'arguments': %p}", args); g_assert(qdict_haskey(rsp, "return")); qobject_unref(rsp); @@ -625,7 +625,7 @@ static int test_migrate_start(QTestState **from, QTestState **to, cmd_dst = tmp; } - *from = qtest_start(cmd_src); + *from = qtest_init(cmd_src); g_free(cmd_src); *to = qtest_init(cmd_dst); @@ -715,7 +715,7 @@ static void test_deprecated(void) { QTestState *from; - from = qtest_start("-machine none"); + from = qtest_init("-machine none"); deprecated_set_downtime(from, 0.12345); deprecated_set_speed(from, 12345); From patchwork Tue Sep 3 06:18:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 11127241 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0F58213B1 for ; Tue, 3 Sep 2019 06:20:40 +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 E4A77215EA for ; Tue, 3 Sep 2019 06:20:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E4A77215EA 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:41964 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i52BC-0000c0-6E for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Sep 2019 02:20:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57017) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i529h-0007CJ-DJ for qemu-devel@nongnu.org; Tue, 03 Sep 2019 02:19:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i529f-0003Z2-GW for qemu-devel@nongnu.org; Tue, 03 Sep 2019 02:19:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46992) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i529e-0003YB-VA for qemu-devel@nongnu.org; Tue, 03 Sep 2019 02:19:03 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EFEF418C4267 for ; Tue, 3 Sep 2019 06:19:01 +0000 (UTC) Received: from thuth.com (ovpn-116-80.ams2.redhat.com [10.36.116.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D532600C6; Tue, 3 Sep 2019 06:19:00 +0000 (UTC) From: Thomas Huth To: Laurent Vivier , qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 08:18:45 +0200 Message-Id: <20190903061849.21493-3-thuth@redhat.com> In-Reply-To: <20190903061849.21493-1-thuth@redhat.com> References: <20190903061849.21493-1-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.62]); Tue, 03 Sep 2019 06:19:01 +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: [Qemu-devel] [PATCH 2/6] tests/libqos/e1000e: Make e1000e libqos functions independent from global_qtest 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" libqos library functions should never depend on functions (like memread(), memwrite() or clock_step()) that require global_qtest to be set, since library functions might get used in qtests that track multiple states, too. Thus let's replace the global_qtest-related functions with their independent counterparts. Signed-off-by: Thomas Huth Reviewed-by: Laurent Vivier --- tests/libqos/e1000e.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/libqos/e1000e.c b/tests/libqos/e1000e.c index 1d0592974e..560e7a2bb2 100644 --- a/tests/libqos/e1000e.c +++ b/tests/libqos/e1000e.c @@ -85,26 +85,32 @@ static uint32_t e1000e_macreg_read(QE1000E *d, uint32_t reg) void e1000e_tx_ring_push(QE1000E *d, void *descr) { + QE1000E_PCI *d_pci = container_of(d, QE1000E_PCI, e1000e); uint32_t tail = e1000e_macreg_read(d, E1000E_TDT); uint32_t len = e1000e_macreg_read(d, E1000E_TDLEN) / E1000E_TXD_LEN; - memwrite(d->tx_ring + tail * E1000E_TXD_LEN, descr, E1000E_TXD_LEN); + qtest_memwrite(d_pci->pci_dev.bus->qts, d->tx_ring + tail * E1000E_TXD_LEN, + descr, E1000E_TXD_LEN); e1000e_macreg_write(d, E1000E_TDT, (tail + 1) % len); /* Read WB data for the packet transmitted */ - memread(d->tx_ring + tail * E1000E_TXD_LEN, descr, E1000E_TXD_LEN); + qtest_memread(d_pci->pci_dev.bus->qts, d->tx_ring + tail * E1000E_TXD_LEN, + descr, E1000E_TXD_LEN); } void e1000e_rx_ring_push(QE1000E *d, void *descr) { + QE1000E_PCI *d_pci = container_of(d, QE1000E_PCI, e1000e); uint32_t tail = e1000e_macreg_read(d, E1000E_RDT); uint32_t len = e1000e_macreg_read(d, E1000E_RDLEN) / E1000E_RXD_LEN; - memwrite(d->rx_ring + tail * E1000E_RXD_LEN, descr, E1000E_RXD_LEN); + qtest_memwrite(d_pci->pci_dev.bus->qts, d->rx_ring + tail * E1000E_RXD_LEN, + descr, E1000E_RXD_LEN); e1000e_macreg_write(d, E1000E_RDT, (tail + 1) % len); /* Read WB data for the packet received */ - memread(d->rx_ring + tail * E1000E_RXD_LEN, descr, E1000E_RXD_LEN); + qtest_memread(d_pci->pci_dev.bus->qts, d->rx_ring + tail * E1000E_RXD_LEN, + descr, E1000E_RXD_LEN); } static void e1000e_foreach_callback(QPCIDevice *dev, int devfn, void *data) @@ -123,7 +129,7 @@ void e1000e_wait_isr(QE1000E *d, uint16_t msg_id) if (qpci_msix_pending(&d_pci->pci_dev, msg_id)) { return; } - clock_step(10000); + qtest_clock_step(d_pci->pci_dev.bus->qts, 10000); } while (g_get_monotonic_time() < end_time); g_error("Timeout expired"); From patchwork Tue Sep 3 06:18:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 11127247 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A33B514E5 for ; Tue, 3 Sep 2019 06:23:18 +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 83B0121897 for ; Tue, 3 Sep 2019 06:23:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 83B0121897 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:41992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i52Dl-0003Io-M5 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Sep 2019 02:23:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57034) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i529i-0007EL-RS for qemu-devel@nongnu.org; Tue, 03 Sep 2019 02:19:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i529h-0003aH-Hr for qemu-devel@nongnu.org; Tue, 03 Sep 2019 02:19:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34076) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i529h-0003ZG-AF for qemu-devel@nongnu.org; Tue, 03 Sep 2019 02:19:05 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C8D5FC054C52 for ; Tue, 3 Sep 2019 06:19:03 +0000 (UTC) Received: from thuth.com (ovpn-116-80.ams2.redhat.com [10.36.116.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id 57B2460127; Tue, 3 Sep 2019 06:19:02 +0000 (UTC) From: Thomas Huth To: Laurent Vivier , qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 08:18:46 +0200 Message-Id: <20190903061849.21493-4-thuth@redhat.com> In-Reply-To: <20190903061849.21493-1-thuth@redhat.com> References: <20190903061849.21493-1-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 03 Sep 2019 06:19:03 +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: [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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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); 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); From patchwork Tue Sep 3 06:18:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 11127245 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3952C13B1 for ; Tue, 3 Sep 2019 06:23:17 +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 18A0C20882 for ; Tue, 3 Sep 2019 06:23:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 18A0C20882 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:41990 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i52Dk-0003GG-3z for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Sep 2019 02:23:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57043) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i529j-0007FF-Gx for qemu-devel@nongnu.org; Tue, 03 Sep 2019 02:19:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i529i-0003al-E6 for qemu-devel@nongnu.org; Tue, 03 Sep 2019 02:19:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34116) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i529i-0003aN-9I for qemu-devel@nongnu.org; Tue, 03 Sep 2019 02:19:06 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A269E8AC6E1 for ; Tue, 3 Sep 2019 06:19:05 +0000 (UTC) Received: from thuth.com (ovpn-116-80.ams2.redhat.com [10.36.116.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id 311A5600C6; Tue, 3 Sep 2019 06:19:03 +0000 (UTC) From: Thomas Huth To: Laurent Vivier , qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 08:18:47 +0200 Message-Id: <20190903061849.21493-5-thuth@redhat.com> In-Reply-To: <20190903061849.21493-1-thuth@redhat.com> References: <20190903061849.21493-1-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.69]); Tue, 03 Sep 2019 06:19:05 +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: [Qemu-devel] [PATCH 4/6] tests: Remove unnecessary global_qtest references 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" We are going to remove global_qtest from the main libqtest library soon, so tests that do not urgently need global_qtest anymore should be cleaned from the unnecessary references. Signed-off-by: Thomas Huth --- tests/ahci-test.c | 1 - tests/bios-tables-test.c | 1 - tests/ivshmem-test.c | 3 --- tests/rtas-test.c | 1 - 4 files changed, 6 deletions(-) diff --git a/tests/ahci-test.c b/tests/ahci-test.c index 086811e602..c8d42ceea0 100644 --- a/tests/ahci-test.c +++ b/tests/ahci-test.c @@ -200,7 +200,6 @@ static void ahci_shutdown(AHCIQState *ahci) { QOSState *qs = ahci->parent; - assert(!global_qtest); ahci_clean_mem(ahci); free_ahci_device(ahci->dev); g_free(ahci); diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c index a356ac3489..9b3d8b0d1b 100644 --- a/tests/bios-tables-test.c +++ b/tests/bios-tables-test.c @@ -626,7 +626,6 @@ static void test_acpi_one(const char *params, test_data *data) test_smbios_structs(data); } - assert(!global_qtest); qtest_quit(data->qts); g_free(args); } diff --git a/tests/ivshmem-test.c b/tests/ivshmem-test.c index b76457948b..be9aa92a61 100644 --- a/tests/ivshmem-test.c +++ b/tests/ivshmem-test.c @@ -100,7 +100,6 @@ static inline void write_mem(IVState *s, uint64_t off, static void cleanup_vm(IVState *s) { - assert(!global_qtest); g_free(s->dev); qtest_shutdown(s->qs); } @@ -388,7 +387,6 @@ static void test_ivshmem_hotplug(void) qts = qtest_init("-object memory-backend-ram,size=1M,id=mb1"); - global_qtest = qts; /* TODO: Get rid of global_qtest here */ qtest_qmp_device_add(qts, "ivshmem-plain", "iv1", "{'addr': %s, 'memdev': 'mb1'}", stringify(PCI_SLOT_HP)); @@ -397,7 +395,6 @@ static void test_ivshmem_hotplug(void) } qtest_quit(qts); - global_qtest = NULL; } static void test_ivshmem_memdev(void) diff --git a/tests/rtas-test.c b/tests/rtas-test.c index ee888676ed..167b42db38 100644 --- a/tests/rtas-test.c +++ b/tests/rtas-test.c @@ -14,7 +14,6 @@ static void test_rtas_get_time_of_day(void) time_t t1, t2; qs = qtest_spapr_boot("-machine pseries"); - global_qtest = qs->qts; t1 = time(NULL); ret = qrtas_get_time_of_day(qs->qts, &qs->alloc, &tm, &ns); From patchwork Tue Sep 3 06:18:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 11127251 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E7AC814E5 for ; Tue, 3 Sep 2019 06:24:29 +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 77A5920882 for ; Tue, 3 Sep 2019 06:24:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 77A5920882 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i52Eu-0004d4-5h for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Sep 2019 02:24:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57063) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i529m-0007Jj-RO for qemu-devel@nongnu.org; Tue, 03 Sep 2019 02:19:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i529k-0003cP-IN for qemu-devel@nongnu.org; Tue, 03 Sep 2019 02:19:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48006) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i529k-0003bq-Ac for qemu-devel@nongnu.org; Tue, 03 Sep 2019 02:19:08 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A8158307CDFC for ; Tue, 3 Sep 2019 06:19:07 +0000 (UTC) Received: from thuth.com (ovpn-116-80.ams2.redhat.com [10.36.116.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A9A4600C6; Tue, 3 Sep 2019 06:19:05 +0000 (UTC) From: Thomas Huth To: Laurent Vivier , qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 08:18:48 +0200 Message-Id: <20190903061849.21493-6-thuth@redhat.com> In-Reply-To: <20190903061849.21493-1-thuth@redhat.com> References: <20190903061849.21493-1-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 03 Sep 2019 06:19:07 +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: [Qemu-devel] [PATCH 5/6] tests/libqtest: Move global_test wrapper function into a separate header 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" We want libqtest.h to become completely independen from global_qtest (so that the wrapper functions are not used by accident anymore). As a first step, move the wrapper functions into a separate header file. Signed-off-by: Thomas Huth --- MAINTAINERS | 2 +- tests/libqtest-single.h | 311 ++++++++++++++++++++++++++++++++++++++++ tests/libqtest.c | 11 -- tests/libqtest.h | 287 +----------------------------------- 4 files changed, 313 insertions(+), 298 deletions(-) create mode 100644 tests/libqtest-single.h diff --git a/MAINTAINERS b/MAINTAINERS index ef6c01084b..b01bf0902a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2078,7 +2078,7 @@ R: Paolo Bonzini S: Maintained F: qtest.c F: accel/qtest.c -F: tests/libqtest.* +F: tests/libqtest* F: tests/libqos/ F: tests/*-test.c diff --git a/tests/libqtest-single.h b/tests/libqtest-single.h new file mode 100644 index 0000000000..49259558a5 --- /dev/null +++ b/tests/libqtest-single.h @@ -0,0 +1,311 @@ +/* + * QTest - wrappers for test with single QEMU instances + * + * Copyright IBM, Corp. 2012 + * Copyright Red Hat, Inc. 2012 + * Copyright SUSE LINUX Products GmbH 2013 + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#ifndef LIBQTEST_SINGLE_H +#define LIBQTEST_SINGLE_H + +/** + * qtest_start: + * @args: other arguments to pass to QEMU + * + * Start QEMU and assign the resulting #QTestState to a global variable. + * The global variable is used by "shortcut" functions documented below. + * + * Returns: #QTestState instance. + */ +static inline QTestState *qtest_start(const char *args) +{ + global_qtest = qtest_init(args); + return global_qtest; +} + +/** + * qtest_end: + * + * Shut down the QEMU process started by qtest_start(). + */ +static inline void qtest_end(void) +{ + if (!global_qtest) { + return; + } + qtest_quit(global_qtest); + global_qtest = NULL; +} + +/** + * qmp: + * @fmt...: QMP message to send to qemu, formatted like + * qobject_from_jsonf_nofail(). See parse_escape() for what's + * supported after '%'. + * + * Sends a QMP message to QEMU and returns the response. + */ +GCC_FMT_ATTR(1, 2) +static inline QDict *qmp(const char *fmt, ...) +{ + va_list ap; + QDict *response; + + va_start(ap, fmt); + response = qtest_vqmp(global_qtest, fmt, ap); + va_end(ap); + return response; +} + +/** + * qmp_eventwait: + * @s: #event event to wait for. + * + * Continuously polls for QMP responses until it receives the desired event. + */ +static inline void qmp_eventwait(const char *event) +{ + return qtest_qmp_eventwait(global_qtest, event); +} + +/** + * get_irq: + * @num: Interrupt to observe. + * + * Returns: The level of the @num interrupt. + */ +static inline bool get_irq(int num) +{ + return qtest_get_irq(global_qtest, num); +} + +/** + * outb: + * @addr: I/O port to write to. + * @value: Value being written. + * + * Write an 8-bit value to an I/O port. + */ +static inline void outb(uint16_t addr, uint8_t value) +{ + qtest_outb(global_qtest, addr, value); +} + +/** + * outw: + * @addr: I/O port to write to. + * @value: Value being written. + * + * Write a 16-bit value to an I/O port. + */ +static inline void outw(uint16_t addr, uint16_t value) +{ + qtest_outw(global_qtest, addr, value); +} + +/** + * outl: + * @addr: I/O port to write to. + * @value: Value being written. + * + * Write a 32-bit value to an I/O port. + */ +static inline void outl(uint16_t addr, uint32_t value) +{ + qtest_outl(global_qtest, addr, value); +} + +/** + * inb: + * @addr: I/O port to read from. + * + * Reads an 8-bit value from an I/O port. + * + * Returns: Value read. + */ +static inline uint8_t inb(uint16_t addr) +{ + return qtest_inb(global_qtest, addr); +} + +/** + * inw: + * @addr: I/O port to read from. + * + * Reads a 16-bit value from an I/O port. + * + * Returns: Value read. + */ +static inline uint16_t inw(uint16_t addr) +{ + return qtest_inw(global_qtest, addr); +} + +/** + * inl: + * @addr: I/O port to read from. + * + * Reads a 32-bit value from an I/O port. + * + * Returns: Value read. + */ +static inline uint32_t inl(uint16_t addr) +{ + return qtest_inl(global_qtest, addr); +} + +/** + * writeb: + * @addr: Guest address to write to. + * @value: Value being written. + * + * Writes an 8-bit value to guest memory. + */ +static inline void writeb(uint64_t addr, uint8_t value) +{ + qtest_writeb(global_qtest, addr, value); +} + +/** + * writew: + * @addr: Guest address to write to. + * @value: Value being written. + * + * Writes a 16-bit value to guest memory. + */ +static inline void writew(uint64_t addr, uint16_t value) +{ + qtest_writew(global_qtest, addr, value); +} + +/** + * writel: + * @addr: Guest address to write to. + * @value: Value being written. + * + * Writes a 32-bit value to guest memory. + */ +static inline void writel(uint64_t addr, uint32_t value) +{ + qtest_writel(global_qtest, addr, value); +} + +/** + * writeq: + * @addr: Guest address to write to. + * @value: Value being written. + * + * Writes a 64-bit value to guest memory. + */ +static inline void writeq(uint64_t addr, uint64_t value) +{ + qtest_writeq(global_qtest, addr, value); +} + +/** + * readb: + * @addr: Guest address to read from. + * + * Reads an 8-bit value from guest memory. + * + * Returns: Value read. + */ +static inline uint8_t readb(uint64_t addr) +{ + return qtest_readb(global_qtest, addr); +} + +/** + * readw: + * @addr: Guest address to read from. + * + * Reads a 16-bit value from guest memory. + * + * Returns: Value read. + */ +static inline uint16_t readw(uint64_t addr) +{ + return qtest_readw(global_qtest, addr); +} + +/** + * readl: + * @addr: Guest address to read from. + * + * Reads a 32-bit value from guest memory. + * + * Returns: Value read. + */ +static inline uint32_t readl(uint64_t addr) +{ + return qtest_readl(global_qtest, addr); +} + +/** + * readq: + * @addr: Guest address to read from. + * + * Reads a 64-bit value from guest memory. + * + * Returns: Value read. + */ +static inline uint64_t readq(uint64_t addr) +{ + return qtest_readq(global_qtest, addr); +} + +/** + * memread: + * @addr: Guest address to read from. + * @data: Pointer to where memory contents will be stored. + * @size: Number of bytes to read. + * + * Read guest memory into a buffer. + */ +static inline void memread(uint64_t addr, void *data, size_t size) +{ + qtest_memread(global_qtest, addr, data, size); +} + +/** + * memwrite: + * @addr: Guest address to write to. + * @data: Pointer to the bytes that will be written to guest memory. + * @size: Number of bytes to write. + * + * Write a buffer to guest memory. + */ +static inline void memwrite(uint64_t addr, const void *data, size_t size) +{ + qtest_memwrite(global_qtest, addr, data, size); +} + +/** + * clock_step_next: + * + * Advance the QEMU_CLOCK_VIRTUAL to the next deadline. + * + * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds. + */ +static inline int64_t clock_step_next(void) +{ + return qtest_clock_step_next(global_qtest); +} + +/** + * clock_step: + * @step: Number of nanoseconds to advance the clock by. + * + * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds. + * + * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds. + */ +static inline int64_t clock_step(int64_t step) +{ + return qtest_clock_step(global_qtest, step); +} + +#endif diff --git a/tests/libqtest.c b/tests/libqtest.c index 2713b86cf7..e5101d9d3a 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -1106,17 +1106,6 @@ void qtest_memset(QTestState *s, uint64_t addr, uint8_t pattern, size_t size) qtest_rsp(s, 0); } -QDict *qmp(const char *fmt, ...) -{ - va_list ap; - QDict *response; - - va_start(ap, fmt); - response = qtest_vqmp(global_qtest, fmt, ap); - va_end(ap); - return response; -} - void qtest_qmp_assert_success(QTestState *qts, const char *fmt, ...) { va_list ap; diff --git a/tests/libqtest.h b/tests/libqtest.h index 07ea35867c..6a7d7e41ad 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -628,45 +628,6 @@ void qtest_add_data_func_full(const char *str, void *data, void qtest_add_abrt_handler(GHookFunc fn, const void *data); -/** - * qtest_start: - * @args: other arguments to pass to QEMU - * - * Start QEMU and assign the resulting #QTestState to a global variable. - * The global variable is used by "shortcut" functions documented below. - * - * Returns: #QTestState instance. - */ -static inline QTestState *qtest_start(const char *args) -{ - global_qtest = qtest_init(args); - return global_qtest; -} - -/** - * qtest_end: - * - * Shut down the QEMU process started by qtest_start(). - */ -static inline void qtest_end(void) -{ - if (!global_qtest) { - return; - } - qtest_quit(global_qtest); - global_qtest = NULL; -} - -/** - * qmp: - * @fmt...: QMP message to send to qemu, formatted like - * qobject_from_jsonf_nofail(). See parse_escape() for what's - * supported after '%'. - * - * Sends a QMP message to QEMU and returns the response. - */ -QDict *qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2); - /** * qtest_qmp_assert_success: * @qts: QTestState instance to operate on @@ -680,253 +641,7 @@ QDict *qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2); void qtest_qmp_assert_success(QTestState *qts, const char *fmt, ...) GCC_FMT_ATTR(2, 3); -/* - * qmp_eventwait: - * @s: #event event to wait for. - * - * Continuously polls for QMP responses until it receives the desired event. - */ -static inline void qmp_eventwait(const char *event) -{ - return qtest_qmp_eventwait(global_qtest, event); -} - -/** - * get_irq: - * @num: Interrupt to observe. - * - * Returns: The level of the @num interrupt. - */ -static inline bool get_irq(int num) -{ - return qtest_get_irq(global_qtest, num); -} - -/** - * outb: - * @addr: I/O port to write to. - * @value: Value being written. - * - * Write an 8-bit value to an I/O port. - */ -static inline void outb(uint16_t addr, uint8_t value) -{ - qtest_outb(global_qtest, addr, value); -} - -/** - * outw: - * @addr: I/O port to write to. - * @value: Value being written. - * - * Write a 16-bit value to an I/O port. - */ -static inline void outw(uint16_t addr, uint16_t value) -{ - qtest_outw(global_qtest, addr, value); -} - -/** - * outl: - * @addr: I/O port to write to. - * @value: Value being written. - * - * Write a 32-bit value to an I/O port. - */ -static inline void outl(uint16_t addr, uint32_t value) -{ - qtest_outl(global_qtest, addr, value); -} - -/** - * inb: - * @addr: I/O port to read from. - * - * Reads an 8-bit value from an I/O port. - * - * Returns: Value read. - */ -static inline uint8_t inb(uint16_t addr) -{ - return qtest_inb(global_qtest, addr); -} - -/** - * inw: - * @addr: I/O port to read from. - * - * Reads a 16-bit value from an I/O port. - * - * Returns: Value read. - */ -static inline uint16_t inw(uint16_t addr) -{ - return qtest_inw(global_qtest, addr); -} - -/** - * inl: - * @addr: I/O port to read from. - * - * Reads a 32-bit value from an I/O port. - * - * Returns: Value read. - */ -static inline uint32_t inl(uint16_t addr) -{ - return qtest_inl(global_qtest, addr); -} - -/** - * writeb: - * @addr: Guest address to write to. - * @value: Value being written. - * - * Writes an 8-bit value to guest memory. - */ -static inline void writeb(uint64_t addr, uint8_t value) -{ - qtest_writeb(global_qtest, addr, value); -} - -/** - * writew: - * @addr: Guest address to write to. - * @value: Value being written. - * - * Writes a 16-bit value to guest memory. - */ -static inline void writew(uint64_t addr, uint16_t value) -{ - qtest_writew(global_qtest, addr, value); -} - -/** - * writel: - * @addr: Guest address to write to. - * @value: Value being written. - * - * Writes a 32-bit value to guest memory. - */ -static inline void writel(uint64_t addr, uint32_t value) -{ - qtest_writel(global_qtest, addr, value); -} - -/** - * writeq: - * @addr: Guest address to write to. - * @value: Value being written. - * - * Writes a 64-bit value to guest memory. - */ -static inline void writeq(uint64_t addr, uint64_t value) -{ - qtest_writeq(global_qtest, addr, value); -} - -/** - * readb: - * @addr: Guest address to read from. - * - * Reads an 8-bit value from guest memory. - * - * Returns: Value read. - */ -static inline uint8_t readb(uint64_t addr) -{ - return qtest_readb(global_qtest, addr); -} - -/** - * readw: - * @addr: Guest address to read from. - * - * Reads a 16-bit value from guest memory. - * - * Returns: Value read. - */ -static inline uint16_t readw(uint64_t addr) -{ - return qtest_readw(global_qtest, addr); -} - -/** - * readl: - * @addr: Guest address to read from. - * - * Reads a 32-bit value from guest memory. - * - * Returns: Value read. - */ -static inline uint32_t readl(uint64_t addr) -{ - return qtest_readl(global_qtest, addr); -} - -/** - * readq: - * @addr: Guest address to read from. - * - * Reads a 64-bit value from guest memory. - * - * Returns: Value read. - */ -static inline uint64_t readq(uint64_t addr) -{ - return qtest_readq(global_qtest, addr); -} - -/** - * memread: - * @addr: Guest address to read from. - * @data: Pointer to where memory contents will be stored. - * @size: Number of bytes to read. - * - * Read guest memory into a buffer. - */ -static inline void memread(uint64_t addr, void *data, size_t size) -{ - qtest_memread(global_qtest, addr, data, size); -} - -/** - * memwrite: - * @addr: Guest address to write to. - * @data: Pointer to the bytes that will be written to guest memory. - * @size: Number of bytes to write. - * - * Write a buffer to guest memory. - */ -static inline void memwrite(uint64_t addr, const void *data, size_t size) -{ - qtest_memwrite(global_qtest, addr, data, size); -} - -/** - * clock_step_next: - * - * Advance the QEMU_CLOCK_VIRTUAL to the next deadline. - * - * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds. - */ -static inline int64_t clock_step_next(void) -{ - return qtest_clock_step_next(global_qtest); -} - -/** - * clock_step: - * @step: Number of nanoseconds to advance the clock by. - * - * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds. - * - * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds. - */ -static inline int64_t clock_step(int64_t step) -{ - return qtest_clock_step(global_qtest, step); -} +#include "libqtest-single.h" QDict *qmp_fd_receive(int fd); void qmp_fd_vsend_fds(int fd, int *fds, size_t fds_num, From patchwork Tue Sep 3 06:18:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 11127243 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0408513B1 for ; Tue, 3 Sep 2019 06:20:52 +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 C9249215EA for ; Tue, 3 Sep 2019 06:20:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C9249215EA 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:41966 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i52BO-0000mg-Ou for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Sep 2019 02:20:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57073) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i529p-0007Lr-B5 for qemu-devel@nongnu.org; Tue, 03 Sep 2019 02:19:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i529m-0003e2-Az for qemu-devel@nongnu.org; Tue, 03 Sep 2019 02:19:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41158) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i529m-0003dV-3F for qemu-devel@nongnu.org; Tue, 03 Sep 2019 02:19:10 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6F91D308A968 for ; Tue, 3 Sep 2019 06:19:09 +0000 (UTC) Received: from thuth.com (ovpn-116-80.ams2.redhat.com [10.36.116.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CEE4600C6; Tue, 3 Sep 2019 06:19:07 +0000 (UTC) From: Thomas Huth To: Laurent Vivier , qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 08:18:49 +0200 Message-Id: <20190903061849.21493-7-thuth@redhat.com> In-Reply-To: <20190903061849.21493-1-thuth@redhat.com> References: <20190903061849.21493-1-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Tue, 03 Sep 2019 06:19:09 +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: [Qemu-devel] [PATCH 6/6] tests/libqtest: Use libqtest-single.h in tests that require global_qtest 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Tests that require global_qtest or the related wrapper functions now use the libqtest-single.h header that is dedicated for everything related to global_qtest. The core libqtest.c and libqtest.h files are now completely indepedent from global_qtest, so that the core library is now not depending on a global state anymore. Signed-off-by: Thomas Huth --- tests/cpu-plug-test.c | 2 +- tests/display-vga-test.c | 2 +- tests/e1000e-test.c | 2 +- tests/fdc-test.c | 2 +- tests/i440fx-test.c | 2 +- tests/i82801b11-test.c | 2 +- tests/intel-hda-test.c | 2 +- tests/ioh3420-test.c | 2 +- tests/ipmi-kcs-test.c | 3 +-- tests/libqtest-single.h | 4 ++++ tests/libqtest.c | 2 -- tests/libqtest.h | 4 ---- tests/qos-test.c | 2 +- tests/rtc-test.c | 2 +- tests/rtl8139-test.c | 2 +- tests/test-netfilter.c | 2 +- tests/test-x86-cpuid-compat.c | 2 +- tests/tmp105-test.c | 2 +- tests/tpm-crb-test.c | 2 +- tests/tpm-tests.c | 2 +- tests/tpm-tis-test.c | 2 +- tests/usb-hcd-ohci-test.c | 2 +- tests/usb-hcd-uhci-test.c | 2 +- tests/usb-hcd-xhci-test.c | 2 +- tests/vhost-user-test.c | 2 +- tests/virtio-blk-test.c | 2 +- tests/virtio-ccw-test.c | 2 +- tests/virtio-net-test.c | 2 +- tests/virtio-scsi-test.c | 2 +- tests/virtio-serial-test.c | 2 +- 30 files changed, 31 insertions(+), 34 deletions(-) diff --git a/tests/cpu-plug-test.c b/tests/cpu-plug-test.c index 3049620854..776407e1b6 100644 --- a/tests/cpu-plug-test.c +++ b/tests/cpu-plug-test.c @@ -10,7 +10,7 @@ #include "qemu/osdep.h" #include "qemu-common.h" -#include "libqtest.h" +#include "libqtest-single.h" #include "qapi/qmp/qdict.h" struct PlugTestData { diff --git a/tests/display-vga-test.c b/tests/display-vga-test.c index bd176dcf3a..ace3bb28e0 100644 --- a/tests/display-vga-test.c +++ b/tests/display-vga-test.c @@ -8,7 +8,7 @@ */ #include "qemu/osdep.h" -#include "libqtest.h" +#include "libqtest-single.h" static void pci_cirrus(void) { diff --git a/tests/e1000e-test.c b/tests/e1000e-test.c index 93628c588d..1a232a663a 100644 --- a/tests/e1000e-test.c +++ b/tests/e1000e-test.c @@ -26,7 +26,7 @@ #include "qemu/osdep.h" #include "qemu-common.h" -#include "libqtest.h" +#include "libqtest-single.h" #include "qemu-common.h" #include "libqos/pci-pc.h" #include "qemu/sockets.h" diff --git a/tests/fdc-test.c b/tests/fdc-test.c index 31cd3295c1..26b69f7c5c 100644 --- a/tests/fdc-test.c +++ b/tests/fdc-test.c @@ -25,7 +25,7 @@ #include "qemu/osdep.h" -#include "libqtest.h" +#include "libqtest-single.h" #include "qapi/qmp/qdict.h" #include "qemu-common.h" diff --git a/tests/i440fx-test.c b/tests/i440fx-test.c index 69205b58a8..1f57d9684b 100644 --- a/tests/i440fx-test.c +++ b/tests/i440fx-test.c @@ -14,7 +14,7 @@ #include "qemu/osdep.h" -#include "libqtest.h" +#include "libqtest-single.h" #include "libqos/pci.h" #include "libqos/pci-pc.h" #include "hw/pci/pci_regs.h" diff --git a/tests/i82801b11-test.c b/tests/i82801b11-test.c index a6e31594c9..4345da338b 100644 --- a/tests/i82801b11-test.c +++ b/tests/i82801b11-test.c @@ -8,7 +8,7 @@ */ #include "qemu/osdep.h" -#include "libqtest.h" +#include "libqtest-single.h" /* Tests only initialization so far. TODO: Replace with functional tests */ static void nop(void) diff --git a/tests/intel-hda-test.c b/tests/intel-hda-test.c index b782b2e944..fc25ccc33c 100644 --- a/tests/intel-hda-test.c +++ b/tests/intel-hda-test.c @@ -8,7 +8,7 @@ */ #include "qemu/osdep.h" -#include "libqtest.h" +#include "libqtest-single.h" #define HDA_ID "hda0" #define CODEC_DEVICES " -device hda-output,bus=" HDA_ID ".0" \ diff --git a/tests/ioh3420-test.c b/tests/ioh3420-test.c index b54c4b9f11..f6ca43cca7 100644 --- a/tests/ioh3420-test.c +++ b/tests/ioh3420-test.c @@ -8,7 +8,7 @@ */ #include "qemu/osdep.h" -#include "libqtest.h" +#include "libqtest-single.h" /* Tests only initialization so far. TODO: Replace with functional tests */ static void nop(void) diff --git a/tests/ipmi-kcs-test.c b/tests/ipmi-kcs-test.c index a2354c10c7..693a6aacb5 100644 --- a/tests/ipmi-kcs-test.c +++ b/tests/ipmi-kcs-test.c @@ -24,8 +24,7 @@ #include "qemu/osdep.h" - -#include "libqtest.h" +#include "libqtest-single.h" #define IPMI_IRQ 5 diff --git a/tests/libqtest-single.h b/tests/libqtest-single.h index 49259558a5..6f1bb1331c 100644 --- a/tests/libqtest-single.h +++ b/tests/libqtest-single.h @@ -11,6 +11,10 @@ #ifndef LIBQTEST_SINGLE_H #define LIBQTEST_SINGLE_H +#include "libqtest.h" + +QTestState *global_qtest __attribute__((common, weak)); + /** * qtest_start: * @args: other arguments to pass to QEMU diff --git a/tests/libqtest.c b/tests/libqtest.c index e5101d9d3a..0a6b91737e 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -35,8 +35,6 @@ #define SOCKET_TIMEOUT 50 #define SOCKET_MAX_FDS 16 -QTestState *global_qtest; - struct QTestState { int fd; diff --git a/tests/libqtest.h b/tests/libqtest.h index 6a7d7e41ad..c8cffe5d68 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -22,8 +22,6 @@ typedef struct QTestState QTestState; -extern QTestState *global_qtest; - /** * qtest_initf: * @fmt...: Format for creating other arguments to pass to QEMU, formatted @@ -641,8 +639,6 @@ void qtest_add_abrt_handler(GHookFunc fn, const void *data); void qtest_qmp_assert_success(QTestState *qts, const char *fmt, ...) GCC_FMT_ATTR(2, 3); -#include "libqtest-single.h" - QDict *qmp_fd_receive(int fd); void qmp_fd_vsend_fds(int fd, int *fds, size_t fds_num, const char *fmt, va_list ap) GCC_FMT_ATTR(4, 0); diff --git a/tests/qos-test.c b/tests/qos-test.c index 3c0071b3b7..fd70d73ea5 100644 --- a/tests/qos-test.c +++ b/tests/qos-test.c @@ -18,7 +18,7 @@ #include "qemu/osdep.h" #include -#include "libqtest.h" +#include "libqtest-single.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qbool.h" #include "qapi/qmp/qstring.h" diff --git a/tests/rtc-test.c b/tests/rtc-test.c index 509be707e3..6309b0ef6c 100644 --- a/tests/rtc-test.c +++ b/tests/rtc-test.c @@ -13,7 +13,7 @@ #include "qemu/osdep.h" -#include "libqtest.h" +#include "libqtest-single.h" #include "qemu/timer.h" #include "hw/timer/mc146818rtc_regs.h" diff --git a/tests/rtl8139-test.c b/tests/rtl8139-test.c index d6d0c24909..4506049264 100644 --- a/tests/rtl8139-test.c +++ b/tests/rtl8139-test.c @@ -8,7 +8,7 @@ */ #include "qemu/osdep.h" -#include "libqtest.h" +#include "libqtest-single.h" #include "libqos/pci-pc.h" #include "qemu/timer.h" #include "qemu-common.h" diff --git a/tests/test-netfilter.c b/tests/test-netfilter.c index e47075dd06..22927ee6ab 100644 --- a/tests/test-netfilter.c +++ b/tests/test-netfilter.c @@ -9,7 +9,7 @@ */ #include "qemu/osdep.h" -#include "libqtest.h" +#include "libqtest-single.h" #include "qapi/qmp/qdict.h" /* add a netfilter to a netdev and then remove it */ diff --git a/tests/test-x86-cpuid-compat.c b/tests/test-x86-cpuid-compat.c index e75b959950..772287bdb4 100644 --- a/tests/test-x86-cpuid-compat.c +++ b/tests/test-x86-cpuid-compat.c @@ -4,7 +4,7 @@ #include "qapi/qmp/qlist.h" #include "qapi/qmp/qnum.h" #include "qapi/qmp/qbool.h" -#include "libqtest.h" +#include "libqtest-single.h" static char *get_cpu0_qom_path(void) { diff --git a/tests/tmp105-test.c b/tests/tmp105-test.c index f599309a4a..f930a96b83 100644 --- a/tests/tmp105-test.c +++ b/tests/tmp105-test.c @@ -9,7 +9,7 @@ #include "qemu/osdep.h" -#include "libqtest.h" +#include "libqtest-single.h" #include "libqos/qgraph.h" #include "libqos/i2c.h" #include "qapi/qmp/qdict.h" diff --git a/tests/tpm-crb-test.c b/tests/tpm-crb-test.c index a139caa51d..632fb7fbd8 100644 --- a/tests/tpm-crb-test.c +++ b/tests/tpm-crb-test.c @@ -15,7 +15,7 @@ #include "hw/acpi/tpm.h" #include "io/channel-socket.h" -#include "libqtest.h" +#include "libqtest-single.h" #include "qemu/module.h" #include "tpm-emu.h" diff --git a/tests/tpm-tests.c b/tests/tpm-tests.c index e640777aa9..6e45a0ba85 100644 --- a/tests/tpm-tests.c +++ b/tests/tpm-tests.c @@ -15,7 +15,7 @@ #include "qemu/osdep.h" #include -#include "libqtest.h" +#include "libqtest-single.h" #include "tpm-tests.h" static bool diff --git a/tests/tpm-tis-test.c b/tests/tpm-tis-test.c index 92a7e95aad..dcf30e05b7 100644 --- a/tests/tpm-tis-test.c +++ b/tests/tpm-tis-test.c @@ -17,7 +17,7 @@ #include "hw/acpi/tpm.h" #include "io/channel-socket.h" -#include "libqtest.h" +#include "libqtest-single.h" #include "qemu/module.h" #include "tpm-emu.h" diff --git a/tests/usb-hcd-ohci-test.c b/tests/usb-hcd-ohci-test.c index 0cd73b7363..19d760f3fb 100644 --- a/tests/usb-hcd-ohci-test.c +++ b/tests/usb-hcd-ohci-test.c @@ -8,7 +8,7 @@ */ #include "qemu/osdep.h" -#include "libqtest.h" +#include "libqtest-single.h" #include "qemu/module.h" #include "libqos/usb.h" #include "libqos/qgraph.h" diff --git a/tests/usb-hcd-uhci-test.c b/tests/usb-hcd-uhci-test.c index 2eef8e3d1c..7a117b64d9 100644 --- a/tests/usb-hcd-uhci-test.c +++ b/tests/usb-hcd-uhci-test.c @@ -8,7 +8,7 @@ */ #include "qemu/osdep.h" -#include "libqtest.h" +#include "libqtest-single.h" #include "libqos/libqos.h" #include "libqos/usb.h" #include "libqos/libqos-pc.h" diff --git a/tests/usb-hcd-xhci-test.c b/tests/usb-hcd-xhci-test.c index 01845371f9..10ef9d2a91 100644 --- a/tests/usb-hcd-xhci-test.c +++ b/tests/usb-hcd-xhci-test.c @@ -8,7 +8,7 @@ */ #include "qemu/osdep.h" -#include "libqtest.h" +#include "libqtest-single.h" #include "libqos/usb.h" diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index 6ae8a23688..91ea373ba5 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -10,7 +10,7 @@ #include "qemu/osdep.h" -#include "libqtest.h" +#include "libqtest-single.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" #include "qemu/config-file.h" diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c index 247fef0b0f..b41d907dc3 100644 --- a/tests/virtio-blk-test.c +++ b/tests/virtio-blk-test.c @@ -9,7 +9,7 @@ */ #include "qemu/osdep.h" -#include "libqtest.h" +#include "libqtest-single.h" #include "qemu/bswap.h" #include "qemu/module.h" #include "standard-headers/linux/virtio_blk.h" diff --git a/tests/virtio-ccw-test.c b/tests/virtio-ccw-test.c index 9f445ef4ad..d05236407b 100644 --- a/tests/virtio-ccw-test.c +++ b/tests/virtio-ccw-test.c @@ -14,7 +14,7 @@ */ #include "qemu/osdep.h" -#include "libqtest.h" +#include "libqtest-single.h" #include "libqos/virtio.h" static void virtio_balloon_nop(void) diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c index 840875aaae..a08e2ffe12 100644 --- a/tests/virtio-net-test.c +++ b/tests/virtio-net-test.c @@ -9,7 +9,7 @@ #include "qemu/osdep.h" #include "qemu-common.h" -#include "libqtest.h" +#include "libqtest-single.h" #include "qemu/iov.h" #include "qemu/module.h" #include "qapi/qmp/qdict.h" diff --git a/tests/virtio-scsi-test.c b/tests/virtio-scsi-test.c index 09348765d7..7c8f9b27f8 100644 --- a/tests/virtio-scsi-test.c +++ b/tests/virtio-scsi-test.c @@ -9,7 +9,7 @@ */ #include "qemu/osdep.h" -#include "libqtest.h" +#include "libqtest-single.h" #include "qemu/module.h" #include "scsi/constants.h" #include "libqos/libqos-pc.h" diff --git a/tests/virtio-serial-test.c b/tests/virtio-serial-test.c index e584ad76e8..2541034822 100644 --- a/tests/virtio-serial-test.c +++ b/tests/virtio-serial-test.c @@ -8,7 +8,7 @@ */ #include "qemu/osdep.h" -#include "libqtest.h" +#include "libqtest-single.h" #include "qemu/module.h" #include "libqos/virtio-serial.h"