From nobody Sat Apr 27 17:22:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518122013940444.8365029685814; Thu, 8 Feb 2018 12:33:33 -0800 (PST) Received: from localhost ([::1]:46033 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejssl-0006Zy-JU for importer@patchew.org; Thu, 08 Feb 2018 15:33:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45305) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejsVy-0002Hi-Q5 for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:09:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ejsVx-0002J9-BD for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:09:50 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:52620 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ejsVx-0002Ii-5J for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:09:49 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B58CE8182D1B for ; Thu, 8 Feb 2018 20:09:47 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-204-120.brq.redhat.com [10.40.204.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC0F2B07B8; Thu, 8 Feb 2018 20:09:46 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Thu, 8 Feb 2018 21:09:29 +0100 Message-Id: <1518120582-26647-2-git-send-email-thuth@redhat.com> In-Reply-To: <1518120582-26647-1-git-send-email-thuth@redhat.com> References: <1518120582-26647-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 08 Feb 2018 20:09:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 08 Feb 2018 20:09:47 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 01/14] tests: Clean up wait for event X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Markus Armbruster We still use hacks like qmp("") to wait for an event, even though we have qmp_eventwait() since commit 8fe941f, and qmp_eventwait_ref() since commit 7ffe312. Both commits neglected to convert all the existing hacks. Make up what they missed. Bonus: gets rid of empty format strings. A step towards compile-time format string checking without triggering -Wformat-zero-length. Signed-off-by: Markus Armbruster Reviewed-by: Stefan Hajnoczi Signed-off-by: Eric Blake [thuth: dropped the hunks from the usb tests - not needed anymore] Signed-off-by: Thomas Huth --- tests/boot-order-test.c | 2 +- tests/libqos/pci-pc.c | 6 +----- tests/tco-test.c | 3 +-- tests/wdt_ib700-test.c | 35 ++++++++++------------------------- 4 files changed, 13 insertions(+), 33 deletions(-) diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c index 60c5545..508469a 100644 --- a/tests/boot-order-test.c +++ b/tests/boot-order-test.c @@ -41,7 +41,7 @@ static void test_a_boot_order(const char *machine, * system_reset only requests reset. We get a RESET event after * the actual reset completes. Need to wait for that. */ - qmp_discard_response(""); /* HACK: wait for event */ + qmp_eventwait("RESET"); actual =3D read_boot_order(); g_assert_cmphex(actual, =3D=3D, expected_reboot); qtest_quit(global_qtest); diff --git a/tests/libqos/pci-pc.c b/tests/libqos/pci-pc.c index ded1c54..02ce499 100644 --- a/tests/libqos/pci-pc.c +++ b/tests/libqos/pci-pc.c @@ -173,9 +173,5 @@ void qpci_unplug_acpi_device_test(const char *id, uint8= _t slot) =20 outb(ACPI_PCIHP_ADDR + PCI_EJ_BASE, 1 << slot); =20 - response =3D qmp(""); - g_assert(response); - g_assert(qdict_haskey(response, "event")); - g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED")); - QDECREF(response); + qmp_eventwait("DEVICE_DELETED"); } diff --git a/tests/tco-test.c b/tests/tco-test.c index 2616d33..bed66a3 100644 --- a/tests/tco-test.c +++ b/tests/tco-test.c @@ -235,9 +235,8 @@ static void test_tco_max_timeout(void) =20 static QDict *get_watchdog_action(void) { - QDict *ev =3D qmp(""); + QDict *ev =3D qmp_eventwait_ref("WATCHDOG"); QDict *data; - g_assert(!strcmp(qdict_get_str(ev, "event"), "WATCHDOG")); =20 data =3D qdict_get_qdict(ev, "data"); QINCREF(data); diff --git a/tests/wdt_ib700-test.c b/tests/wdt_ib700-test.c index 49f4f0c..4fc8eea 100644 --- a/tests/wdt_ib700-test.c +++ b/tests/wdt_ib700-test.c @@ -18,26 +18,10 @@ static void qmp_check_no_event(void) QDECREF(resp); } =20 -static QDict *qmp_get_event(const char *name) -{ - QDict *event =3D qmp(""); - QDict *data; - g_assert(qdict_haskey(event, "event")); - g_assert(!strcmp(qdict_get_str(event, "event"), name)); - - if (qdict_haskey(event, "data")) { - data =3D qdict_get_qdict(event, "data"); - QINCREF(data); - } else { - data =3D NULL; - } - - QDECREF(event); - return data; -} - static QDict *ib700_program_and_wait(QTestState *s) { + QDict *event, *data; + clock_step(NANOSECONDS_PER_SECOND * 40); qmp_check_no_event(); =20 @@ -61,7 +45,11 @@ static QDict *ib700_program_and_wait(QTestState *s) clock_step(3 * NANOSECONDS_PER_SECOND); qmp_check_no_event(); clock_step(2 * NANOSECONDS_PER_SECOND); - return qmp_get_event("WATCHDOG"); + event =3D qmp_eventwait_ref("WATCHDOG"); + data =3D qdict_get_qdict(event, "data"); + QINCREF(data); + QDECREF(event); + return data; } =20 =20 @@ -73,8 +61,7 @@ static void ib700_pause(void) d =3D ib700_program_and_wait(s); g_assert(!strcmp(qdict_get_str(d, "action"), "pause")); QDECREF(d); - d =3D qmp_get_event("STOP"); - QDECREF(d); + qmp_eventwait("STOP"); qtest_end(); } =20 @@ -86,8 +73,7 @@ static void ib700_reset(void) d =3D ib700_program_and_wait(s); g_assert(!strcmp(qdict_get_str(d, "action"), "reset")); QDECREF(d); - d =3D qmp_get_event("RESET"); - QDECREF(d); + qmp_eventwait("RESET"); qtest_end(); } =20 @@ -99,8 +85,7 @@ static void ib700_shutdown(void) d =3D ib700_program_and_wait(s); g_assert(!strcmp(qdict_get_str(d, "action"), "reset")); QDECREF(d); - d =3D qmp_get_event("SHUTDOWN"); - QDECREF(d); + qmp_eventwait("SHUTDOWN"); qtest_end(); } =20 --=20 1.8.3.1 From nobody Sat Apr 27 17:22:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518121088386474.20166838890646; Thu, 8 Feb 2018 12:18:08 -0800 (PST) Received: from localhost ([::1]:43811 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejsdz-0000mp-EQ for importer@patchew.org; Thu, 08 Feb 2018 15:18:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45295) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejsVy-0002HC-8H for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:09:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ejsVx-0002JJ-DP for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:09:50 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:43650 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ejsVx-0002It-8h for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:09:49 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ED84E40FB62E for ; Thu, 8 Feb 2018 20:09:48 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-204-120.brq.redhat.com [10.40.204.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F86CB3011; Thu, 8 Feb 2018 20:09:47 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Thu, 8 Feb 2018 21:09:30 +0100 Message-Id: <1518120582-26647-3-git-send-email-thuth@redhat.com> In-Reply-To: <1518120582-26647-1-git-send-email-thuth@redhat.com> References: <1518120582-26647-1-git-send-email-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 08 Feb 2018 20:09:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 08 Feb 2018 20:09:48 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 02/14] libqtest: Use qemu_strtoul() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Eric Blake This will keep checkpatch happy when the next patch does code motion. Fix the include order to match HACKING when adding the needed header. Signed-off-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Thomas Huth Signed-off-by: Thomas Huth --- tests/libqtest.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/libqtest.c b/tests/libqtest.c index 0ec8af2..5d90cdc 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -15,12 +15,13 @@ * */ #include "qemu/osdep.h" -#include "libqtest.h" =20 #include #include #include =20 +#include "libqtest.h" +#include "qemu/cutils.h" #include "qapi/error.h" #include "qapi/qmp/json-parser.h" #include "qapi/qmp/json-streamer.h" @@ -360,12 +361,14 @@ redo: g_string_free(line, TRUE); =20 if (strcmp(words[0], "IRQ") =3D=3D 0) { - int irq; + long irq; + int ret; =20 g_assert(words[1] !=3D NULL); g_assert(words[2] !=3D NULL); =20 - irq =3D strtoul(words[2], NULL, 0); + ret =3D qemu_strtol(words[2], NULL, 0, &irq); + g_assert(!ret); g_assert_cmpint(irq, >=3D, 0); g_assert_cmpint(irq, <, MAX_IRQ); =20 @@ -727,11 +730,13 @@ void qtest_outl(QTestState *s, uint16_t addr, uint32_= t value) static uint32_t qtest_in(QTestState *s, const char *cmd, uint16_t addr) { gchar **args; - uint32_t value; + int ret; + unsigned long value; =20 qtest_sendf(s, "%s 0x%x\n", cmd, addr); args =3D qtest_rsp(s, 2); - value =3D strtoul(args[1], NULL, 0); + ret =3D qemu_strtoul(args[1], NULL, 0, &value); + g_assert(!ret && value <=3D UINT32_MAX); g_strfreev(args); =20 return value; @@ -782,11 +787,13 @@ void qtest_writeq(QTestState *s, uint64_t addr, uint6= 4_t value) static uint64_t qtest_read(QTestState *s, const char *cmd, uint64_t addr) { gchar **args; + int ret; uint64_t value; =20 qtest_sendf(s, "%s 0x%" PRIx64 "\n", cmd, addr); args =3D qtest_rsp(s, 2); - value =3D strtoull(args[1], NULL, 0); + ret =3D qemu_strtou64(args[1], NULL, 0, &value); + g_assert(!ret); g_strfreev(args); =20 return value; --=20 1.8.3.1 From nobody Sat Apr 27 17:22:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518122336183361.7873439626396; Thu, 8 Feb 2018 12:38:56 -0800 (PST) Received: from localhost ([::1]:46461 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejsy2-0003Tu-Vd for importer@patchew.org; Thu, 08 Feb 2018 15:38:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45326) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejsW0-0002JJ-Gm for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:09:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ejsVy-0002Ju-Lf for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:09:52 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60194 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ejsVy-0002Jd-G3 for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:09:50 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 32937EAEA8 for ; Thu, 8 Feb 2018 20:09:50 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-204-120.brq.redhat.com [10.40.204.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5775EB3016; Thu, 8 Feb 2018 20:09:49 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Thu, 8 Feb 2018 21:09:31 +0100 Message-Id: <1518120582-26647-4-git-send-email-thuth@redhat.com> In-Reply-To: <1518120582-26647-1-git-send-email-thuth@redhat.com> References: <1518120582-26647-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 08 Feb 2018 20:09:50 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 08 Feb 2018 20:09:50 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 03/14] libqos: Track QTestState with QPCIBus X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake When initializing a QPCIBus, track which QTestState the bus is associated with (so that a later patch can then explicitly use that test state for all communication on the bus, rather than blindly relying on global_qtest). Update the initialization functions to take another parameter, and update all callers to pass in state (for now, most callers get away with passing the current global_qtest as the current state, although this required fixing the order of initialization to ensure qtest_start() is called before qpci_init*() in rtl8139-test, and provided an opportunity to pass in the allocator in e1000e-test). Touch up some allocations to use g_new0() rather than g_malloc() while in the area, and simplify some code (all implementations of QOSOps provide a .init_allocator() that never fails). Signed-off-by: Eric Blake Reviewed-by: John Snow Reviewed-by: Thomas Huth [thuth: Removed hunk from vhost-user-test.c that is not required anymore, and fixed conflict in qtest_vboot()] Signed-off-by: Thomas Huth --- tests/ahci-test.c | 2 +- tests/e1000e-test.c | 6 +++--- tests/i440fx-test.c | 2 +- tests/ide-test.c | 2 +- tests/libqos/ahci.c | 4 ++-- tests/libqos/ahci.h | 2 +- tests/libqos/libqos.c | 10 +++------- tests/libqos/libqos.h | 2 +- tests/libqos/pci-pc.c | 7 ++++--- tests/libqos/pci-pc.h | 2 +- tests/libqos/pci-spapr.c | 7 ++++--- tests/libqos/pci-spapr.h | 2 +- tests/libqos/pci.h | 1 + tests/q35-test.c | 4 ++-- tests/rtl8139-test.c | 5 +++-- tests/tco-test.c | 2 +- tests/usb-hcd-ehci-test.c | 2 +- tests/vhost-user-test.c | 2 +- 18 files changed, 32 insertions(+), 32 deletions(-) diff --git a/tests/ahci-test.c b/tests/ahci-test.c index 3934e62..d9c99b7 100644 --- a/tests/ahci-test.c +++ b/tests/ahci-test.c @@ -160,7 +160,7 @@ static AHCIQState *ahci_vboot(const char *cli, va_list = ap) alloc_set_flags(s->parent->alloc, ALLOC_LEAK_ASSERT); =20 /* Verify that we have an AHCI device present. */ - s->dev =3D get_ahci_device(&s->fingerprint); + s->dev =3D get_ahci_device(s->parent->qts, &s->fingerprint); =20 return s; } diff --git a/tests/e1000e-test.c b/tests/e1000e-test.c index c612dc6..d8085d9 100644 --- a/tests/e1000e-test.c +++ b/tests/e1000e-test.c @@ -392,12 +392,12 @@ static void data_test_init(e1000e_device *d) qtest_start(cmdline); g_free(cmdline); =20 - test_bus =3D qpci_init_pc(NULL); - g_assert_nonnull(test_bus); - test_alloc =3D pc_alloc_init(); g_assert_nonnull(test_alloc); =20 + test_bus =3D qpci_init_pc(global_qtest, test_alloc); + g_assert_nonnull(test_bus); + e1000e_device_init(test_bus, d); } =20 diff --git a/tests/i440fx-test.c b/tests/i440fx-test.c index e9d05c8..4390e55 100644 --- a/tests/i440fx-test.c +++ b/tests/i440fx-test.c @@ -38,7 +38,7 @@ static QPCIBus *test_start_get_bus(const TestData *s) cmdline =3D g_strdup_printf("-smp %d", s->num_cpus); qtest_start(cmdline); g_free(cmdline); - return qpci_init_pc(NULL); + return qpci_init_pc(global_qtest, NULL); } =20 static void test_i440fx_defaults(gconstpointer opaque) diff --git a/tests/ide-test.c b/tests/ide-test.c index aa9de06..b2237b6 100644 --- a/tests/ide-test.c +++ b/tests/ide-test.c @@ -143,7 +143,7 @@ static QPCIDevice *get_pci_device(QPCIBar *bmdma_bar, Q= PCIBar *ide_bar) uint16_t vendor_id, device_id; =20 if (!pcibus) { - pcibus =3D qpci_init_pc(NULL); + pcibus =3D qpci_init_pc(global_qtest, NULL); } =20 /* Find PCI device and verify it's the right one */ diff --git a/tests/libqos/ahci.c b/tests/libqos/ahci.c index 13c0749..40c532e 100644 --- a/tests/libqos/ahci.c +++ b/tests/libqos/ahci.c @@ -123,13 +123,13 @@ bool is_atapi(AHCIQState *ahci, uint8_t port) /** * Locate, verify, and return a handle to the AHCI device. */ -QPCIDevice *get_ahci_device(uint32_t *fingerprint) +QPCIDevice *get_ahci_device(QTestState *qts, uint32_t *fingerprint) { QPCIDevice *ahci; uint32_t ahci_fingerprint; QPCIBus *pcibus; =20 - pcibus =3D qpci_init_pc(NULL); + pcibus =3D qpci_init_pc(qts, NULL); =20 /* Find the AHCI PCI device and verify it's the right one. */ ahci =3D qpci_device_find(pcibus, QPCI_DEVFN(0x1F, 0x02)); diff --git a/tests/libqos/ahci.h b/tests/libqos/ahci.h index 5f9627b..715ca1e 100644 --- a/tests/libqos/ahci.h +++ b/tests/libqos/ahci.h @@ -571,7 +571,7 @@ void ahci_free(AHCIQState *ahci, uint64_t addr); void ahci_clean_mem(AHCIQState *ahci); =20 /* Device management */ -QPCIDevice *get_ahci_device(uint32_t *fingerprint); +QPCIDevice *get_ahci_device(QTestState *qts, uint32_t *fingerprint); void free_ahci_device(QPCIDevice *dev); void ahci_pci_enable(AHCIQState *ahci); void start_ahci_device(AHCIQState *ahci); diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c index 991bc1a..7a76c1e 100644 --- a/tests/libqos/libqos.c +++ b/tests/libqos/libqos.c @@ -17,18 +17,14 @@ QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_= fmt, va_list ap) { char *cmdline; =20 - struct QOSState *qs =3D g_new(QOSState, 1); + QOSState *qs =3D g_new0(QOSState, 1); =20 cmdline =3D g_strdup_vprintf(cmdline_fmt, ap); qs->qts =3D qtest_start(cmdline); qs->ops =3D ops; if (ops) { - if (ops->init_allocator) { - qs->alloc =3D ops->init_allocator(ALLOC_NO_FLAGS); - } - if (ops->qpci_init && qs->alloc) { - qs->pcibus =3D ops->qpci_init(qs->alloc); - } + qs->alloc =3D ops->init_allocator(ALLOC_NO_FLAGS); + qs->pcibus =3D ops->qpci_init(qs->qts, qs->alloc); } =20 g_free(cmdline); diff --git a/tests/libqos/libqos.h b/tests/libqos/libqos.h index 2319697..78e5c04 100644 --- a/tests/libqos/libqos.h +++ b/tests/libqos/libqos.h @@ -10,7 +10,7 @@ typedef struct QOSState QOSState; typedef struct QOSOps { QGuestAllocator *(*init_allocator)(QAllocOpts); void (*uninit_allocator)(QGuestAllocator *); - QPCIBus *(*qpci_init)(QGuestAllocator *alloc); + QPCIBus *(*qpci_init)(QTestState *qts, QGuestAllocator *alloc); void (*qpci_free)(QPCIBus *bus); void (*shutdown)(QOSState *); } QOSOps; diff --git a/tests/libqos/pci-pc.c b/tests/libqos/pci-pc.c index 02ce499..e267fd1 100644 --- a/tests/libqos/pci-pc.c +++ b/tests/libqos/pci-pc.c @@ -115,11 +115,11 @@ static void qpci_pc_config_writel(QPCIBus *bus, int d= evfn, uint8_t offset, uint3 outl(0xcfc, value); } =20 -QPCIBus *qpci_init_pc(QGuestAllocator *alloc) +QPCIBus *qpci_init_pc(QTestState *qts, QGuestAllocator *alloc) { - QPCIBusPC *ret; + QPCIBusPC *ret =3D g_new0(QPCIBusPC, 1); =20 - ret =3D g_malloc(sizeof(*ret)); + assert(qts); =20 ret->bus.pio_readb =3D qpci_pc_pio_readb; ret->bus.pio_readw =3D qpci_pc_pio_readw; @@ -142,6 +142,7 @@ QPCIBus *qpci_init_pc(QGuestAllocator *alloc) ret->bus.config_writew =3D qpci_pc_config_writew; ret->bus.config_writel =3D qpci_pc_config_writel; =20 + ret->bus.qts =3D qts; ret->bus.pio_alloc_ptr =3D 0xc000; ret->bus.mmio_alloc_ptr =3D 0xE0000000; ret->bus.mmio_limit =3D 0x100000000ULL; diff --git a/tests/libqos/pci-pc.h b/tests/libqos/pci-pc.h index 9479b51..491eeac 100644 --- a/tests/libqos/pci-pc.h +++ b/tests/libqos/pci-pc.h @@ -16,7 +16,7 @@ #include "libqos/pci.h" #include "libqos/malloc.h" =20 -QPCIBus *qpci_init_pc(QGuestAllocator *alloc); +QPCIBus *qpci_init_pc(QTestState *qts, QGuestAllocator *alloc); void qpci_free_pc(QPCIBus *bus); =20 #endif diff --git a/tests/libqos/pci-spapr.c b/tests/libqos/pci-spapr.c index 2043f1e..ef52fcb 100644 --- a/tests/libqos/pci-spapr.c +++ b/tests/libqos/pci-spapr.c @@ -154,11 +154,11 @@ static void qpci_spapr_config_writel(QPCIBus *bus, in= t devfn, uint8_t offset, #define SPAPR_PCI_MMIO32_WIN_SIZE 0x80000000 /* 2 GiB */ #define SPAPR_PCI_IO_WIN_SIZE 0x10000 =20 -QPCIBus *qpci_init_spapr(QGuestAllocator *alloc) +QPCIBus *qpci_init_spapr(QTestState *qts, QGuestAllocator *alloc) { - QPCIBusSPAPR *ret; + QPCIBusSPAPR *ret =3D g_new0(QPCIBusSPAPR, 1); =20 - ret =3D g_malloc(sizeof(*ret)); + assert(qts); =20 ret->alloc =3D alloc; =20 @@ -197,6 +197,7 @@ QPCIBus *qpci_init_spapr(QGuestAllocator *alloc) ret->mmio32.pci_base =3D SPAPR_PCI_MMIO32_WIN_SIZE; ret->mmio32.size =3D SPAPR_PCI_MMIO32_WIN_SIZE; =20 + ret->bus.qts =3D qts; ret->bus.pio_alloc_ptr =3D 0xc000; ret->bus.mmio_alloc_ptr =3D ret->mmio32.pci_base; ret->bus.mmio_limit =3D ret->mmio32.pci_base + ret->mmio32.size; diff --git a/tests/libqos/pci-spapr.h b/tests/libqos/pci-spapr.h index 4192126..387686d 100644 --- a/tests/libqos/pci-spapr.h +++ b/tests/libqos/pci-spapr.h @@ -11,7 +11,7 @@ #include "libqos/malloc.h" #include "libqos/pci.h" =20 -QPCIBus *qpci_init_spapr(QGuestAllocator *alloc); +QPCIBus *qpci_init_spapr(QTestState *qts, QGuestAllocator *alloc); void qpci_free_spapr(QPCIBus *bus); =20 #endif diff --git a/tests/libqos/pci.h b/tests/libqos/pci.h index ed48061..429c382 100644 --- a/tests/libqos/pci.h +++ b/tests/libqos/pci.h @@ -48,6 +48,7 @@ struct QPCIBus { void (*config_writel)(QPCIBus *bus, int devfn, uint8_t offset, uint32_t value); =20 + QTestState *qts; uint16_t pio_alloc_ptr; uint64_t mmio_alloc_ptr, mmio_limit; }; diff --git a/tests/q35-test.c b/tests/q35-test.c index f98bed7..e149c4c 100644 --- a/tests/q35-test.c +++ b/tests/q35-test.c @@ -86,7 +86,7 @@ static void test_smram_lock(void) =20 qtest_start("-M q35"); =20 - pcibus =3D qpci_init_pc(NULL); + pcibus =3D qpci_init_pc(global_qtest, NULL); g_assert(pcibus !=3D NULL); =20 pcidev =3D qpci_device_find(pcibus, 0); @@ -145,7 +145,7 @@ static void test_tseg_size(const void *data) g_free(cmdline); =20 /* locate the DRAM controller */ - pcibus =3D qpci_init_pc(NULL); + pcibus =3D qpci_init_pc(global_qtest, NULL); g_assert(pcibus !=3D NULL); pcidev =3D qpci_device_find(pcibus, 0); g_assert(pcidev !=3D NULL); diff --git a/tests/rtl8139-test.c b/tests/rtl8139-test.c index 7de7dc4..68bfc42 100644 --- a/tests/rtl8139-test.c +++ b/tests/rtl8139-test.c @@ -35,7 +35,7 @@ static QPCIDevice *get_device(void) { QPCIDevice *dev; =20 - pcibus =3D qpci_init_pc(NULL); + pcibus =3D qpci_init_pc(global_qtest, NULL); qpci_device_foreach(pcibus, 0x10ec, 0x8139, save_fn, &dev); g_assert(dev !=3D NULL); =20 @@ -197,11 +197,12 @@ int main(int argc, char **argv) { int ret; =20 + qtest_start("-device rtl8139"); + g_test_init(&argc, &argv, NULL); qtest_add_func("/rtl8139/nop", nop); qtest_add_func("/rtl8139/timer", test_init); =20 - qtest_start("-device rtl8139"); ret =3D g_test_run(); =20 qtest_end(); diff --git a/tests/tco-test.c b/tests/tco-test.c index bed66a3..5567b79 100644 --- a/tests/tco-test.c +++ b/tests/tco-test.c @@ -62,7 +62,7 @@ static void test_init(TestData *d) global_qtest =3D qs; qtest_irq_intercept_in(qs, "ioapic"); =20 - d->bus =3D qpci_init_pc(NULL); + d->bus =3D qpci_init_pc(qs, NULL); d->dev =3D qpci_device_find(d->bus, QPCI_DEVFN(0x1f, 0x00)); g_assert(d->dev !=3D NULL); =20 diff --git a/tests/usb-hcd-ehci-test.c b/tests/usb-hcd-ehci-test.c index 944eb1c..55d4743 100644 --- a/tests/usb-hcd-ehci-test.c +++ b/tests/usb-hcd-ehci-test.c @@ -52,7 +52,7 @@ static void ehci_port_test(struct qhc *hc, int port, uint= 32_t expect) =20 static void test_init(void) { - pcibus =3D qpci_init_pc(NULL); + pcibus =3D qpci_init_pc(global_qtest, NULL); g_assert(pcibus !=3D NULL); =20 qusb_pci_init_one(pcibus, &uhci1, QPCI_DEVFN(0x1d, 0), 4); diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index ec6ac9d..07b7e8a 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -169,7 +169,7 @@ static void init_virtio_dev(TestServer *s, uint32_t fea= tures_mask) uint32_t features; int i; =20 - s->bus =3D qpci_init_pc(NULL); + s->bus =3D qpci_init_pc(global_qtest, NULL); g_assert_nonnull(s->bus); =20 s->dev =3D qvirtio_pci_device_find(s->bus, VIRTIO_ID_NET); --=20 1.8.3.1 From nobody Sat Apr 27 17:22:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518121512468294.91238239084635; Thu, 8 Feb 2018 12:25:12 -0800 (PST) Received: from localhost ([::1]:44742 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejskl-0007CI-6v for importer@patchew.org; Thu, 08 Feb 2018 15:25:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45335) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejsW1-0002KO-Jb for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:09:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ejsVz-0002KS-Nw for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:09:53 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:43652 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ejsVz-0002KD-I8 for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:09:51 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4638C40FB630 for ; Thu, 8 Feb 2018 20:09:51 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-204-120.brq.redhat.com [10.40.204.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 82B99B07B8; Thu, 8 Feb 2018 20:09:50 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Thu, 8 Feb 2018 21:09:32 +0100 Message-Id: <1518120582-26647-5-git-send-email-thuth@redhat.com> In-Reply-To: <1518120582-26647-1-git-send-email-thuth@redhat.com> References: <1518120582-26647-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 08 Feb 2018 20:09:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 08 Feb 2018 20:09:51 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 04/14] libqos: Use explicit QTestState for fw_cfg operations X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake Drop one more client of global_qtest by teaching all fw_cfg test functionality (invoked through alloc-pc) to pass in an explicit QTestState, adjusting all callers. In particular, fw_cfg-test had to reorder things to create the test state prior to creating the fw_cfg (and drop a pointless strdup in the meantime), but that test now no longer depends on global_qtest. Signed-off-by: Eric Blake Reviewed-by: John Snow Reviewed-by: Thomas Huth [thuth: Fixed conflict wrt pc_alloc_init() in vhost-user-test.c] Signed-off-by: Thomas Huth --- tests/boot-order-test.c | 6 +++--- tests/e1000e-test.c | 2 +- tests/fw_cfg-test.c | 13 ++++--------- tests/ide-test.c | 2 +- tests/libqos/fw_cfg.c | 14 ++++++++------ tests/libqos/fw_cfg.h | 10 ++++++---- tests/libqos/libqos.c | 2 +- tests/libqos/libqos.h | 2 +- tests/libqos/malloc-pc.c | 8 ++++---- tests/libqos/malloc-pc.h | 4 ++-- tests/libqos/malloc-spapr.c | 4 ++-- tests/libqos/malloc-spapr.h | 2 +- tests/libqos/malloc.h | 1 + tests/vhost-user-test.c | 2 +- 14 files changed, 36 insertions(+), 36 deletions(-) diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c index 508469a..e70f5de 100644 --- a/tests/boot-order-test.c +++ b/tests/boot-order-test.c @@ -132,7 +132,7 @@ static void test_prep_boot_order(void) =20 static uint64_t read_boot_order_pmac(void) { - QFWCFG *fw_cfg =3D mm_fw_cfg_init(0xf0000510); + QFWCFG *fw_cfg =3D mm_fw_cfg_init(global_qtest, 0xf0000510); =20 return qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE); } @@ -157,7 +157,7 @@ static void test_pmac_newworld_boot_order(void) =20 static uint64_t read_boot_order_sun4m(void) { - QFWCFG *fw_cfg =3D mm_fw_cfg_init(0xd00000510ULL); + QFWCFG *fw_cfg =3D mm_fw_cfg_init(global_qtest, 0xd00000510ULL); =20 return qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE); } @@ -169,7 +169,7 @@ static void test_sun4m_boot_order(void) =20 static uint64_t read_boot_order_sun4u(void) { - QFWCFG *fw_cfg =3D io_fw_cfg_init(0x510); + QFWCFG *fw_cfg =3D io_fw_cfg_init(global_qtest, 0x510); =20 return qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE); } diff --git a/tests/e1000e-test.c b/tests/e1000e-test.c index d8085d9..32aa738 100644 --- a/tests/e1000e-test.c +++ b/tests/e1000e-test.c @@ -392,7 +392,7 @@ static void data_test_init(e1000e_device *d) qtest_start(cmdline); g_free(cmdline); =20 - test_alloc =3D pc_alloc_init(); + test_alloc =3D pc_alloc_init(global_qtest); g_assert_nonnull(test_alloc); =20 test_bus =3D qpci_init_pc(global_qtest, test_alloc); diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c index 81f45bd..1548bf1 100644 --- a/tests/fw_cfg-test.c +++ b/tests/fw_cfg-test.c @@ -102,12 +102,13 @@ static void test_fw_cfg_boot_menu(void) int main(int argc, char **argv) { QTestState *s; - char *cmdline; int ret; =20 g_test_init(&argc, &argv, NULL); =20 - fw_cfg =3D pc_fw_cfg_init(); + s =3D qtest_init("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8"); + + fw_cfg =3D pc_fw_cfg_init(s); =20 qtest_add_func("fw_cfg/signature", test_fw_cfg_signature); qtest_add_func("fw_cfg/id", test_fw_cfg_id); @@ -125,15 +126,9 @@ int main(int argc, char **argv) qtest_add_func("fw_cfg/numa", test_fw_cfg_numa); qtest_add_func("fw_cfg/boot_menu", test_fw_cfg_boot_menu); =20 - cmdline =3D g_strdup_printf("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d= 8 "); - s =3D qtest_start(cmdline); - g_free(cmdline); - ret =3D g_test_run(); =20 - if (s) { - qtest_quit(s); - } + qtest_quit(s); =20 return ret; } diff --git a/tests/ide-test.c b/tests/ide-test.c index b2237b6..084f6a5 100644 --- a/tests/ide-test.c +++ b/tests/ide-test.c @@ -125,7 +125,7 @@ static void ide_test_start(const char *cmdline_fmt, ...) va_end(ap); =20 qtest_start(cmdline); - guest_malloc =3D pc_alloc_init(); + guest_malloc =3D pc_alloc_init(global_qtest); =20 g_free(cmdline); } diff --git a/tests/libqos/fw_cfg.c b/tests/libqos/fw_cfg.c index 4d9dc3f..d0889d1 100644 --- a/tests/libqos/fw_cfg.c +++ b/tests/libqos/fw_cfg.c @@ -56,7 +56,7 @@ uint64_t qfw_cfg_get_u64(QFWCFG *fw_cfg, uint16_t key) =20 static void mm_fw_cfg_select(QFWCFG *fw_cfg, uint16_t key) { - writew(fw_cfg->base, key); + qtest_writew(fw_cfg->qts, fw_cfg->base, key); } =20 static void mm_fw_cfg_read(QFWCFG *fw_cfg, void *data, size_t len) @@ -65,15 +65,16 @@ static void mm_fw_cfg_read(QFWCFG *fw_cfg, void *data, = size_t len) int i; =20 for (i =3D 0; i < len; i++) { - ptr[i] =3D readb(fw_cfg->base + 2); + ptr[i] =3D qtest_readb(fw_cfg->qts, fw_cfg->base + 2); } } =20 -QFWCFG *mm_fw_cfg_init(uint64_t base) +QFWCFG *mm_fw_cfg_init(QTestState *qts, uint64_t base) { QFWCFG *fw_cfg =3D g_malloc0(sizeof(*fw_cfg)); =20 fw_cfg->base =3D base; + fw_cfg->qts =3D qts; fw_cfg->select =3D mm_fw_cfg_select; fw_cfg->read =3D mm_fw_cfg_read; =20 @@ -82,7 +83,7 @@ QFWCFG *mm_fw_cfg_init(uint64_t base) =20 static void io_fw_cfg_select(QFWCFG *fw_cfg, uint16_t key) { - outw(fw_cfg->base, key); + qtest_outw(fw_cfg->qts, fw_cfg->base, key); } =20 static void io_fw_cfg_read(QFWCFG *fw_cfg, void *data, size_t len) @@ -91,15 +92,16 @@ static void io_fw_cfg_read(QFWCFG *fw_cfg, void *data, = size_t len) int i; =20 for (i =3D 0; i < len; i++) { - ptr[i] =3D inb(fw_cfg->base + 1); + ptr[i] =3D qtest_inb(fw_cfg->qts, fw_cfg->base + 1); } } =20 -QFWCFG *io_fw_cfg_init(uint16_t base) +QFWCFG *io_fw_cfg_init(QTestState *qts, uint16_t base) { QFWCFG *fw_cfg =3D g_malloc0(sizeof(*fw_cfg)); =20 fw_cfg->base =3D base; + fw_cfg->qts =3D qts; fw_cfg->select =3D io_fw_cfg_select; fw_cfg->read =3D io_fw_cfg_read; =20 diff --git a/tests/libqos/fw_cfg.h b/tests/libqos/fw_cfg.h index e8371b2..0353416 100644 --- a/tests/libqos/fw_cfg.h +++ b/tests/libqos/fw_cfg.h @@ -13,12 +13,14 @@ #ifndef LIBQOS_FW_CFG_H #define LIBQOS_FW_CFG_H =20 +#include "libqtest.h" =20 typedef struct QFWCFG QFWCFG; =20 struct QFWCFG { uint64_t base; + QTestState *qts; void (*select)(QFWCFG *fw_cfg, uint16_t key); void (*read)(QFWCFG *fw_cfg, void *data, size_t len); }; @@ -30,12 +32,12 @@ uint16_t qfw_cfg_get_u16(QFWCFG *fw_cfg, uint16_t key); uint32_t qfw_cfg_get_u32(QFWCFG *fw_cfg, uint16_t key); uint64_t qfw_cfg_get_u64(QFWCFG *fw_cfg, uint16_t key); =20 -QFWCFG *mm_fw_cfg_init(uint64_t base); -QFWCFG *io_fw_cfg_init(uint16_t base); +QFWCFG *mm_fw_cfg_init(QTestState *qts, uint64_t base); +QFWCFG *io_fw_cfg_init(QTestState *qts, uint16_t base); =20 -static inline QFWCFG *pc_fw_cfg_init(void) +static inline QFWCFG *pc_fw_cfg_init(QTestState *qts) { - return io_fw_cfg_init(0x510); + return io_fw_cfg_init(qts, 0x510); } =20 #endif diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c index 7a76c1e..40018b9 100644 --- a/tests/libqos/libqos.c +++ b/tests/libqos/libqos.c @@ -23,7 +23,7 @@ QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fm= t, va_list ap) qs->qts =3D qtest_start(cmdline); qs->ops =3D ops; if (ops) { - qs->alloc =3D ops->init_allocator(ALLOC_NO_FLAGS); + qs->alloc =3D ops->init_allocator(qs->qts, ALLOC_NO_FLAGS); qs->pcibus =3D ops->qpci_init(qs->qts, qs->alloc); } =20 diff --git a/tests/libqos/libqos.h b/tests/libqos/libqos.h index 78e5c04..07d4b93 100644 --- a/tests/libqos/libqos.h +++ b/tests/libqos/libqos.h @@ -8,7 +8,7 @@ typedef struct QOSState QOSState; =20 typedef struct QOSOps { - QGuestAllocator *(*init_allocator)(QAllocOpts); + QGuestAllocator *(*init_allocator)(QTestState *qts, QAllocOpts); void (*uninit_allocator)(QGuestAllocator *); QPCIBus *(*qpci_init)(QTestState *qts, QGuestAllocator *alloc); void (*qpci_free)(QPCIBus *bus); diff --git a/tests/libqos/malloc-pc.c b/tests/libqos/malloc-pc.c index dd2b900..634b9c2 100644 --- a/tests/libqos/malloc-pc.c +++ b/tests/libqos/malloc-pc.c @@ -29,11 +29,11 @@ void pc_alloc_uninit(QGuestAllocator *allocator) alloc_uninit(allocator); } =20 -QGuestAllocator *pc_alloc_init_flags(QAllocOpts flags) +QGuestAllocator *pc_alloc_init_flags(QTestState *qts, QAllocOpts flags) { QGuestAllocator *s; uint64_t ram_size; - QFWCFG *fw_cfg =3D pc_fw_cfg_init(); + QFWCFG *fw_cfg =3D pc_fw_cfg_init(qts); =20 ram_size =3D qfw_cfg_get_u64(fw_cfg, FW_CFG_RAM_SIZE); s =3D alloc_init_flags(flags, 1 << 20, MIN(ram_size, 0xE0000000)); @@ -45,7 +45,7 @@ QGuestAllocator *pc_alloc_init_flags(QAllocOpts flags) return s; } =20 -inline QGuestAllocator *pc_alloc_init(void) +inline QGuestAllocator *pc_alloc_init(QTestState *qts) { - return pc_alloc_init_flags(ALLOC_NO_FLAGS); + return pc_alloc_init_flags(qts, ALLOC_NO_FLAGS); } diff --git a/tests/libqos/malloc-pc.h b/tests/libqos/malloc-pc.h index 86ab9f0..10f3da6 100644 --- a/tests/libqos/malloc-pc.h +++ b/tests/libqos/malloc-pc.h @@ -15,8 +15,8 @@ =20 #include "libqos/malloc.h" =20 -QGuestAllocator *pc_alloc_init(void); -QGuestAllocator *pc_alloc_init_flags(QAllocOpts flags); +QGuestAllocator *pc_alloc_init(QTestState *qts); +QGuestAllocator *pc_alloc_init_flags(QTestState *qts, QAllocOpts flags); void pc_alloc_uninit(QGuestAllocator *allocator); =20 #endif diff --git a/tests/libqos/malloc-spapr.c b/tests/libqos/malloc-spapr.c index 006404a..1c359ce 100644 --- a/tests/libqos/malloc-spapr.c +++ b/tests/libqos/malloc-spapr.c @@ -22,7 +22,7 @@ void spapr_alloc_uninit(QGuestAllocator *allocator) alloc_uninit(allocator); } =20 -QGuestAllocator *spapr_alloc_init_flags(QAllocOpts flags) +QGuestAllocator *spapr_alloc_init_flags(QTestState *qts, QAllocOpts flags) { QGuestAllocator *s; =20 @@ -34,5 +34,5 @@ QGuestAllocator *spapr_alloc_init_flags(QAllocOpts flags) =20 QGuestAllocator *spapr_alloc_init(void) { - return spapr_alloc_init_flags(ALLOC_NO_FLAGS); + return spapr_alloc_init_flags(NULL, ALLOC_NO_FLAGS); } diff --git a/tests/libqos/malloc-spapr.h b/tests/libqos/malloc-spapr.h index 64d0e77..52a9346 100644 --- a/tests/libqos/malloc-spapr.h +++ b/tests/libqos/malloc-spapr.h @@ -11,7 +11,7 @@ #include "libqos/malloc.h" =20 QGuestAllocator *spapr_alloc_init(void); -QGuestAllocator *spapr_alloc_init_flags(QAllocOpts flags); +QGuestAllocator *spapr_alloc_init_flags(QTestState *qts, QAllocOpts flags); void spapr_alloc_uninit(QGuestAllocator *allocator); =20 #endif diff --git a/tests/libqos/malloc.h b/tests/libqos/malloc.h index ae9dac8..828fdda 100644 --- a/tests/libqos/malloc.h +++ b/tests/libqos/malloc.h @@ -14,6 +14,7 @@ #define LIBQOS_MALLOC_H =20 #include "qemu/queue.h" +#include "libqtest.h" =20 typedef enum { ALLOC_NO_FLAGS =3D 0x00, diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index 07b7e8a..d53146e 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -180,7 +180,7 @@ static void init_virtio_dev(TestServer *s, uint32_t fea= tures_mask) qvirtio_set_acknowledge(&s->dev->vdev); qvirtio_set_driver(&s->dev->vdev); =20 - s->alloc =3D pc_alloc_init(); + s->alloc =3D pc_alloc_init(global_qtest); =20 for (i =3D 0; i < s->queues * 2; i++) { s->vq[i] =3D qvirtqueue_setup(&s->dev->vdev, s->alloc, i); --=20 1.8.3.1 From nobody Sat Apr 27 17:22:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518122195784908.9928773972524; Thu, 8 Feb 2018 12:36:35 -0800 (PST) Received: from localhost ([::1]:46123 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejsvq-0000x7-Nq for importer@patchew.org; Thu, 08 Feb 2018 15:36:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45367) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejsW4-0002MJ-Ch for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:09:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ejsW1-0002Kz-0B for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:09:56 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:43658 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ejsW0-0002Kl-Q3 for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:09:52 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 737BC40FB630 for ; Thu, 8 Feb 2018 20:09:52 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-204-120.brq.redhat.com [10.40.204.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 950D9B07B8; Thu, 8 Feb 2018 20:09:51 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Thu, 8 Feb 2018 21:09:33 +0100 Message-Id: <1518120582-26647-6-git-send-email-thuth@redhat.com> In-Reply-To: <1518120582-26647-1-git-send-email-thuth@redhat.com> References: <1518120582-26647-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 08 Feb 2018 20:09:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 08 Feb 2018 20:09:52 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 05/14] libqos: Use explicit QTestState for rtas operations X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake Drop one more client of global_qtest by teaching all rtas test functionality to pass in an explicit QTestState, adjusting all callers. Signed-off-by: Eric Blake Reviewed-by: Thomas Huth [thuth: Use nicer indentation in rtas.h] Signed-off-by: Thomas Huth --- tests/libqos/pci-spapr.c | 18 ++++++++++++------ tests/libqos/rtas.c | 36 ++++++++++++++++++++---------------- tests/libqos/rtas.h | 12 +++++++----- tests/rtas-test.c | 2 +- 4 files changed, 40 insertions(+), 28 deletions(-) diff --git a/tests/libqos/pci-spapr.c b/tests/libqos/pci-spapr.c index ef52fcb..c0f7e6d 100644 --- a/tests/libqos/pci-spapr.c +++ b/tests/libqos/pci-spapr.c @@ -108,21 +108,24 @@ static uint8_t qpci_spapr_config_readb(QPCIBus *bus, = int devfn, uint8_t offset) { QPCIBusSPAPR *s =3D container_of(bus, QPCIBusSPAPR, bus); uint32_t config_addr =3D (devfn << 8) | offset; - return qrtas_ibm_read_pci_config(s->alloc, s->buid, config_addr, 1); + return qrtas_ibm_read_pci_config(bus->qts, s->alloc, s->buid, + config_addr, 1); } =20 static uint16_t qpci_spapr_config_readw(QPCIBus *bus, int devfn, uint8_t o= ffset) { QPCIBusSPAPR *s =3D container_of(bus, QPCIBusSPAPR, bus); uint32_t config_addr =3D (devfn << 8) | offset; - return qrtas_ibm_read_pci_config(s->alloc, s->buid, config_addr, 2); + return qrtas_ibm_read_pci_config(bus->qts, s->alloc, s->buid, + config_addr, 2); } =20 static uint32_t qpci_spapr_config_readl(QPCIBus *bus, int devfn, uint8_t o= ffset) { QPCIBusSPAPR *s =3D container_of(bus, QPCIBusSPAPR, bus); uint32_t config_addr =3D (devfn << 8) | offset; - return qrtas_ibm_read_pci_config(s->alloc, s->buid, config_addr, 4); + return qrtas_ibm_read_pci_config(bus->qts, s->alloc, s->buid, + config_addr, 4); } =20 static void qpci_spapr_config_writeb(QPCIBus *bus, int devfn, uint8_t offs= et, @@ -130,7 +133,8 @@ static void qpci_spapr_config_writeb(QPCIBus *bus, int = devfn, uint8_t offset, { QPCIBusSPAPR *s =3D container_of(bus, QPCIBusSPAPR, bus); uint32_t config_addr =3D (devfn << 8) | offset; - qrtas_ibm_write_pci_config(s->alloc, s->buid, config_addr, 1, value); + qrtas_ibm_write_pci_config(bus->qts, s->alloc, s->buid, + config_addr, 1, value); } =20 static void qpci_spapr_config_writew(QPCIBus *bus, int devfn, uint8_t offs= et, @@ -138,7 +142,8 @@ static void qpci_spapr_config_writew(QPCIBus *bus, int = devfn, uint8_t offset, { QPCIBusSPAPR *s =3D container_of(bus, QPCIBusSPAPR, bus); uint32_t config_addr =3D (devfn << 8) | offset; - qrtas_ibm_write_pci_config(s->alloc, s->buid, config_addr, 2, value); + qrtas_ibm_write_pci_config(bus->qts, s->alloc, s->buid, + config_addr, 2, value); } =20 static void qpci_spapr_config_writel(QPCIBus *bus, int devfn, uint8_t offs= et, @@ -146,7 +151,8 @@ static void qpci_spapr_config_writel(QPCIBus *bus, int = devfn, uint8_t offset, { QPCIBusSPAPR *s =3D container_of(bus, QPCIBusSPAPR, bus); uint32_t config_addr =3D (devfn << 8) | offset; - qrtas_ibm_write_pci_config(s->alloc, s->buid, config_addr, 4, value); + qrtas_ibm_write_pci_config(bus->qts, s->alloc, s->buid, + config_addr, 4, value); } =20 #define SPAPR_PCI_BASE (1ULL << 45) diff --git a/tests/libqos/rtas.c b/tests/libqos/rtas.c index 0269803..d81ff42 100644 --- a/tests/libqos/rtas.c +++ b/tests/libqos/rtas.c @@ -7,26 +7,28 @@ #include "libqtest.h" #include "libqos/rtas.h" =20 -static void qrtas_copy_args(uint64_t target_args, uint32_t nargs, - uint32_t *args) +static void qrtas_copy_args(QTestState *qts, uint64_t target_args, + uint32_t nargs, uint32_t *args) { int i; =20 for (i =3D 0; i < nargs; i++) { - writel(target_args + i * sizeof(uint32_t), args[i]); + qtest_writel(qts, target_args + i * sizeof(uint32_t), args[i]); } } =20 -static void qrtas_copy_ret(uint64_t target_ret, uint32_t nret, uint32_t *r= et) +static void qrtas_copy_ret(QTestState *qts, uint64_t target_ret, + uint32_t nret, uint32_t *ret) { int i; =20 for (i =3D 0; i < nret; i++) { - ret[i] =3D readl(target_ret + i * sizeof(uint32_t)); + ret[i] =3D qtest_readl(qts, target_ret + i * sizeof(uint32_t)); } } =20 -static uint64_t qrtas_call(QGuestAllocator *alloc, const char *name, +static uint64_t qrtas_call(QTestState *qts, QGuestAllocator *alloc, + const char *name, uint32_t nargs, uint32_t *args, uint32_t nret, uint32_t *ret) { @@ -36,10 +38,9 @@ static uint64_t qrtas_call(QGuestAllocator *alloc, const= char *name, target_args =3D guest_alloc(alloc, nargs * sizeof(uint32_t)); target_ret =3D guest_alloc(alloc, nret * sizeof(uint32_t)); =20 - qrtas_copy_args(target_args, nargs, args); - res =3D qtest_rtas_call(global_qtest, name, - nargs, target_args, nret, target_ret); - qrtas_copy_ret(target_ret, nret, ret); + qrtas_copy_args(qts, target_args, nargs, args); + res =3D qtest_rtas_call(qts, name, nargs, target_args, nret, target_re= t); + qrtas_copy_ret(qts, target_ret, nret, ret); =20 guest_free(alloc, target_ret); guest_free(alloc, target_args); @@ -47,12 +48,13 @@ static uint64_t qrtas_call(QGuestAllocator *alloc, cons= t char *name, return res; } =20 -int qrtas_get_time_of_day(QGuestAllocator *alloc, struct tm *tm, uint32_t = *ns) +int qrtas_get_time_of_day(QTestState *qts, QGuestAllocator *alloc, + struct tm *tm, uint32_t *ns) { int res; uint32_t ret[8]; =20 - res =3D qrtas_call(alloc, "get-time-of-day", 0, NULL, 8, ret); + res =3D qrtas_call(qts, alloc, "get-time-of-day", 0, NULL, 8, ret); if (res !=3D 0) { return res; } @@ -70,7 +72,8 @@ int qrtas_get_time_of_day(QGuestAllocator *alloc, struct = tm *tm, uint32_t *ns) return res; } =20 -uint32_t qrtas_ibm_read_pci_config(QGuestAllocator *alloc, uint64_t buid, +uint32_t qrtas_ibm_read_pci_config(QTestState *qts, QGuestAllocator *alloc, + uint64_t buid, uint32_t addr, uint32_t size) { int res; @@ -80,7 +83,7 @@ uint32_t qrtas_ibm_read_pci_config(QGuestAllocator *alloc= , uint64_t buid, args[1] =3D buid >> 32; args[2] =3D buid & 0xffffffff; args[3] =3D size; - res =3D qrtas_call(alloc, "ibm,read-pci-config", 4, args, 2, ret); + res =3D qrtas_call(qts, alloc, "ibm,read-pci-config", 4, args, 2, ret); if (res !=3D 0) { return -1; } @@ -92,7 +95,8 @@ uint32_t qrtas_ibm_read_pci_config(QGuestAllocator *alloc= , uint64_t buid, return ret[1]; } =20 -int qrtas_ibm_write_pci_config(QGuestAllocator *alloc, uint64_t buid, +int qrtas_ibm_write_pci_config(QTestState *qts, QGuestAllocator *alloc, + uint64_t buid, uint32_t addr, uint32_t size, uint32_t val) { int res; @@ -103,7 +107,7 @@ int qrtas_ibm_write_pci_config(QGuestAllocator *alloc, = uint64_t buid, args[2] =3D buid & 0xffffffff; args[3] =3D size; args[4] =3D val; - res =3D qrtas_call(alloc, "ibm,write-pci-config", 5, args, 1, ret); + res =3D qrtas_call(qts, alloc, "ibm,write-pci-config", 5, args, 1, ret= ); if (res !=3D 0) { return -1; } diff --git a/tests/libqos/rtas.h b/tests/libqos/rtas.h index 498eb19..459e23a 100644 --- a/tests/libqos/rtas.h +++ b/tests/libqos/rtas.h @@ -7,9 +7,11 @@ #define LIBQOS_RTAS_H #include "libqos/malloc.h" =20 -int qrtas_get_time_of_day(QGuestAllocator *alloc, struct tm *tm, uint32_t = *ns); -uint32_t qrtas_ibm_read_pci_config(QGuestAllocator *alloc, uint64_t buid, - uint32_t addr, uint32_t size); -int qrtas_ibm_write_pci_config(QGuestAllocator *alloc, uint64_t buid, - uint32_t addr, uint32_t size, uint32_t val); +int qrtas_get_time_of_day(QTestState *qts, QGuestAllocator *alloc, + struct tm *tm, uint32_t *ns); +uint32_t qrtas_ibm_read_pci_config(QTestState *qts, QGuestAllocator *alloc, + uint64_t buid, uint32_t addr, uint32_t = size); +int qrtas_ibm_write_pci_config(QTestState *qts, QGuestAllocator *alloc, + uint64_t buid, uint32_t addr, uint32_t size, + uint32_t val); #endif /* LIBQOS_RTAS_H */ diff --git a/tests/rtas-test.c b/tests/rtas-test.c index 276c87e..34a6921 100644 --- a/tests/rtas-test.c +++ b/tests/rtas-test.c @@ -16,7 +16,7 @@ static void test_rtas_get_time_of_day(void) qs =3D qtest_spapr_boot("-machine pseries"); =20 t1 =3D time(NULL); - ret =3D qrtas_get_time_of_day(qs->alloc, &tm, &ns); + ret =3D qrtas_get_time_of_day(qs->qts, qs->alloc, &tm, &ns); g_assert_cmpint(ret, =3D=3D, 0); t2 =3D mktimegm(&tm); g_assert(t2 - t1 < 5); /* 5 sec max to run the test */ --=20 1.8.3.1 From nobody Sat Apr 27 17:22:04 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518121918692553.7167373012859; Thu, 8 Feb 2018 12:31:58 -0800 (PST) Received: from localhost ([::1]:45721 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejsrN-00059i-5X for importer@patchew.org; Thu, 08 Feb 2018 15:31:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45369) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejsW4-0002MK-Dv for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:09:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ejsW2-0002Lh-7b for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:09:56 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60196 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ejsW2-0002LR-0B for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:09:54 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A790E9BA56 for ; Thu, 8 Feb 2018 20:09:53 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-204-120.brq.redhat.com [10.40.204.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id CCEBFB3011; Thu, 8 Feb 2018 20:09:52 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Thu, 8 Feb 2018 21:09:34 +0100 Message-Id: <1518120582-26647-7-git-send-email-thuth@redhat.com> In-Reply-To: <1518120582-26647-1-git-send-email-thuth@redhat.com> References: <1518120582-26647-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 08 Feb 2018 20:09:53 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 08 Feb 2018 20:09:53 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 06/14] libqos: Use explicit QTestState for i2c operations X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake Drop one more client of global_qtest by teaching all i2c test functionality to pass in an explicit QTestState, adjusting all callers. Signed-off-by: Eric Blake Reviewed-by: Thomas Huth Signed-off-by: Thomas Huth --- tests/ds1338-test.c | 6 ++--- tests/libqos/i2c-imx.c | 67 +++++++++++++++++++++++++--------------------= ---- tests/libqos/i2c-omap.c | 45 +++++++++++++++++---------------- tests/libqos/i2c.h | 7 ++++-- tests/tmp105-test.c | 6 ++--- 5 files changed, 66 insertions(+), 65 deletions(-) diff --git a/tests/ds1338-test.c b/tests/ds1338-test.c index 26968bc..742dad9 100644 --- a/tests/ds1338-test.c +++ b/tests/ds1338-test.c @@ -61,16 +61,14 @@ int main(int argc, char **argv) g_test_init(&argc, &argv, NULL); =20 s =3D qtest_start("-display none -machine imx25-pdk"); - i2c =3D imx_i2c_create(IMX25_I2C_0_BASE); + i2c =3D imx_i2c_create(s, IMX25_I2C_0_BASE); addr =3D DS1338_ADDR; =20 qtest_add_func("/ds1338/tx-rx", send_and_receive); =20 ret =3D g_test_run(); =20 - if (s) { - qtest_quit(s); - } + qtest_quit(s); g_free(i2c); =20 return ret; diff --git a/tests/libqos/i2c-imx.c b/tests/libqos/i2c-imx.c index 1c4b431..0945f2e 100644 --- a/tests/libqos/i2c-imx.c +++ b/tests/libqos/i2c-imx.c @@ -40,8 +40,8 @@ typedef struct IMXI2C { static void imx_i2c_set_slave_addr(IMXI2C *s, uint8_t addr, enum IMXI2CDirection direction) { - writeb(s->addr + I2DR_ADDR, (addr << 1) | - (direction =3D=3D IMX_I2C_READ ? 1 : 0)); + qtest_writeb(s->parent.qts, s->addr + I2DR_ADDR, + (addr << 1) | (direction =3D=3D IMX_I2C_READ ? 1 : 0)); } =20 static void imx_i2c_send(I2CAdapter *i2c, uint8_t addr, @@ -63,35 +63,35 @@ static void imx_i2c_send(I2CAdapter *i2c, uint8_t addr, I2CR_MTX | I2CR_TXAK; =20 - writeb(s->addr + I2CR_ADDR, data); - status =3D readb(s->addr + I2SR_ADDR); + qtest_writeb(i2c->qts, s->addr + I2CR_ADDR, data); + status =3D qtest_readb(i2c->qts, s->addr + I2SR_ADDR); g_assert((status & I2SR_IBB) !=3D 0); =20 /* set the slave address */ imx_i2c_set_slave_addr(s, addr, IMX_I2C_WRITE); - status =3D readb(s->addr + I2SR_ADDR); + status =3D qtest_readb(i2c->qts, s->addr + I2SR_ADDR); g_assert((status & I2SR_IIF) !=3D 0); g_assert((status & I2SR_RXAK) =3D=3D 0); =20 /* ack the interrupt */ - writeb(s->addr + I2SR_ADDR, 0); - status =3D readb(s->addr + I2SR_ADDR); + qtest_writeb(i2c->qts, s->addr + I2SR_ADDR, 0); + status =3D qtest_readb(i2c->qts, s->addr + I2SR_ADDR); g_assert((status & I2SR_IIF) =3D=3D 0); =20 while (size < len) { /* check we are still busy */ - status =3D readb(s->addr + I2SR_ADDR); + status =3D qtest_readb(i2c->qts, s->addr + I2SR_ADDR); g_assert((status & I2SR_IBB) !=3D 0); =20 /* write the data */ - writeb(s->addr + I2DR_ADDR, buf[size]); - status =3D readb(s->addr + I2SR_ADDR); + qtest_writeb(i2c->qts, s->addr + I2DR_ADDR, buf[size]); + status =3D qtest_readb(i2c->qts, s->addr + I2SR_ADDR); g_assert((status & I2SR_IIF) !=3D 0); g_assert((status & I2SR_RXAK) =3D=3D 0); =20 /* ack the interrupt */ - writeb(s->addr + I2SR_ADDR, 0); - status =3D readb(s->addr + I2SR_ADDR); + qtest_writeb(i2c->qts, s->addr + I2SR_ADDR, 0); + status =3D qtest_readb(i2c->qts, s->addr + I2SR_ADDR); g_assert((status & I2SR_IIF) =3D=3D 0); =20 size++; @@ -99,8 +99,8 @@ static void imx_i2c_send(I2CAdapter *i2c, uint8_t addr, =20 /* release the bus */ data &=3D ~(I2CR_MSTA | I2CR_MTX); - writeb(s->addr + I2CR_ADDR, data); - status =3D readb(s->addr + I2SR_ADDR); + qtest_writeb(i2c->qts, s->addr + I2CR_ADDR, data); + status =3D qtest_readb(i2c->qts, s->addr + I2SR_ADDR); g_assert((status & I2SR_IBB) =3D=3D 0); } =20 @@ -123,19 +123,19 @@ static void imx_i2c_recv(I2CAdapter *i2c, uint8_t add= r, I2CR_MTX | I2CR_TXAK; =20 - writeb(s->addr + I2CR_ADDR, data); - status =3D readb(s->addr + I2SR_ADDR); + qtest_writeb(i2c->qts, s->addr + I2CR_ADDR, data); + status =3D qtest_readb(i2c->qts, s->addr + I2SR_ADDR); g_assert((status & I2SR_IBB) !=3D 0); =20 /* set the slave address */ imx_i2c_set_slave_addr(s, addr, IMX_I2C_READ); - status =3D readb(s->addr + I2SR_ADDR); + status =3D qtest_readb(i2c->qts, s->addr + I2SR_ADDR); g_assert((status & I2SR_IIF) !=3D 0); g_assert((status & I2SR_RXAK) =3D=3D 0); =20 /* ack the interrupt */ - writeb(s->addr + I2SR_ADDR, 0); - status =3D readb(s->addr + I2SR_ADDR); + qtest_writeb(i2c->qts, s->addr + I2SR_ADDR, 0); + status =3D qtest_readb(i2c->qts, s->addr + I2SR_ADDR); g_assert((status & I2SR_IIF) =3D=3D 0); =20 /* set the bus for read */ @@ -144,23 +144,23 @@ static void imx_i2c_recv(I2CAdapter *i2c, uint8_t add= r, if (len !=3D 1) { data &=3D ~I2CR_TXAK; } - writeb(s->addr + I2CR_ADDR, data); - status =3D readb(s->addr + I2SR_ADDR); + qtest_writeb(i2c->qts, s->addr + I2CR_ADDR, data); + status =3D qtest_readb(i2c->qts, s->addr + I2SR_ADDR); g_assert((status & I2SR_IBB) !=3D 0); =20 /* dummy read */ - readb(s->addr + I2DR_ADDR); - status =3D readb(s->addr + I2SR_ADDR); + qtest_readb(i2c->qts, s->addr + I2DR_ADDR); + status =3D qtest_readb(i2c->qts, s->addr + I2SR_ADDR); g_assert((status & I2SR_IIF) !=3D 0); =20 /* ack the interrupt */ - writeb(s->addr + I2SR_ADDR, 0); - status =3D readb(s->addr + I2SR_ADDR); + qtest_writeb(i2c->qts, s->addr + I2SR_ADDR, 0); + status =3D qtest_readb(i2c->qts, s->addr + I2SR_ADDR); g_assert((status & I2SR_IIF) =3D=3D 0); =20 while (size < len) { /* check we are still busy */ - status =3D readb(s->addr + I2SR_ADDR); + status =3D qtest_readb(i2c->qts, s->addr + I2SR_ADDR); g_assert((status & I2SR_IBB) !=3D 0); =20 if (size =3D=3D (len - 1)) { @@ -170,30 +170,30 @@ static void imx_i2c_recv(I2CAdapter *i2c, uint8_t add= r, /* ack the data read */ data |=3D I2CR_TXAK; } - writeb(s->addr + I2CR_ADDR, data); + qtest_writeb(i2c->qts, s->addr + I2CR_ADDR, data); =20 /* read the data */ - buf[size] =3D readb(s->addr + I2DR_ADDR); + buf[size] =3D qtest_readb(i2c->qts, s->addr + I2DR_ADDR); =20 if (size !=3D (len - 1)) { - status =3D readb(s->addr + I2SR_ADDR); + status =3D qtest_readb(i2c->qts, s->addr + I2SR_ADDR); g_assert((status & I2SR_IIF) !=3D 0); =20 /* ack the interrupt */ - writeb(s->addr + I2SR_ADDR, 0); + qtest_writeb(i2c->qts, s->addr + I2SR_ADDR, 0); } =20 - status =3D readb(s->addr + I2SR_ADDR); + status =3D qtest_readb(i2c->qts, s->addr + I2SR_ADDR); g_assert((status & I2SR_IIF) =3D=3D 0); =20 size++; } =20 - status =3D readb(s->addr + I2SR_ADDR); + status =3D qtest_readb(i2c->qts, s->addr + I2SR_ADDR); g_assert((status & I2SR_IBB) =3D=3D 0); } =20 -I2CAdapter *imx_i2c_create(uint64_t addr) +I2CAdapter *imx_i2c_create(QTestState *qts, uint64_t addr) { IMXI2C *s =3D g_malloc0(sizeof(*s)); I2CAdapter *i2c =3D (I2CAdapter *)s; @@ -202,6 +202,7 @@ I2CAdapter *imx_i2c_create(uint64_t addr) =20 i2c->send =3D imx_i2c_send; i2c->recv =3D imx_i2c_recv; + i2c->qts =3D qts; =20 return i2c; } diff --git a/tests/libqos/i2c-omap.c b/tests/libqos/i2c-omap.c index f603fdf..1ef6e7b 100644 --- a/tests/libqos/i2c-omap.c +++ b/tests/libqos/i2c-omap.c @@ -51,8 +51,8 @@ static void omap_i2c_set_slave_addr(OMAPI2C *s, uint8_t a= ddr) { uint16_t data =3D addr; =20 - writew(s->addr + OMAP_I2C_SA, data); - data =3D readw(s->addr + OMAP_I2C_SA); + qtest_writew(s->parent.qts, s->addr + OMAP_I2C_SA, data); + data =3D qtest_readw(s->parent.qts, s->addr + OMAP_I2C_SA); g_assert_cmphex(data, =3D=3D, addr); } =20 @@ -65,38 +65,38 @@ static void omap_i2c_send(I2CAdapter *i2c, uint8_t addr, omap_i2c_set_slave_addr(s, addr); =20 data =3D len; - writew(s->addr + OMAP_I2C_CNT, data); + qtest_writew(i2c->qts, s->addr + OMAP_I2C_CNT, data); =20 data =3D OMAP_I2C_CON_I2C_EN | OMAP_I2C_CON_TRX | OMAP_I2C_CON_MST | OMAP_I2C_CON_STT | OMAP_I2C_CON_STP; - writew(s->addr + OMAP_I2C_CON, data); - data =3D readw(s->addr + OMAP_I2C_CON); + qtest_writew(i2c->qts, s->addr + OMAP_I2C_CON, data); + data =3D qtest_readw(i2c->qts, s->addr + OMAP_I2C_CON); g_assert((data & OMAP_I2C_CON_STP) !=3D 0); =20 - data =3D readw(s->addr + OMAP_I2C_STAT); + data =3D qtest_readw(i2c->qts, s->addr + OMAP_I2C_STAT); g_assert((data & OMAP_I2C_STAT_NACK) =3D=3D 0); =20 while (len > 1) { - data =3D readw(s->addr + OMAP_I2C_STAT); + data =3D qtest_readw(i2c->qts, s->addr + OMAP_I2C_STAT); g_assert((data & OMAP_I2C_STAT_XRDY) !=3D 0); =20 data =3D buf[0] | ((uint16_t)buf[1] << 8); - writew(s->addr + OMAP_I2C_DATA, data); + qtest_writew(i2c->qts, s->addr + OMAP_I2C_DATA, data); buf =3D (uint8_t *)buf + 2; len -=3D 2; } if (len =3D=3D 1) { - data =3D readw(s->addr + OMAP_I2C_STAT); + data =3D qtest_readw(i2c->qts, s->addr + OMAP_I2C_STAT); g_assert((data & OMAP_I2C_STAT_XRDY) !=3D 0); =20 data =3D buf[0]; - writew(s->addr + OMAP_I2C_DATA, data); + qtest_writew(i2c->qts, s->addr + OMAP_I2C_DATA, data); } =20 - data =3D readw(s->addr + OMAP_I2C_CON); + data =3D qtest_readw(i2c->qts, s->addr + OMAP_I2C_CON); g_assert((data & OMAP_I2C_CON_STP) =3D=3D 0); } =20 @@ -109,30 +109,30 @@ static void omap_i2c_recv(I2CAdapter *i2c, uint8_t ad= dr, omap_i2c_set_slave_addr(s, addr); =20 data =3D len; - writew(s->addr + OMAP_I2C_CNT, data); + qtest_writew(i2c->qts, s->addr + OMAP_I2C_CNT, data); =20 data =3D OMAP_I2C_CON_I2C_EN | OMAP_I2C_CON_MST | OMAP_I2C_CON_STT | OMAP_I2C_CON_STP; - writew(s->addr + OMAP_I2C_CON, data); - data =3D readw(s->addr + OMAP_I2C_CON); + qtest_writew(i2c->qts, s->addr + OMAP_I2C_CON, data); + data =3D qtest_readw(i2c->qts, s->addr + OMAP_I2C_CON); g_assert((data & OMAP_I2C_CON_STP) =3D=3D 0); =20 - data =3D readw(s->addr + OMAP_I2C_STAT); + data =3D qtest_readw(i2c->qts, s->addr + OMAP_I2C_STAT); g_assert((data & OMAP_I2C_STAT_NACK) =3D=3D 0); =20 - data =3D readw(s->addr + OMAP_I2C_CNT); + data =3D qtest_readw(i2c->qts, s->addr + OMAP_I2C_CNT); g_assert_cmpuint(data, =3D=3D, len); =20 while (len > 0) { - data =3D readw(s->addr + OMAP_I2C_STAT); + data =3D qtest_readw(i2c->qts, s->addr + OMAP_I2C_STAT); g_assert((data & OMAP_I2C_STAT_RRDY) !=3D 0); g_assert((data & OMAP_I2C_STAT_ROVR) =3D=3D 0); =20 - data =3D readw(s->addr + OMAP_I2C_DATA); + data =3D qtest_readw(i2c->qts, s->addr + OMAP_I2C_DATA); =20 - stat =3D readw(s->addr + OMAP_I2C_STAT); + stat =3D qtest_readw(i2c->qts, s->addr + OMAP_I2C_STAT); =20 if (unlikely(len =3D=3D 1)) { g_assert((stat & OMAP_I2C_STAT_SBD) !=3D 0); @@ -148,11 +148,11 @@ static void omap_i2c_recv(I2CAdapter *i2c, uint8_t ad= dr, } } =20 - data =3D readw(s->addr + OMAP_I2C_CON); + data =3D qtest_readw(i2c->qts, s->addr + OMAP_I2C_CON); g_assert((data & OMAP_I2C_CON_STP) =3D=3D 0); } =20 -I2CAdapter *omap_i2c_create(uint64_t addr) +I2CAdapter *omap_i2c_create(QTestState *qts, uint64_t addr) { OMAPI2C *s =3D g_malloc0(sizeof(*s)); I2CAdapter *i2c =3D (I2CAdapter *)s; @@ -162,9 +162,10 @@ I2CAdapter *omap_i2c_create(uint64_t addr) =20 i2c->send =3D omap_i2c_send; i2c->recv =3D omap_i2c_recv; + i2c->qts =3D qts; =20 /* verify the mmio address by looking for a known signature */ - data =3D readw(addr + OMAP_I2C_REV); + data =3D qtest_readw(qts, addr + OMAP_I2C_REV); g_assert_cmphex(data, =3D=3D, 0x34); =20 return i2c; diff --git a/tests/libqos/i2c.h b/tests/libqos/i2c.h index 6e648f9..eb40b80 100644 --- a/tests/libqos/i2c.h +++ b/tests/libqos/i2c.h @@ -9,6 +9,7 @@ #ifndef LIBQOS_I2C_H #define LIBQOS_I2C_H =20 +#include "libqtest.h" =20 typedef struct I2CAdapter I2CAdapter; struct I2CAdapter { @@ -16,6 +17,8 @@ struct I2CAdapter { const uint8_t *buf, uint16_t len); void (*recv)(I2CAdapter *adapter, uint8_t addr, uint8_t *buf, uint16_t len); + + QTestState *qts; }; =20 void i2c_send(I2CAdapter *i2c, uint8_t addr, @@ -24,9 +27,9 @@ void i2c_recv(I2CAdapter *i2c, uint8_t addr, uint8_t *buf, uint16_t len); =20 /* libi2c-omap.c */ -I2CAdapter *omap_i2c_create(uint64_t addr); +I2CAdapter *omap_i2c_create(QTestState *qts, uint64_t addr); =20 /* libi2c-imx.c */ -I2CAdapter *imx_i2c_create(uint64_t addr); +I2CAdapter *imx_i2c_create(QTestState *qts, uint64_t addr); =20 #endif diff --git a/tests/tmp105-test.c b/tests/tmp105-test.c index a7940a4..382f88b 100644 --- a/tests/tmp105-test.c +++ b/tests/tmp105-test.c @@ -154,15 +154,13 @@ int main(int argc, char **argv) s =3D qtest_start("-machine n800 " "-device tmp105,bus=3Di2c-bus.0,id=3D" TMP105_TEST_ID ",address=3D0x49"); - i2c =3D omap_i2c_create(OMAP2_I2C_1_BASE); + i2c =3D omap_i2c_create(s, OMAP2_I2C_1_BASE); =20 qtest_add_func("/tmp105/tx-rx", send_and_receive); =20 ret =3D g_test_run(); =20 - if (s) { - qtest_quit(s); - } + qtest_quit(s); g_free(i2c); =20 return ret; --=20 1.8.3.1 From nobody Sat Apr 27 17:22:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518121716259396.0641758087967; Thu, 8 Feb 2018 12:28:36 -0800 (PST) Received: from localhost ([::1]:45260 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejso7-0002EI-1q for importer@patchew.org; Thu, 08 Feb 2018 15:28:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45374) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejsW4-0002MN-UC for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:09:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ejsW3-0002MD-Cg for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:09:56 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53828 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ejsW3-0002M4-7D for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:09:55 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DE536404084A for ; Thu, 8 Feb 2018 20:09:54 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-204-120.brq.redhat.com [10.40.204.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 10B39B301A; Thu, 8 Feb 2018 20:09:53 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Thu, 8 Feb 2018 21:09:35 +0100 Message-Id: <1518120582-26647-8-git-send-email-thuth@redhat.com> In-Reply-To: <1518120582-26647-1-git-send-email-thuth@redhat.com> References: <1518120582-26647-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 08 Feb 2018 20:09:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 08 Feb 2018 20:09:54 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 07/14] libqos: Use explicit QTestState for ahci operations X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake Drop one more client of global_qtest by teaching all ahci test functionality to pass in an explicit QTestState. The state was already available, so no callers had to be adjusted. Signed-off-by: Eric Blake Reviewed-by: John Snow Reviewed-by: Thomas Huth Signed-off-by: Thomas Huth --- tests/libqos/ahci.c | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/tests/libqos/ahci.c b/tests/libqos/ahci.c index 40c532e..bc201d7 100644 --- a/tests/libqos/ahci.c +++ b/tests/libqos/ahci.c @@ -283,7 +283,8 @@ void ahci_hba_enable(AHCIQState *ahci) /* Allocate Memory for the Command List Buffer & FIS Buffer */ /* PxCLB space ... 0x20 per command, as in 4.2.2 p 36 */ ahci->port[i].clb =3D ahci_alloc(ahci, num_cmd_slots * 0x20); - qmemset(ahci->port[i].clb, 0x00, num_cmd_slots * 0x20); + qtest_memset(ahci->parent->qts, ahci->port[i].clb, 0x00, + num_cmd_slots * 0x20); g_test_message("CLB: 0x%08" PRIx64, ahci->port[i].clb); ahci_px_wreg(ahci, i, AHCI_PX_CLB, ahci->port[i].clb); g_assert_cmphex(ahci->port[i].clb, =3D=3D, @@ -291,7 +292,7 @@ void ahci_hba_enable(AHCIQState *ahci) =20 /* PxFB space ... 0x100, as in 4.2.1 p 35 */ ahci->port[i].fb =3D ahci_alloc(ahci, 0x100); - qmemset(ahci->port[i].fb, 0x00, 0x100); + qtest_memset(ahci->parent->qts, ahci->port[i].fb, 0x00, 0x100); g_test_message("FB: 0x%08" PRIx64, ahci->port[i].fb); ahci_px_wreg(ahci, i, AHCI_PX_FB, ahci->port[i].fb); g_assert_cmphex(ahci->port[i].fb, =3D=3D, @@ -397,7 +398,7 @@ void ahci_port_clear(AHCIQState *ahci, uint8_t port) g_assert_cmphex(ahci_px_rreg(ahci, port, AHCI_PX_IS), =3D=3D, 0); =20 /* Wipe the FIS-Receive Buffer */ - qmemset(ahci->port[port].fb, 0x00, 0x100); + qtest_memset(ahci->parent->qts, ahci->port[port].fb, 0x00, 0x100); } =20 /** @@ -466,7 +467,7 @@ void ahci_port_check_d2h_sanity(AHCIQState *ahci, uint8= _t port, uint8_t slot) RegD2HFIS *d2h =3D g_malloc0(0x20); uint32_t reg; =20 - memread(ahci->port[port].fb + 0x40, d2h, 0x20); + qtest_memread(ahci->parent->qts, ahci->port[port].fb + 0x40, d2h, 0x20= ); g_assert_cmphex(d2h->fis_type, =3D=3D, 0x34); =20 reg =3D ahci_px_rreg(ahci, port, AHCI_PX_TFD); @@ -484,7 +485,7 @@ void ahci_port_check_pio_sanity(AHCIQState *ahci, uint8= _t port, /* We cannot check the Status or E_Status registers, because * the status may have again changed between the PIO Setup FIS * and the conclusion of the command with the D2H Register FIS. */ - memread(ahci->port[port].fb + 0x20, pio, 0x20); + qtest_memread(ahci->parent->qts, ahci->port[port].fb + 0x20, pio, 0x20= ); g_assert_cmphex(pio->fis_type, =3D=3D, 0x5f); =20 /* BUG: PIO Setup FIS as utilized by QEMU tries to fit the entire @@ -516,7 +517,7 @@ void ahci_get_command_header(AHCIQState *ahci, uint8_t = port, { uint64_t ba =3D ahci->port[port].clb; ba +=3D slot * sizeof(AHCICommandHeader); - memread(ba, cmd, sizeof(AHCICommandHeader)); + qtest_memread(ahci->parent->qts, ba, cmd, sizeof(AHCICommandHeader)); =20 cmd->flags =3D le16_to_cpu(cmd->flags); cmd->prdtl =3D le16_to_cpu(cmd->prdtl); @@ -537,7 +538,7 @@ void ahci_set_command_header(AHCIQState *ahci, uint8_t = port, tmp.prdbc =3D cpu_to_le32(cmd->prdbc); tmp.ctba =3D cpu_to_le64(cmd->ctba); =20 - memwrite(ba, &tmp, sizeof(AHCICommandHeader)); + qtest_memwrite(ahci->parent->qts, ba, &tmp, sizeof(AHCICommandHeader)); } =20 void ahci_destroy_command(AHCIQState *ahci, uint8_t port, uint8_t slot) @@ -575,7 +576,7 @@ void ahci_write_fis(AHCIQState *ahci, AHCICommand *cmd) tmp.count =3D cpu_to_le16(tmp.count); } =20 - memwrite(addr, &tmp, sizeof(tmp)); + qtest_memwrite(ahci->parent->qts, addr, &tmp, sizeof(tmp)); } =20 unsigned ahci_pick_cmd(AHCIQState *ahci, uint8_t port) @@ -636,7 +637,7 @@ void ahci_exec(AHCIQState *ahci, uint8_t port, if (opts->size && !opts->buffer) { opts->buffer =3D ahci_alloc(ahci, opts->size); g_assert(opts->buffer); - qmemset(opts->buffer, 0x00, opts->size); + qtest_memset(ahci->parent->qts, opts->buffer, 0x00, opts->size); } =20 /* Command creation */ @@ -661,15 +662,15 @@ void ahci_exec(AHCIQState *ahci, uint8_t port, ahci_command_commit(ahci, cmd, port); ahci_command_issue_async(ahci, cmd); if (opts->error) { - qmp_eventwait("STOP"); + qtest_qmp_eventwait(ahci->parent->qts, "STOP"); } if (opts->mid_cb) { rc =3D opts->mid_cb(ahci, cmd, opts); g_assert_cmpint(rc, =3D=3D, 0); } if (opts->error) { - qmp_async("{'execute':'cont' }"); - qmp_eventwait("RESUME"); + qtest_async_qmp(ahci->parent->qts, "{'execute':'cont' }"); + qtest_qmp_eventwait(ahci->parent->qts, "RESUME"); } =20 /* Wait for command to complete and verify sanity */ @@ -697,7 +698,7 @@ AHCICommand *ahci_guest_io_halt(AHCIQState *ahci, uint8= _t port, ahci_command_adjust(cmd, sector, buffer, bufsize, 0); ahci_command_commit(ahci, cmd, port); ahci_command_issue_async(ahci, cmd); - qmp_eventwait("STOP"); + qtest_qmp_eventwait(ahci->parent->qts, "STOP"); =20 return cmd; } @@ -706,8 +707,8 @@ AHCICommand *ahci_guest_io_halt(AHCIQState *ahci, uint8= _t port, void ahci_guest_io_resume(AHCIQState *ahci, AHCICommand *cmd) { /* Complete the command */ - qmp_async("{'execute':'cont' }"); - qmp_eventwait("RESUME"); + qtest_async_qmp(ahci->parent->qts, "{'execute':'cont' }"); + qtest_qmp_eventwait(ahci->parent->qts, "RESUME"); ahci_command_wait(ahci, cmd); ahci_command_verify(ahci, cmd); ahci_command_free(cmd); @@ -754,16 +755,16 @@ void ahci_io(AHCIQState *ahci, uint8_t port, uint8_t = ide_cmd, g_assert(props); ptr =3D ahci_alloc(ahci, bufsize); g_assert(!bufsize || ptr); - qmemset(ptr, 0x00, bufsize); + qtest_memset(ahci->parent->qts, ptr, 0x00, bufsize); =20 if (bufsize && props->write) { - bufwrite(ptr, buffer, bufsize); + qtest_bufwrite(ahci->parent->qts, ptr, buffer, bufsize); } =20 ahci_guest_io(ahci, port, ide_cmd, ptr, bufsize, sector); =20 if (bufsize && props->read) { - bufread(ptr, buffer, bufsize); + qtest_bufread(ahci->parent->qts, ptr, buffer, bufsize); } =20 ahci_free(ahci, ptr); @@ -901,7 +902,7 @@ static int copy_buffer(AHCIQState *ahci, AHCICommand *c= md, const AHCIOpts *opts) { unsigned char *rx =3D opts->opaque; - bufread(opts->buffer, rx, opts->size); + qtest_bufread(ahci->parent->qts, opts->buffer, rx, opts->size); return 0; } =20 @@ -1141,7 +1142,7 @@ void ahci_command_commit(AHCIQState *ahci, AHCIComman= d *cmd, uint8_t port) ahci_write_fis(ahci, cmd); /* Then ATAPI CMD, if needed */ if (cmd->props->atapi) { - memwrite(table_ptr + 0x40, cmd->atapi_cmd, 16); + qtest_memwrite(ahci->parent->qts, table_ptr + 0x40, cmd->atapi_cmd= , 16); } =20 /* Construct and write the PRDs to the command table */ @@ -1162,8 +1163,8 @@ void ahci_command_commit(AHCIQState *ahci, AHCIComman= d *cmd, uint8_t port) prd.dbc |=3D cpu_to_le32(0x80000000); /* Request DPS Interrupt */ =20 /* Commit the PRD entry to the Command Table */ - memwrite(table_ptr + 0x80 + (i * sizeof(PRD)), - &prd, sizeof(PRD)); + qtest_memwrite(ahci->parent->qts, table_ptr + 0x80 + (i * sizeof(P= RD)), + &prd, sizeof(PRD)); } =20 /* Bookmark the PRDTL and CTBA values */ --=20 1.8.3.1 From nobody Sat Apr 27 17:22:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518122125613477.1064548838792; Thu, 8 Feb 2018 12:35:25 -0800 (PST) Received: from localhost ([::1]:46095 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejsuh-0008Pe-Qu for importer@patchew.org; Thu, 08 Feb 2018 15:35:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45394) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejsW6-0002NC-B4 for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:10:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ejsW4-0002Mj-KV for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:09:58 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:43662 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ejsW4-0002MT-E3 for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:09:56 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 17A7640FB62E for ; Thu, 8 Feb 2018 20:09:56 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-204-120.brq.redhat.com [10.40.204.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4885CB07B8; Thu, 8 Feb 2018 20:09:55 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Thu, 8 Feb 2018 21:09:36 +0100 Message-Id: <1518120582-26647-9-git-send-email-thuth@redhat.com> In-Reply-To: <1518120582-26647-1-git-send-email-thuth@redhat.com> References: <1518120582-26647-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 08 Feb 2018 20:09:56 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 08 Feb 2018 20:09:56 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 08/14] libqos: Use explicit QTestState for remaining libqos operations X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake Drop one more client of global_qtest by teaching all remaining libqos stragglers to pass in an explicit QTestState. Change the setting of global_qtest from being implicit in libqos' call to qtest_start() to instead be explicit in all clients that are still relying on global_qtest. Note that qmp_execute() can be greatly simplified in the process, and that we also get rid of interpolation of a JSON string into a temporary variable when qtest_qmp() can do it more reliably. Signed-off-by: Eric Blake Acked-by: Greg Kurz Reviewed-by: John Snow Signed-off-by: Thomas Huth --- tests/ahci-test.c | 1 + tests/ivshmem-test.c | 1 + tests/libqos/libqos-pc.c | 2 +- tests/libqos/libqos.c | 30 ++++++++++-------------------- tests/megasas-test.c | 5 ++++- tests/rtas-test.c | 1 + tests/usb-hcd-uhci-test.c | 1 + tests/virtio-9p-test.c | 1 + tests/virtio-blk-test.c | 1 + tests/virtio-net-test.c | 15 +++++++++------ tests/virtio-scsi-test.c | 16 +++++++++------- 11 files changed, 39 insertions(+), 35 deletions(-) diff --git a/tests/ahci-test.c b/tests/ahci-test.c index d9c99b7..f2a3926 100644 --- a/tests/ahci-test.c +++ b/tests/ahci-test.c @@ -157,6 +157,7 @@ static AHCIQState *ahci_vboot(const char *cli, va_list = ap) =20 s =3D g_new0(AHCIQState, 1); s->parent =3D qtest_pc_vboot(cli, ap); + global_qtest =3D s->parent->qts; alloc_set_flags(s->parent->alloc, ALLOC_LEAK_ASSERT); =20 /* Verify that we have an AHCI device present. */ diff --git a/tests/ivshmem-test.c b/tests/ivshmem-test.c index 3776342..8af16ee 100644 --- a/tests/ivshmem-test.c +++ b/tests/ivshmem-test.c @@ -131,6 +131,7 @@ static void setup_vm_cmd(IVState *s, const char *cmd, b= ool msix) g_printerr("ivshmem-test tests are only available on x86 or ppc64\= n"); exit(EXIT_FAILURE); } + global_qtest =3D s->qs->qts; s->dev =3D get_device(s->qs->pcibus); =20 s->reg_bar =3D qpci_iomap(s->dev, 0, &barsize); diff --git a/tests/libqos/libqos-pc.c b/tests/libqos/libqos-pc.c index b554758..a9c1ace 100644 --- a/tests/libqos/libqos-pc.c +++ b/tests/libqos/libqos-pc.c @@ -25,7 +25,7 @@ QOSState *qtest_pc_boot(const char *cmdline_fmt, ...) qs =3D qtest_vboot(&qos_ops, cmdline_fmt, ap); va_end(ap); =20 - qtest_irq_intercept_in(global_qtest, "ioapic"); + qtest_irq_intercept_in(qs->qts, "ioapic"); =20 return qs; } diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c index 40018b9..9798e1d 100644 --- a/tests/libqos/libqos.c +++ b/tests/libqos/libqos.c @@ -20,7 +20,7 @@ QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fm= t, va_list ap) QOSState *qs =3D g_new0(QOSState, 1); =20 cmdline =3D g_strdup_vprintf(cmdline_fmt, ap); - qs->qts =3D qtest_start(cmdline); + qs->qts =3D qtest_init(cmdline); qs->ops =3D ops; if (ops) { qs->alloc =3D ops->init_allocator(qs->qts, ALLOC_NO_FLAGS); @@ -80,29 +80,21 @@ void set_context(QOSState *s) global_qtest =3D s->qts; } =20 -static QDict *qmp_execute(const char *command) +static QDict *qmp_execute(QTestState *qts, const char *command) { - char *fmt; - QDict *rsp; - - fmt =3D g_strdup_printf("{ 'execute': '%s' }", command); - rsp =3D qmp(fmt); - g_free(fmt); - - return rsp; + return qtest_qmp(qts, "{ 'execute': %s }", command); } =20 void migrate(QOSState *from, QOSState *to, const char *uri) { const char *st; - char *s; QDict *rsp, *sub; bool running; =20 set_context(from); =20 /* Is the machine currently running? */ - rsp =3D qmp_execute("query-status"); + rsp =3D qmp_execute(from->qts, "query-status"); g_assert(qdict_haskey(rsp, "return")); sub =3D qdict_get_qdict(rsp, "return"); g_assert(qdict_haskey(sub, "running")); @@ -110,30 +102,28 @@ void migrate(QOSState *from, QOSState *to, const char= *uri) QDECREF(rsp); =20 /* Issue the migrate command. */ - s =3D g_strdup_printf("{ 'execute': 'migrate'," - "'arguments': { 'uri': '%s' } }", - uri); - rsp =3D qmp(s); - g_free(s); + rsp =3D qtest_qmp(from->qts, + "{ 'execute': 'migrate', 'arguments': { 'uri': %s }}", + uri); g_assert(qdict_haskey(rsp, "return")); QDECREF(rsp); =20 /* Wait for STOP event, but only if we were running: */ if (running) { - qmp_eventwait("STOP"); + qtest_qmp_eventwait(from->qts, "STOP"); } =20 /* If we were running, we can wait for an event. */ if (running) { migrate_allocator(from->alloc, to->alloc); set_context(to); - qmp_eventwait("RESUME"); + qtest_qmp_eventwait(to->qts, "RESUME"); return; } =20 /* Otherwise, we need to wait: poll until migration is completed. */ while (1) { - rsp =3D qmp_execute("query-migrate"); + rsp =3D qmp_execute(from->qts, "query-migrate"); g_assert(qdict_haskey(rsp, "return")); sub =3D qdict_get_qdict(rsp, "return"); g_assert(qdict_haskey(sub, "status")); diff --git a/tests/megasas-test.c b/tests/megasas-test.c index ce960e7..81837e1 100644 --- a/tests/megasas-test.c +++ b/tests/megasas-test.c @@ -15,13 +15,16 @@ =20 static QOSState *qmegasas_start(const char *extra_opts) { + QOSState *qs; const char *arch =3D qtest_get_arch(); const char *cmd =3D "-drive id=3Dhd0,if=3Dnone,file=3Dnull-co://,forma= t=3Draw " "-device megasas,id=3Dscsi0,addr=3D04.0 " "-device scsi-hd,bus=3Dscsi0.0,drive=3Dhd0 %s"; =20 if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { - return qtest_pc_boot(cmd, extra_opts ? : ""); + qs =3D qtest_pc_boot(cmd, extra_opts ? : ""); + global_qtest =3D qs->qts; + return qs; } =20 g_printerr("virtio-scsi tests are only available on x86 or ppc64\n"); diff --git a/tests/rtas-test.c b/tests/rtas-test.c index 34a6921..009bda6 100644 --- a/tests/rtas-test.c +++ b/tests/rtas-test.c @@ -14,6 +14,7 @@ static void test_rtas_get_time_of_day(void) time_t t1, t2; =20 qs =3D qtest_spapr_boot("-machine pseries"); + global_qtest =3D qs->qts; =20 t1 =3D time(NULL); ret =3D qrtas_get_time_of_day(qs->qts, qs->alloc, &tm, &ns); diff --git a/tests/usb-hcd-uhci-test.c b/tests/usb-hcd-uhci-test.c index 62e0c78..6a7e5a2 100644 --- a/tests/usb-hcd-uhci-test.c +++ b/tests/usb-hcd-uhci-test.c @@ -77,6 +77,7 @@ int main(int argc, char **argv) "available on x86 or ppc64\n"); exit(EXIT_FAILURE); } + global_qtest =3D qs->qts; ret =3D g_test_run(); qtest_shutdown(qs); =20 diff --git a/tests/virtio-9p-test.c b/tests/virtio-9p-test.c index 54edcb9..a2b3108 100644 --- a/tests/virtio-9p-test.c +++ b/tests/virtio-9p-test.c @@ -44,6 +44,7 @@ static QVirtIO9P *qvirtio_9p_start(const char *driver) g_printerr("virtio-9p tests are only available on x86 or ppc64\n"); exit(EXIT_FAILURE); } + global_qtest =3D v9p->qs->qts; =20 return v9p; } diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c index 2ac64e5..9be9ffb 100644 --- a/tests/virtio-blk-test.c +++ b/tests/virtio-blk-test.c @@ -77,6 +77,7 @@ static QOSState *pci_test_start(void) g_printerr("virtio-blk tests are only available on x86 or ppc64\n"= ); exit(EXIT_FAILURE); } + global_qtest =3D qs->qts; unlink(tmp_path); g_free(tmp_path); return qs; diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c index ea634dc..e15bc48 100644 --- a/tests/virtio-net-test.c +++ b/tests/virtio-net-test.c @@ -53,18 +53,21 @@ static QVirtioPCIDevice *virtio_net_pci_init(QPCIBus *b= us, int slot) =20 static QOSState *pci_test_start(int socket) { + QOSState *qs; const char *arch =3D qtest_get_arch(); const char *cmd =3D "-netdev socket,fd=3D%d,id=3Dhs0 -device " "virtio-net-pci,netdev=3Dhs0"; =20 if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { - return qtest_pc_boot(cmd, socket); - } - if (strcmp(arch, "ppc64") =3D=3D 0) { - return qtest_spapr_boot(cmd, socket); + qs =3D qtest_pc_boot(cmd, socket); + } else if (strcmp(arch, "ppc64") =3D=3D 0) { + qs =3D qtest_spapr_boot(cmd, socket); + } else { + g_printerr("virtio-net tests are only available on x86 or ppc64\n"= ); + exit(EXIT_FAILURE); } - g_printerr("virtio-net tests are only available on x86 or ppc64\n"); - exit(EXIT_FAILURE); + global_qtest =3D qs->qts; + return qs; } =20 static void driver_init(QVirtioDevice *dev) diff --git a/tests/virtio-scsi-test.c b/tests/virtio-scsi-test.c index bcf408f..7393d69 100644 --- a/tests/virtio-scsi-test.c +++ b/tests/virtio-scsi-test.c @@ -34,20 +34,22 @@ typedef struct { =20 static QOSState *qvirtio_scsi_start(const char *extra_opts) { + QOSState *qs; const char *arch =3D qtest_get_arch(); const char *cmd =3D "-drive id=3Ddrv0,if=3Dnone,file=3Dnull-co://,form= at=3Draw " "-device virtio-scsi-pci,id=3Dvs0 " "-device scsi-hd,bus=3Dvs0.0,drive=3Ddrv0 %s"; =20 if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { - return qtest_pc_boot(cmd, extra_opts ? : ""); - } - if (strcmp(arch, "ppc64") =3D=3D 0) { - return qtest_spapr_boot(cmd, extra_opts ? : ""); + qs =3D qtest_pc_boot(cmd, extra_opts ? : ""); + } else if (strcmp(arch, "ppc64") =3D=3D 0) { + qs =3D qtest_spapr_boot(cmd, extra_opts ? : ""); + } else { + g_printerr("virtio-scsi tests are only available on x86 or ppc64\n= "); + exit(EXIT_FAILURE); } - - g_printerr("virtio-scsi tests are only available on x86 or ppc64\n"); - exit(EXIT_FAILURE); + global_qtest =3D qs->qts; + return qs; } =20 static void qvirtio_scsi_stop(QOSState *qs) --=20 1.8.3.1 From nobody Sat Apr 27 17:22:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518122367566254.1740702398797; Thu, 8 Feb 2018 12:39:27 -0800 (PST) Received: from localhost ([::1]:46483 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejsyc-00042o-N9 for importer@patchew.org; Thu, 08 Feb 2018 15:39:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45408) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejsW7-0002O8-B9 for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:10:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ejsW5-0002NL-Rf for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:09:59 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60202 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ejsW5-0002N8-Ll for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:09:57 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 59FBFEAEA8 for ; Thu, 8 Feb 2018 20:09:57 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-204-120.brq.redhat.com [10.40.204.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 804F9B07B8; Thu, 8 Feb 2018 20:09:56 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Thu, 8 Feb 2018 21:09:37 +0100 Message-Id: <1518120582-26647-10-git-send-email-thuth@redhat.com> In-Reply-To: <1518120582-26647-1-git-send-email-thuth@redhat.com> References: <1518120582-26647-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 08 Feb 2018 20:09:57 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 08 Feb 2018 20:09:57 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 09/14] qmp-test: Drop dependence on global_qtest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake As a general rule, we prefer avoiding implicit global state because it makes code harder to safely copy and paste without thinking about the global state. Although qmp-test does not maintain parallel qtest connections, it was the last test assigning to global_qtest. It's just as easy to be explicit about the state; once all tests have been cleaned up, a later patch can then get rid of global_qtest and a layer of wrappers in libqtest. Signed-off-by: Eric Blake Reviewed-by: Thomas Huth Signed-off-by: Thomas Huth --- tests/qmp-test.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/tests/qmp-test.c b/tests/qmp-test.c index 36feb22..db34c45 100644 --- a/tests/qmp-test.c +++ b/tests/qmp-test.c @@ -41,32 +41,32 @@ static void test_version(QObject *version) visit_free(v); } =20 -static void test_malformed(void) +static void test_malformed(QTestState *qts) { QDict *resp; =20 /* Not even a dictionary */ - resp =3D qmp("null"); + resp =3D qtest_qmp(qts, "null"); g_assert_cmpstr(get_error_class(resp), =3D=3D, "GenericError"); QDECREF(resp); =20 /* No "execute" key */ - resp =3D qmp("{}"); + resp =3D qtest_qmp(qts, "{}"); g_assert_cmpstr(get_error_class(resp), =3D=3D, "GenericError"); QDECREF(resp); =20 /* "execute" isn't a string */ - resp =3D qmp("{ 'execute': true }"); + resp =3D qtest_qmp(qts, "{ 'execute': true }"); g_assert_cmpstr(get_error_class(resp), =3D=3D, "GenericError"); QDECREF(resp); =20 /* "arguments" isn't a dictionary */ - resp =3D qmp("{ 'execute': 'no-such-cmd', 'arguments': [] }"); + resp =3D qtest_qmp(qts, "{ 'execute': 'no-such-cmd', 'arguments': [] }= "); g_assert_cmpstr(get_error_class(resp), =3D=3D, "GenericError"); QDECREF(resp); =20 /* extra key */ - resp =3D qmp("{ 'execute': 'no-such-cmd', 'extra': true }"); + resp =3D qtest_qmp(qts, "{ 'execute': 'no-such-cmd', 'extra': true }"); g_assert_cmpstr(get_error_class(resp), =3D=3D, "GenericError"); QDECREF(resp); } @@ -75,11 +75,12 @@ static void test_qmp_protocol(void) { QDict *resp, *q, *ret; QList *capabilities; + QTestState *qts; =20 - global_qtest =3D qtest_init_without_qmp_handshake(common_args); + qts =3D qtest_init_without_qmp_handshake(common_args); =20 /* Test greeting */ - resp =3D qmp_receive(); + resp =3D qtest_qmp_receive(qts); q =3D qdict_get_qdict(resp, "QMP"); g_assert(q); test_version(qdict_get(q, "version")); @@ -88,46 +89,46 @@ static void test_qmp_protocol(void) QDECREF(resp); =20 /* Test valid command before handshake */ - resp =3D qmp("{ 'execute': 'query-version' }"); + resp =3D qtest_qmp(qts, "{ 'execute': 'query-version' }"); g_assert_cmpstr(get_error_class(resp), =3D=3D, "CommandNotFound"); QDECREF(resp); =20 /* Test malformed commands before handshake */ - test_malformed(); + test_malformed(qts); =20 /* Test handshake */ - resp =3D qmp("{ 'execute': 'qmp_capabilities' }"); + resp =3D qtest_qmp(qts, "{ 'execute': 'qmp_capabilities' }"); ret =3D qdict_get_qdict(resp, "return"); g_assert(ret && !qdict_size(ret)); QDECREF(resp); =20 /* Test repeated handshake */ - resp =3D qmp("{ 'execute': 'qmp_capabilities' }"); + resp =3D qtest_qmp(qts, "{ 'execute': 'qmp_capabilities' }"); g_assert_cmpstr(get_error_class(resp), =3D=3D, "CommandNotFound"); QDECREF(resp); =20 /* Test valid command */ - resp =3D qmp("{ 'execute': 'query-version' }"); + resp =3D qtest_qmp(qts, "{ 'execute': 'query-version' }"); test_version(qdict_get(resp, "return")); QDECREF(resp); =20 /* Test malformed commands */ - test_malformed(); + test_malformed(qts); =20 /* Test 'id' */ - resp =3D qmp("{ 'execute': 'query-name', 'id': 'cookie#1' }"); + resp =3D qtest_qmp(qts, "{ 'execute': 'query-name', 'id': 'cookie#1' }= "); ret =3D qdict_get_qdict(resp, "return"); g_assert(ret); g_assert_cmpstr(qdict_get_try_str(resp, "id"), =3D=3D, "cookie#1"); QDECREF(resp); =20 /* Test command failure with 'id' */ - resp =3D qmp("{ 'execute': 'human-monitor-command', 'id': 2 }"); + resp =3D qtest_qmp(qts, "{ 'execute': 'human-monitor-command', 'id': 2= }"); g_assert_cmpstr(get_error_class(resp), =3D=3D, "GenericError"); g_assert_cmpint(qdict_get_int(resp, "id"), =3D=3D, 2); QDECREF(resp); =20 - qtest_end(); + qtest_quit(qts); } =20 static int query_error_class(const char *cmd) --=20 1.8.3.1 From nobody Sat Apr 27 17:22:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518121121455324.98346816474543; Thu, 8 Feb 2018 12:18:41 -0800 (PST) Received: from localhost ([::1]:43850 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejseW-0001Dx-IJ for importer@patchew.org; Thu, 08 Feb 2018 15:18:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45430) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejsW8-0002P6-6x for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:10:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ejsW7-0002O8-1W for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:10:00 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53832 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ejsW6-0002Nm-Ts for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:09:58 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 91D2E404084E for ; Thu, 8 Feb 2018 20:09:58 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-204-120.brq.redhat.com [10.40.204.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id B838CB3011; Thu, 8 Feb 2018 20:09:57 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Thu, 8 Feb 2018 21:09:38 +0100 Message-Id: <1518120582-26647-11-git-send-email-thuth@redhat.com> In-Reply-To: <1518120582-26647-1-git-send-email-thuth@redhat.com> References: <1518120582-26647-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 08 Feb 2018 20:09:58 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 08 Feb 2018 20:09:58 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 10/14] tests/boot-sector: Drop dependence on global_qtest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake As a general rule, we prefer avoiding implicit global state because it makes code harder to safely copy and paste without thinking about the global state. Adjust the helper code to use explicit state instead, and update all callers. Fix some trailing whitespace while touching the file. Signed-off-by: Eric Blake Reviewed-by: Thomas Huth Acked-by: Michael S. Tsirkin Signed-off-by: Thomas Huth --- tests/bios-tables-test.c | 2 +- tests/boot-sector.c | 8 ++++---- tests/boot-sector.h | 6 ++++-- tests/pxe-test.c | 2 +- tests/vmgenid-test.c | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c index b354aaa..25c85b5 100644 --- a/tests/bios-tables-test.c +++ b/tests/bios-tables-test.c @@ -639,7 +639,7 @@ static void test_acpi_one(const char *params, test_data= *data) =20 qtest_start(args); =20 - boot_sector_test(); + boot_sector_test(global_qtest); =20 data->tables =3D g_array_new(false, true, sizeof(AcpiSdtTable)); test_acpi_rsdp_address(data); diff --git a/tests/boot-sector.c b/tests/boot-sector.c index be29d5b..c373f0e 100644 --- a/tests/boot-sector.c +++ b/tests/boot-sector.c @@ -5,7 +5,7 @@ * * Authors: * Michael S. Tsirkin - * Victor Kaplansky =20 + * Victor Kaplansky * * This work is licensed under the terms of the GNU GPL, version 2 or late= r. * See the COPYING file in the top-level directory. @@ -130,7 +130,7 @@ int boot_sector_init(char *fname) } =20 /* Loop until signature in memory is OK. */ -void boot_sector_test(void) +void boot_sector_test(QTestState *qts) { uint8_t signature_low; uint8_t signature_high; @@ -146,8 +146,8 @@ void boot_sector_test(void) * instruction. */ for (i =3D 0; i < TEST_CYCLES; ++i) { - signature_low =3D readb(SIGNATURE_ADDR); - signature_high =3D readb(SIGNATURE_ADDR + 1); + signature_low =3D qtest_readb(qts, SIGNATURE_ADDR); + signature_high =3D qtest_readb(qts, SIGNATURE_ADDR + 1); signature =3D (signature_high << 8) | signature_low; if (signature =3D=3D SIGNATURE) { break; diff --git a/tests/boot-sector.h b/tests/boot-sector.h index 35d61c7..6ee6bb4 100644 --- a/tests/boot-sector.h +++ b/tests/boot-sector.h @@ -5,7 +5,7 @@ * * Authors: * Michael S. Tsirkin - * Victor Kaplansky =20 + * Victor Kaplansky * * This work is licensed under the terms of the GNU GPL, version 2 or late= r. * See the COPYING file in the top-level directory. @@ -14,11 +14,13 @@ #ifndef TEST_BOOT_SECTOR_H #define TEST_BOOT_SECTOR_H =20 +#include "libqtest.h" + /* Create boot disk file. fname must be a suitable string for mkstemp() */ int boot_sector_init(char *fname); =20 /* Loop until signature in memory is OK. */ -void boot_sector_test(void); +void boot_sector_test(QTestState *qts); =20 /* unlink boot disk file. */ void boot_sector_cleanup(const char *fname); diff --git a/tests/pxe-test.c b/tests/pxe-test.c index 5ca8480..6e36796 100644 --- a/tests/pxe-test.c +++ b/tests/pxe-test.c @@ -71,7 +71,7 @@ static void test_pxe_one(const testdef_t *test, bool ipv6) test->model); =20 qtest_start(args); - boot_sector_test(); + boot_sector_test(global_qtest); qtest_quit(global_qtest); g_free(args); } diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c index 68ff954..824d543 100644 --- a/tests/vmgenid-test.c +++ b/tests/vmgenid-test.c @@ -44,7 +44,7 @@ static uint32_t acpi_find_vgia(void) int i; =20 /* Wait for guest firmware to finish and start the payload. */ - boot_sector_test(); + boot_sector_test(global_qtest); =20 /* Tables should be initialized now. */ rsdp_offset =3D acpi_find_rsdp_address(); --=20 1.8.3.1 From nobody Sat Apr 27 17:22:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518122528140316.9343256091271; Thu, 8 Feb 2018 12:42:08 -0800 (PST) Received: from localhost ([::1]:46657 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejt1D-0006R1-8i for importer@patchew.org; Thu, 08 Feb 2018 15:42:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45443) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejsW9-0002Se-Gb for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:10:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ejsW8-0002Ou-9W for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:10:01 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:52622 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ejsW8-0002OV-3v for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:10:00 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C9A368182D1B for ; Thu, 8 Feb 2018 20:09:59 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-204-120.brq.redhat.com [10.40.204.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id F00C4B301A; Thu, 8 Feb 2018 20:09:58 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Thu, 8 Feb 2018 21:09:39 +0100 Message-Id: <1518120582-26647-12-git-send-email-thuth@redhat.com> In-Reply-To: <1518120582-26647-1-git-send-email-thuth@redhat.com> References: <1518120582-26647-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 08 Feb 2018 20:09:59 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 08 Feb 2018 20:09:59 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 11/14] wdt_ib700-test: Drop dependence on global_qtest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake As a general rule, we prefer avoiding implicit global state because it makes code harder to safely copy and paste without thinking about the global state. Improve this test to be explicit about the state. Signed-off-by: Eric Blake Reviewed-by: Thomas Huth Signed-off-by: Thomas Huth --- tests/wdt_ib700-test.c | 63 +++++++++++++++++++++++++++-------------------= ---- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/tests/wdt_ib700-test.c b/tests/wdt_ib700-test.c index 4fc8eea..4bb8374 100644 --- a/tests/wdt_ib700-test.c +++ b/tests/wdt_ib700-test.c @@ -11,9 +11,9 @@ #include "libqtest.h" #include "qemu/timer.h" =20 -static void qmp_check_no_event(void) +static void qmp_check_no_event(QTestState *s) { - QDict *resp =3D qmp("{'execute':'query-status'}"); + QDict *resp =3D qtest_qmp(s, "{'execute':'query-status'}"); g_assert(qdict_haskey(resp, "return")); QDECREF(resp); } @@ -22,30 +22,30 @@ static QDict *ib700_program_and_wait(QTestState *s) { QDict *event, *data; =20 - clock_step(NANOSECONDS_PER_SECOND * 40); - qmp_check_no_event(); + qtest_clock_step(s, NANOSECONDS_PER_SECOND * 40); + qmp_check_no_event(s); =20 /* 2 second limit */ - outb(0x443, 14); + qtest_outb(s, 0x443, 14); =20 /* Ping */ - clock_step(NANOSECONDS_PER_SECOND); - qmp_check_no_event(); - outb(0x443, 14); + qtest_clock_step(s, NANOSECONDS_PER_SECOND); + qmp_check_no_event(s); + qtest_outb(s, 0x443, 14); =20 /* Disable */ - clock_step(NANOSECONDS_PER_SECOND); - qmp_check_no_event(); - outb(0x441, 1); - clock_step(3 * NANOSECONDS_PER_SECOND); - qmp_check_no_event(); + qtest_clock_step(s, NANOSECONDS_PER_SECOND); + qmp_check_no_event(s); + qtest_outb(s, 0x441, 1); + qtest_clock_step(s, 3 * NANOSECONDS_PER_SECOND); + qmp_check_no_event(s); =20 /* Enable and let it fire */ - outb(0x443, 13); - clock_step(3 * NANOSECONDS_PER_SECOND); - qmp_check_no_event(); - clock_step(2 * NANOSECONDS_PER_SECOND); - event =3D qmp_eventwait_ref("WATCHDOG"); + qtest_outb(s, 0x443, 13); + qtest_clock_step(s, 3 * NANOSECONDS_PER_SECOND); + qmp_check_no_event(s); + qtest_clock_step(s, 2 * NANOSECONDS_PER_SECOND); + event =3D qtest_qmp_eventwait_ref(s, "WATCHDOG"); data =3D qdict_get_qdict(event, "data"); QINCREF(data); QDECREF(event); @@ -56,48 +56,53 @@ static QDict *ib700_program_and_wait(QTestState *s) static void ib700_pause(void) { QDict *d; - QTestState *s =3D qtest_start("-watchdog-action pause -device ib700"); + QTestState *s =3D qtest_init("-watchdog-action pause -device ib700"); + qtest_irq_intercept_in(s, "ioapic"); d =3D ib700_program_and_wait(s); g_assert(!strcmp(qdict_get_str(d, "action"), "pause")); QDECREF(d); - qmp_eventwait("STOP"); - qtest_end(); + qtest_qmp_eventwait(s, "STOP"); + qtest_quit(s); } =20 static void ib700_reset(void) { QDict *d; - QTestState *s =3D qtest_start("-watchdog-action reset -device ib700"); + QTestState *s =3D qtest_init("-watchdog-action reset -device ib700"); + qtest_irq_intercept_in(s, "ioapic"); d =3D ib700_program_and_wait(s); g_assert(!strcmp(qdict_get_str(d, "action"), "reset")); QDECREF(d); - qmp_eventwait("RESET"); - qtest_end(); + qtest_qmp_eventwait(s, "RESET"); + qtest_quit(s); } =20 static void ib700_shutdown(void) { QDict *d; - QTestState *s =3D qtest_start("-watchdog-action reset -no-reboot -devi= ce ib700"); + QTestState *s; + + s =3D qtest_init("-watchdog-action reset -no-reboot -device ib700"); qtest_irq_intercept_in(s, "ioapic"); d =3D ib700_program_and_wait(s); g_assert(!strcmp(qdict_get_str(d, "action"), "reset")); QDECREF(d); - qmp_eventwait("SHUTDOWN"); - qtest_end(); + qtest_qmp_eventwait(s, "SHUTDOWN"); + qtest_quit(s); } =20 static void ib700_none(void) { QDict *d; - QTestState *s =3D qtest_start("-watchdog-action none -device ib700"); + QTestState *s =3D qtest_init("-watchdog-action none -device ib700"); + qtest_irq_intercept_in(s, "ioapic"); d =3D ib700_program_and_wait(s); g_assert(!strcmp(qdict_get_str(d, "action"), "none")); QDECREF(d); - qtest_end(); + qtest_quit(s); } =20 int main(int argc, char **argv) --=20 1.8.3.1 From nobody Sat Apr 27 17:22:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518121419659590.3209741061378; Thu, 8 Feb 2018 12:23:39 -0800 (PST) Received: from localhost ([::1]:44666 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejsjK-0005qT-Ko for importer@patchew.org; Thu, 08 Feb 2018 15:23:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45505) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejsWF-0002ZP-Qr for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:10:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ejsWA-0002Pk-6V for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:10:07 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53836 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ejsWA-0002PU-2K for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:10:02 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8B8C64040073 for ; Thu, 8 Feb 2018 20:10:01 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-204-120.brq.redhat.com [10.40.204.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id A9176B07B8; Thu, 8 Feb 2018 20:10:00 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Thu, 8 Feb 2018 21:09:40 +0100 Message-Id: <1518120582-26647-13-git-send-email-thuth@redhat.com> In-Reply-To: <1518120582-26647-1-git-send-email-thuth@redhat.com> References: <1518120582-26647-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 08 Feb 2018 20:10:01 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 08 Feb 2018 20:10:01 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 12/14] tests/boot-serial: Enable the boot-serial test on SPARC machines, too X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" OpenBIOS prints out the name of the detected CPU here, so looking for this string is a nice test to verify that the CPU detection is still working correctly. Acked-by: Mark Cave-Ayland Signed-off-by: Thomas Huth Reviewed-by: Eric Blake --- tests/Makefile.include | 2 ++ tests/boot-serial-test.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/tests/Makefile.include b/tests/Makefile.include index 83def69..6609276 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -352,11 +352,13 @@ check-qtest-sh4eb-y =3D tests/endianness-test$(EXESUF) check-qtest-sparc-y =3D tests/prom-env-test$(EXESUF) #check-qtest-sparc-y +=3D tests/m48t59-test$(EXESUF) #gcov-files-sparc-y =3D hw/timer/m48t59.c +check-qtest-sparc-y +=3D tests/boot-serial-test$(EXESUF) =20 check-qtest-sparc64-y =3D tests/endianness-test$(EXESUF) #check-qtest-sparc64-y +=3D tests/m48t59-test$(EXESUF) #gcov-files-sparc64-y +=3D hw/timer/m48t59.c check-qtest-sparc64-y +=3D tests/prom-env-test$(EXESUF) +check-qtest-sparc64-y +=3D tests/boot-serial-test$(EXESUF) =20 check-qtest-arm-y =3D tests/tmp105-test$(EXESUF) check-qtest-arm-y +=3D tests/ds1338-test$(EXESUF) diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c index ea87a80..996d3d7 100644 --- a/tests/boot-serial-test.c +++ b/tests/boot-serial-test.c @@ -78,6 +78,10 @@ static testdef_t tests[] =3D { { "i386", "q35", "-device sga", "SGABIOS" }, { "x86_64", "isapc", "-cpu qemu32 -device sga", "SGABIOS" }, { "x86_64", "q35", "-device sga", "SGABIOS" }, + { "sparc", "LX", "", "TMS390S10" }, + { "sparc", "SS-4", "", "MB86904" }, + { "sparc", "SS-600MP", "", "TMS390Z55" }, + { "sparc64", "sun4u", "", "UltraSPARC" }, { "s390x", "s390-ccw-virtio", "-nodefaults -device sclpconsole,chardev=3Dserial0", "virtio device"= }, { "m68k", "mcf5208evb", "", "TT", sizeof(kernel_mcf5208), kernel_mcf52= 08 }, --=20 1.8.3.1 From nobody Sat Apr 27 17:22:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518122498167271.4669866088027; Thu, 8 Feb 2018 12:41:38 -0800 (PST) Received: from localhost ([::1]:46539 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejt0e-0005sq-7R for importer@patchew.org; Thu, 08 Feb 2018 15:41:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45474) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejsWD-0002Wt-Ha for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:10:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ejsWB-0002QQ-8l for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:10:05 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:43666 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ejsWB-0002Q8-3i for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:10:03 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C256740FB635 for ; Thu, 8 Feb 2018 20:10:02 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-204-120.brq.redhat.com [10.40.204.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id E8A59B07B8; Thu, 8 Feb 2018 20:10:01 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Thu, 8 Feb 2018 21:09:41 +0100 Message-Id: <1518120582-26647-14-git-send-email-thuth@redhat.com> In-Reply-To: <1518120582-26647-1-git-send-email-thuth@redhat.com> References: <1518120582-26647-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 08 Feb 2018 20:10:02 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 08 Feb 2018 20:10:02 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 13/14] tests/boot-serial: Add tests for PowerPC Mac machines X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" OpenBIOS prints out the CPU type on these machine types, so we can use this string to test whether the CPU detection is working correctly. Acked-by: Mark Cave-Ayland Signed-off-by: Thomas Huth Reviewed-by: Eric Blake --- tests/boot-serial-test.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c index 996d3d7..72873ee 100644 --- a/tests/boot-serial-test.c +++ b/tests/boot-serial-test.c @@ -69,8 +69,11 @@ static testdef_t tests[] =3D { { "alpha", "clipper", "", "PCI:" }, { "ppc", "ppce500", "", "U-Boot" }, { "ppc", "prep", "", "Open Hack'Ware BIOS" }, + { "ppc", "g3beige", "", "PowerPC,750" }, + { "ppc", "mac99", "", "PowerPC,G4" }, { "ppc64", "ppce500", "", "U-Boot" }, { "ppc64", "prep", "", "Open Hack'Ware BIOS" }, + { "ppc64", "mac99", "", "PowerPC,970FX" }, { "ppc64", "pseries", "", "Open Firmware" }, { "ppc64", "powernv", "-cpu POWER8", "OPAL" }, { "i386", "isapc", "-cpu qemu32 -device sga", "SGABIOS" }, --=20 1.8.3.1 From nobody Sat Apr 27 17:22:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518122701317419.7400381426878; Thu, 8 Feb 2018 12:45:01 -0800 (PST) Received: from localhost ([::1]:47191 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejt3w-0000md-N2 for importer@patchew.org; Thu, 08 Feb 2018 15:44:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45476) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejsWD-0002Wx-Id for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:10:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ejsWC-0002Qu-Gg for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:10:05 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50442 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ejsWC-0002Qi-Bs for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:10:04 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 06EF64026776 for ; Thu, 8 Feb 2018 20:10:04 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-204-120.brq.redhat.com [10.40.204.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2C64AB3016; Thu, 8 Feb 2018 20:10:02 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Thu, 8 Feb 2018 21:09:42 +0100 Message-Id: <1518120582-26647-15-git-send-email-thuth@redhat.com> In-Reply-To: <1518120582-26647-1-git-send-email-thuth@redhat.com> References: <1518120582-26647-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 08 Feb 2018 20:10:04 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 08 Feb 2018 20:10:04 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 14/14] tests/boot-serial-test: Add support for the aarch64 virt machine X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Wei Huang This patch adds a small binary kernel to test aarch64 virt machine's UART. Signed-off-by: Wei Huang [thuth: Fixed contextual conflict with the hppa patch] Signed-off-by: Thomas Huth Reviewed-by: Eric Blake --- tests/Makefile.include | 1 + tests/boot-serial-test.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/tests/Makefile.include b/tests/Makefile.include index 6609276..cc7e7dc 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -371,6 +371,7 @@ gcov-files-arm-y +=3D hw/timer/arm_mptimer.c check-qtest-arm-y +=3D tests/boot-serial-test$(EXESUF) =20 check-qtest-aarch64-y =3D tests/numa-test$(EXESUF) +check-qtest-aarch64-y +=3D tests/boot-serial-test$(EXESUF) =20 check-qtest-microblazeel-y =3D $(check-qtest-microblaze-y) =20 diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c index 72873ee..511bf31 100644 --- a/tests/boot-serial-test.c +++ b/tests/boot-serial-test.c @@ -55,6 +55,13 @@ static const uint8_t bios_raspi2[] =3D { 0x00, 0x10, 0x20, 0x3f, /* 0x3f201000 =3D UART0 base a= ddr */ }; =20 +static const uint8_t kernel_aarch64[] =3D { + 0x81, 0x0a, 0x80, 0x52, /* mov w1, #0x54 */ + 0x02, 0x20, 0xa1, 0xd2, /* mov x2, #0x9000000 */ + 0x41, 0x00, 0x00, 0x39, /* strb w1, [x2] */ + 0xfd, 0xff, 0xff, 0x17, /* b -12 (loop) */ +}; + typedef struct testdef { const char *arch; /* Target architecture */ const char *machine; /* Name of the machine */ @@ -95,6 +102,8 @@ static testdef_t tests[] =3D { { "moxie", "moxiesim", "", "TT", sizeof(bios_moxiesim), 0, bios_moxies= im }, { "arm", "raspi2", "", "TT", sizeof(bios_raspi2), 0, bios_raspi2 }, { "hppa", "hppa", "", "SeaBIOS wants SYSTEM HALT" }, + { "aarch64", "virt", "-cpu cortex-a57", "TT", sizeof(kernel_aarch64), + kernel_aarch64 }, =20 { NULL } }; --=20 1.8.3.1