From nobody Mon May 6 19:53:33 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 1542050124114352.2071440240277; Mon, 12 Nov 2018 11:15:24 -0800 (PST) Received: from localhost ([::1]:50365 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMHgA-0001OA-Eu for importer@patchew.org; Mon, 12 Nov 2018 14:15:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48751) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMHZq-0005Jb-HX for qemu-devel@nongnu.org; Mon, 12 Nov 2018 14:08:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gMHZn-000493-O4 for qemu-devel@nongnu.org; Mon, 12 Nov 2018 14:08:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53346) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gMHZn-0003wI-DA for qemu-devel@nongnu.org; Mon, 12 Nov 2018 14:08:47 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9BC123082A22; Mon, 12 Nov 2018 19:08:18 +0000 (UTC) Received: from thuth.com (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1AB1F60C67; Mon, 12 Nov 2018 19:08:16 +0000 (UTC) From: Thomas Huth To: Eric Blake , qemu-devel@nongnu.org Date: Mon, 12 Nov 2018 20:08:04 +0100 Message-Id: <1542049690-12826-2-git-send-email-thuth@redhat.com> In-Reply-To: <1542049690-12826-1-git-send-email-thuth@redhat.com> References: <1542049690-12826-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 12 Nov 2018 19:08:18 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-3.2 1/7] tests/pvpanic: Make the pvpanic test independent of 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: , Cc: Laurent Vivier , Igor Mammedov , John Snow , Ben Warren , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We want to get rid of global_qtest in the long run, thus do not use the wrappers like inb() and outb() here anymore. Signed-off-by: Thomas Huth Reviewed-by: Eric Blake --- tests/pvpanic-test.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/pvpanic-test.c b/tests/pvpanic-test.c index 7461a72..ff9176a 100644 --- a/tests/pvpanic-test.c +++ b/tests/pvpanic-test.c @@ -15,13 +15,16 @@ static void test_panic(void) { uint8_t val; QDict *response, *data; + QTestState *qts; =20 - val =3D inb(0x505); + qts =3D qtest_init("-device pvpanic"); + + val =3D qtest_inb(qts, 0x505); g_assert_cmpuint(val, =3D=3D, 1); =20 - outb(0x505, 0x1); + qtest_outb(qts, 0x505, 0x1); =20 - response =3D qmp_receive(); + response =3D qtest_qmp_receive(qts); g_assert(qdict_haskey(response, "event")); g_assert_cmpstr(qdict_get_str(response, "event"), =3D=3D, "GUEST_PANIC= KED"); g_assert(qdict_haskey(response, "data")); @@ -29,6 +32,8 @@ static void test_panic(void) g_assert(qdict_haskey(data, "action")); g_assert_cmpstr(qdict_get_str(data, "action"), =3D=3D, "pause"); qobject_unref(response); + + qtest_quit(qts); } =20 int main(int argc, char **argv) @@ -38,10 +43,7 @@ int main(int argc, char **argv) g_test_init(&argc, &argv, NULL); qtest_add_func("/pvpanic/panic", test_panic); =20 - qtest_start("-device pvpanic"); ret =3D g_test_run(); =20 - qtest_end(); - return ret; } --=20 1.8.3.1 From nobody Mon May 6 19:53:33 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 1542050218810883.5057043651443; Mon, 12 Nov 2018 11:16:58 -0800 (PST) Received: from localhost ([::1]:50371 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMHhb-00024M-A2 for importer@patchew.org; Mon, 12 Nov 2018 14:16:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48750) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMHZq-0005Ja-HV for qemu-devel@nongnu.org; Mon, 12 Nov 2018 14:08:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gMHZn-00048x-LO for qemu-devel@nongnu.org; Mon, 12 Nov 2018 14:08:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60082) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gMHZn-0003wq-6x for qemu-devel@nongnu.org; Mon, 12 Nov 2018 14:08:47 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 72DAD4E915; Mon, 12 Nov 2018 19:08:20 +0000 (UTC) Received: from thuth.com (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2B7260C67; Mon, 12 Nov 2018 19:08:18 +0000 (UTC) From: Thomas Huth To: Eric Blake , qemu-devel@nongnu.org Date: Mon, 12 Nov 2018 20:08:05 +0100 Message-Id: <1542049690-12826-3-git-send-email-thuth@redhat.com> In-Reply-To: <1542049690-12826-1-git-send-email-thuth@redhat.com> References: <1542049690-12826-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 12 Nov 2018 19:08:20 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-3.2 2/7] tests/libqos/pci: Make PCI access functions independent of 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: , Cc: Laurent Vivier , Igor Mammedov , John Snow , Ben Warren , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" QPCIBus already tracks QTestState, so use that state instead of an implicit reliance on global_qtest. Based on an earlier patch ("libqos: Use explicit QTestState for pci operations") from Eric Blake. Signed-off-by: Thomas Huth --- tests/libqos/pci-pc.c | 47 ++++++++++++++++++++++++--------------------= --- tests/libqos/pci-spapr.c | 20 ++++++++++---------- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/tests/libqos/pci-pc.c b/tests/libqos/pci-pc.c index 585f528..a4fc02b 100644 --- a/tests/libqos/pci-pc.c +++ b/tests/libqos/pci-pc.c @@ -29,90 +29,91 @@ typedef struct QPCIBusPC =20 static uint8_t qpci_pc_pio_readb(QPCIBus *bus, uint32_t addr) { - return inb(addr); + return qtest_inb(bus->qts, addr); } =20 static void qpci_pc_pio_writeb(QPCIBus *bus, uint32_t addr, uint8_t val) { - outb(addr, val); + qtest_outb(bus->qts, addr, val); } =20 static uint16_t qpci_pc_pio_readw(QPCIBus *bus, uint32_t addr) { - return inw(addr); + return qtest_inw(bus->qts, addr); } =20 static void qpci_pc_pio_writew(QPCIBus *bus, uint32_t addr, uint16_t val) { - outw(addr, val); + qtest_outw(bus->qts, addr, val); } =20 static uint32_t qpci_pc_pio_readl(QPCIBus *bus, uint32_t addr) { - return inl(addr); + return qtest_inl(bus->qts, addr); } =20 static void qpci_pc_pio_writel(QPCIBus *bus, uint32_t addr, uint32_t val) { - outl(addr, val); + qtest_outl(bus->qts, addr, val); } =20 static uint64_t qpci_pc_pio_readq(QPCIBus *bus, uint32_t addr) { - return (uint64_t)inl(addr) + ((uint64_t)inl(addr + 4) << 32); + return (uint64_t)qtest_inl(bus->qts, addr) + + ((uint64_t)qtest_inl(bus->qts, addr + 4) << 32); } =20 static void qpci_pc_pio_writeq(QPCIBus *bus, uint32_t addr, uint64_t val) { - outl(addr, val & 0xffffffff); - outl(addr + 4, val >> 32); + qtest_outl(bus->qts, addr, val & 0xffffffff); + qtest_outl(bus->qts, addr + 4, val >> 32); } =20 static void qpci_pc_memread(QPCIBus *bus, uint32_t addr, void *buf, size_t= len) { - memread(addr, buf, len); + qtest_memread(bus->qts, addr, buf, len); } =20 static void qpci_pc_memwrite(QPCIBus *bus, uint32_t addr, const void *buf, size_t len) { - memwrite(addr, buf, len); + qtest_memwrite(bus->qts, addr, buf, len); } =20 static uint8_t qpci_pc_config_readb(QPCIBus *bus, int devfn, uint8_t offse= t) { - outl(0xcf8, (1U << 31) | (devfn << 8) | offset); - return inb(0xcfc); + qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset); + return qtest_inb(bus->qts, 0xcfc); } =20 static uint16_t qpci_pc_config_readw(QPCIBus *bus, int devfn, uint8_t offs= et) { - outl(0xcf8, (1U << 31) | (devfn << 8) | offset); - return inw(0xcfc); + qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset); + return qtest_inw(bus->qts, 0xcfc); } =20 static uint32_t qpci_pc_config_readl(QPCIBus *bus, int devfn, uint8_t offs= et) { - outl(0xcf8, (1U << 31) | (devfn << 8) | offset); - return inl(0xcfc); + qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset); + return qtest_inl(bus->qts, 0xcfc); } =20 static void qpci_pc_config_writeb(QPCIBus *bus, int devfn, uint8_t offset,= uint8_t value) { - outl(0xcf8, (1U << 31) | (devfn << 8) | offset); - outb(0xcfc, value); + qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset); + qtest_outb(bus->qts, 0xcfc, value); } =20 static void qpci_pc_config_writew(QPCIBus *bus, int devfn, uint8_t offset,= uint16_t value) { - outl(0xcf8, (1U << 31) | (devfn << 8) | offset); - outw(0xcfc, value); + qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset); + qtest_outw(bus->qts, 0xcfc, value); } =20 static void qpci_pc_config_writel(QPCIBus *bus, int devfn, uint8_t offset,= uint32_t value) { - outl(0xcf8, (1U << 31) | (devfn << 8) | offset); - outl(0xcfc, value); + qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset); + qtest_outl(bus->qts, 0xcfc, value); } =20 QPCIBus *qpci_init_pc(QTestState *qts, QGuestAllocator *alloc) diff --git a/tests/libqos/pci-spapr.c b/tests/libqos/pci-spapr.c index c0f7e6d..4c29889 100644 --- a/tests/libqos/pci-spapr.c +++ b/tests/libqos/pci-spapr.c @@ -45,63 +45,63 @@ typedef struct QPCIBusSPAPR { static uint8_t qpci_spapr_pio_readb(QPCIBus *bus, uint32_t addr) { QPCIBusSPAPR *s =3D container_of(bus, QPCIBusSPAPR, bus); - return readb(s->pio_cpu_base + addr); + return qtest_readb(bus->qts, s->pio_cpu_base + addr); } =20 static void qpci_spapr_pio_writeb(QPCIBus *bus, uint32_t addr, uint8_t val) { QPCIBusSPAPR *s =3D container_of(bus, QPCIBusSPAPR, bus); - writeb(s->pio_cpu_base + addr, val); + qtest_writeb(bus->qts, s->pio_cpu_base + addr, val); } =20 static uint16_t qpci_spapr_pio_readw(QPCIBus *bus, uint32_t addr) { QPCIBusSPAPR *s =3D container_of(bus, QPCIBusSPAPR, bus); - return bswap16(readw(s->pio_cpu_base + addr)); + return bswap16(qtest_readw(bus->qts, s->pio_cpu_base + addr)); } =20 static void qpci_spapr_pio_writew(QPCIBus *bus, uint32_t addr, uint16_t va= l) { QPCIBusSPAPR *s =3D container_of(bus, QPCIBusSPAPR, bus); - writew(s->pio_cpu_base + addr, bswap16(val)); + qtest_writew(bus->qts, s->pio_cpu_base + addr, bswap16(val)); } =20 static uint32_t qpci_spapr_pio_readl(QPCIBus *bus, uint32_t addr) { QPCIBusSPAPR *s =3D container_of(bus, QPCIBusSPAPR, bus); - return bswap32(readl(s->pio_cpu_base + addr)); + return bswap32(qtest_readl(bus->qts, s->pio_cpu_base + addr)); } =20 static void qpci_spapr_pio_writel(QPCIBus *bus, uint32_t addr, uint32_t va= l) { QPCIBusSPAPR *s =3D container_of(bus, QPCIBusSPAPR, bus); - writel(s->pio_cpu_base + addr, bswap32(val)); + qtest_writel(bus->qts, s->pio_cpu_base + addr, bswap32(val)); } =20 static uint64_t qpci_spapr_pio_readq(QPCIBus *bus, uint32_t addr) { QPCIBusSPAPR *s =3D container_of(bus, QPCIBusSPAPR, bus); - return bswap64(readq(s->pio_cpu_base + addr)); + return bswap64(qtest_readq(bus->qts, s->pio_cpu_base + addr)); } =20 static void qpci_spapr_pio_writeq(QPCIBus *bus, uint32_t addr, uint64_t va= l) { QPCIBusSPAPR *s =3D container_of(bus, QPCIBusSPAPR, bus); - writeq(s->pio_cpu_base + addr, bswap64(val)); + qtest_writeq(bus->qts, s->pio_cpu_base + addr, bswap64(val)); } =20 static void qpci_spapr_memread(QPCIBus *bus, uint32_t addr, void *buf, size_t len) { QPCIBusSPAPR *s =3D container_of(bus, QPCIBusSPAPR, bus); - memread(s->mmio32_cpu_base + addr, buf, len); + qtest_memread(bus->qts, s->mmio32_cpu_base + addr, buf, len); } =20 static void qpci_spapr_memwrite(QPCIBus *bus, uint32_t addr, const void *buf, size_t len) { QPCIBusSPAPR *s =3D container_of(bus, QPCIBusSPAPR, bus); - memwrite(s->mmio32_cpu_base + addr, buf, len); + qtest_memwrite(bus->qts, s->mmio32_cpu_base + addr, buf, len); } =20 static uint8_t qpci_spapr_config_readb(QPCIBus *bus, int devfn, uint8_t of= fset) --=20 1.8.3.1 From nobody Mon May 6 19:53:33 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 1542049962391421.34125339877744; Mon, 12 Nov 2018 11:12:42 -0800 (PST) Received: from localhost ([::1]:50350 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMHdZ-00082N-1D for importer@patchew.org; Mon, 12 Nov 2018 14:12:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48647) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMHZj-0005FD-1V for qemu-devel@nongnu.org; Mon, 12 Nov 2018 14:08:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gMHZd-00044t-BU for qemu-devel@nongnu.org; Mon, 12 Nov 2018 14:08:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41732) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gMHZT-0003xL-E4 for qemu-devel@nongnu.org; Mon, 12 Nov 2018 14:08:31 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 541523084218; Mon, 12 Nov 2018 19:08:22 +0000 (UTC) Received: from thuth.com (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB88C60C6B; Mon, 12 Nov 2018 19:08:20 +0000 (UTC) From: Thomas Huth To: Eric Blake , qemu-devel@nongnu.org Date: Mon, 12 Nov 2018 20:08:06 +0100 Message-Id: <1542049690-12826-4-git-send-email-thuth@redhat.com> In-Reply-To: <1542049690-12826-1-git-send-email-thuth@redhat.com> References: <1542049690-12826-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 12 Nov 2018 19:08:22 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-3.2 3/7] ahci-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: , Cc: Laurent Vivier , Igor Mammedov , John Snow , Ben Warren , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake Managing parallel connections to two different monitors via the implicit global_qtest makes it hard to copy-and-paste code to tests that are not aware of the implicit state; the management of global_qtest is even harder to follow because it was masked behind set_context(). Instead, explicitly pass QTestState* around (generally, by reusing the member already present in ahci->parent QOSState), and call explicit qtest_* functions on all places that interact with a monitor. We can assert that the conversion is correct by checking that global_qtest remains NULL throughout the test (a later patch that changes global_qtest to not be a public global variable will drop the assertions). Bonus: there was one spots that was creating a needless temporary variable to execute the 'cont' command, rather than just directly passing the literal command through qtest_qmp(). Fixing that gets us one step closer to enabling -Wformat checking on constructed JSON. Signed-off-by: Eric Blake [thuth: rebased patch to current master branch] Signed-off-by: Thomas Huth Acked-by: John Snow --- tests/ahci-test.c | 81 +++++++++++++++++++++++++----------------------= ---- tests/libqos/libqos.c | 9 ------ tests/libqos/libqos.h | 1 - 3 files changed, 39 insertions(+), 52 deletions(-) diff --git a/tests/ahci-test.c b/tests/ahci-test.c index 5dd380e..c73149a 100644 --- a/tests/ahci-test.c +++ b/tests/ahci-test.c @@ -38,7 +38,7 @@ #include "hw/pci/pci_regs.h" =20 /* TODO actually test the results and get rid of this */ -#define qmp_discard_response(...) qobject_unref(qmp(__VA_ARGS__)) +#define qmp_discard_response(s, ...) qobject_unref(qtest_qmp(s, __VA_ARGS_= _)) =20 /* Test images sizes in MB */ #define TEST_IMAGE_SIZE_MB_LARGE (200 * 1024) @@ -161,7 +161,6 @@ 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. */ @@ -201,7 +200,7 @@ static void ahci_shutdown(AHCIQState *ahci) { QOSState *qs =3D ahci->parent; =20 - set_context(qs); + assert(!global_qtest); ahci_clean_mem(ahci); free_ahci_device(ahci->dev); g_free(ahci); @@ -874,15 +873,15 @@ static void ahci_test_io_rw_simple(AHCIQState *ahci, = unsigned bufsize, =20 /* Write some indicative pattern to our buffer. */ generate_pattern(tx, bufsize, AHCI_SECTOR_SIZE); - bufwrite(ptr, tx, bufsize); + qtest_bufwrite(ahci->parent->qts, ptr, tx, bufsize); =20 /* Write this buffer to disk, then read it back to the DMA buffer. */ ahci_guest_io(ahci, port, write_cmd, ptr, bufsize, sector); - qmemset(ptr, 0x00, bufsize); + qtest_memset(ahci->parent->qts, ptr, 0x00, bufsize); ahci_guest_io(ahci, port, read_cmd, ptr, bufsize, sector); =20 /*** Read back the Data ***/ - bufread(ptr, rx, bufsize); + qtest_bufread(ahci->parent->qts, ptr, rx, bufsize); g_assert_cmphex(memcmp(tx, rx, bufsize), =3D=3D, 0); =20 ahci_free(ahci, ptr); @@ -923,7 +922,7 @@ static void ahci_test_max(AHCIQState *ahci) } =20 port =3D ahci_test_nondata(ahci, cmd); - memread(ahci->port[port].fb + 0x40, d2h, 0x20); + qtest_memread(ahci->parent->qts, ahci->port[port].fb + 0x40, d2h, 0x20= ); nsect =3D (uint64_t)d2h->lba_hi[2] << 40 | (uint64_t)d2h->lba_hi[1] << 32 | (uint64_t)d2h->lba_hi[0] << 24 | @@ -1041,7 +1040,7 @@ static void test_dma_fragmented(void) /* Create a DMA buffer in guest memory, and write our pattern to it. */ ptr =3D guest_alloc(ahci->parent->alloc, bufsize); g_assert(ptr); - bufwrite(ptr, tx, bufsize); + qtest_bufwrite(ahci->parent->qts, ptr, tx, bufsize); =20 cmd =3D ahci_command_create(CMD_WRITE_DMA); ahci_command_adjust(cmd, 0, ptr, bufsize, 32); @@ -1058,7 +1057,7 @@ static void test_dma_fragmented(void) ahci_command_free(cmd); =20 /* Read back the guest's receive buffer into local memory */ - bufread(ptr, rx, bufsize); + qtest_bufread(ahci->parent->qts, ptr, rx, bufsize); guest_free(ahci->parent->alloc, ptr); =20 g_assert_cmphex(memcmp(tx, rx, bufsize), =3D=3D, 0); @@ -1169,8 +1168,6 @@ static void ahci_migrate_simple(uint8_t cmd_read, uin= t8_t cmd_write) "-drive if=3Dide,format=3D%s,file=3D%s " "-incoming %s", imgfmt, tmp_path, uri); =20 - set_context(src->parent); - /* initialize */ px =3D ahci_port_select(src); ahci_port_clear(src, px); @@ -1238,7 +1235,7 @@ static void ahci_halted_io_test(uint8_t cmd_read, uin= t8_t cmd_write) generate_pattern(tx, bufsize, AHCI_SECTOR_SIZE); ptr =3D ahci_alloc(ahci, bufsize); g_assert(ptr); - memwrite(ptr, tx, bufsize); + qtest_memwrite(ahci->parent->qts, ptr, tx, bufsize); =20 /* Attempt to write (and fail) */ cmd =3D ahci_guest_io_halt(ahci, port, cmd_write, @@ -1304,8 +1301,6 @@ static void ahci_migrate_halted_io(uint8_t cmd_read, = uint8_t cmd_write) "-incoming %s", tmp_path, imgfmt, uri); =20 - set_context(src->parent); - /* Initialize and prepare */ port =3D ahci_port_select(src); ahci_port_clear(src, port); @@ -1314,7 +1309,7 @@ static void ahci_migrate_halted_io(uint8_t cmd_read, = uint8_t cmd_write) /* create DMA source buffer and write pattern */ ptr =3D ahci_alloc(src, bufsize); g_assert(ptr); - memwrite(ptr, tx, bufsize); + qtest_memwrite(src->parent->qts, ptr, tx, bufsize); =20 /* Write, trigger the VM to stop, migrate, then resume. */ cmd =3D ahci_guest_io_halt(src, port, cmd_write, @@ -1372,8 +1367,6 @@ static void test_flush_migrate(void) "-device ide-hd,drive=3Ddrive0 " "-incoming %s", tmp_path, imgfmt, uri); =20 - set_context(src->parent); - px =3D ahci_port_select(src); ahci_port_clear(src, px); =20 @@ -1384,14 +1377,14 @@ static void test_flush_migrate(void) cmd =3D ahci_command_create(CMD_FLUSH_CACHE); ahci_command_commit(src, cmd, px); ahci_command_issue_async(src, cmd); - qmp_eventwait("STOP"); + qtest_qmp_eventwait(src->parent->qts, "STOP"); =20 /* Migrate over */ ahci_migrate(src, dst, uri); =20 /* Complete the command */ - qmp_send("{'execute':'cont' }"); - qmp_eventwait("RESUME"); + qtest_qmp_send(dst->parent->qts, "{'execute':'cont' }"); + qtest_qmp_eventwait(dst->parent->qts, "RESUME"); ahci_command_wait(dst, cmd); ahci_command_verify(dst, cmd); =20 @@ -1483,7 +1476,7 @@ static int ahci_cb_cmp_buff(AHCIQState *ahci, AHCICom= mand *cmd, } =20 rx =3D g_malloc0(opts->size); - bufread(opts->buffer, rx, opts->size); + qtest_bufread(ahci->parent->qts, opts->buffer, rx, opts->size); g_assert_cmphex(memcmp(tx, rx, opts->size), =3D=3D, 0); g_free(rx); =20 @@ -1558,9 +1551,10 @@ static void test_atapi_bcl(void) } =20 =20 -static void atapi_wait_tray(bool open) +static void atapi_wait_tray(AHCIQState *ahci, bool open) { - QDict *rsp =3D qmp_eventwait_ref("DEVICE_TRAY_MOVED"); + QDict *rsp =3D qtest_qmp_eventwait_ref(ahci->parent->qts, + "DEVICE_TRAY_MOVED"); QDict *data =3D qdict_get_qdict(rsp, "data"); if (open) { g_assert(qdict_get_bool(data, "tray-open")); @@ -1587,43 +1581,46 @@ static void test_atapi_tray(void) port =3D ahci_port_select(ahci); =20 ahci_atapi_eject(ahci, port); - atapi_wait_tray(true); + atapi_wait_tray(ahci, true); =20 ahci_atapi_load(ahci, port); - atapi_wait_tray(false); + atapi_wait_tray(ahci, false); =20 /* Remove media */ - qmp_send("{'execute': 'blockdev-open-tray'," - " 'arguments': {'id': 'cd0'}}"); - atapi_wait_tray(true); - rsp =3D qmp_receive(); + qtest_qmp_send(ahci->parent->qts, "{'execute': 'blockdev-open-tray', " + "'arguments': {'id': 'cd0'}}"); + atapi_wait_tray(ahci, true); + rsp =3D qtest_qmp_receive(ahci->parent->qts); qobject_unref(rsp); =20 - qmp_discard_response("{'execute': 'blockdev-remove-medium', " + qmp_discard_response(ahci->parent->qts, + "{'execute': 'blockdev-remove-medium', " "'arguments': {'id': 'cd0'}}"); =20 /* Test the tray without a medium */ ahci_atapi_load(ahci, port); - atapi_wait_tray(false); + atapi_wait_tray(ahci, false); =20 ahci_atapi_eject(ahci, port); - atapi_wait_tray(true); + atapi_wait_tray(ahci, true); =20 /* Re-insert media */ - qmp_discard_response("{'execute': 'blockdev-add', " - "'arguments': {'node-name': 'node0', " + qmp_discard_response(ahci->parent->qts, + "{'execute': 'blockdev-add', " + "'arguments': {'node-name': 'node0', " "'driver': 'raw', " "'file': { 'driver': 'file', " "'filename': %s }}}", is= o); - qmp_discard_response("{'execute': 'blockdev-insert-medium'," - "'arguments': { 'id': 'cd0', " + qmp_discard_response(ahci->parent->qts, + "{'execute': 'blockdev-insert-medium'," + "'arguments': { 'id': 'cd0', " "'node-name': 'node0' }}"); =20 /* Again, the event shows up first */ - qmp_send("{'execute': 'blockdev-close-tray'," - " 'arguments': {'id': 'cd0'}}"); - atapi_wait_tray(false); - rsp =3D qmp_receive(); + qtest_qmp_send(ahci->parent->qts, "{'execute': 'blockdev-close-tray', " + "'arguments': {'id': 'cd0'}}"); + atapi_wait_tray(ahci, false); + rsp =3D qtest_qmp_receive(ahci->parent->qts); qobject_unref(rsp); =20 /* Now, to convince ATAPI we understand the media has changed... */ @@ -1643,10 +1640,10 @@ static void test_atapi_tray(void) =20 /* Final tray test. */ ahci_atapi_eject(ahci, port); - atapi_wait_tray(true); + atapi_wait_tray(ahci, true); =20 ahci_atapi_load(ahci, port); - atapi_wait_tray(false); + atapi_wait_tray(ahci, false); =20 /* Cleanup */ g_free(tx); diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c index c514187..e54fd2d 100644 --- a/tests/libqos/libqos.c +++ b/tests/libqos/libqos.c @@ -76,11 +76,6 @@ void qtest_shutdown(QOSState *qs) } } =20 -void set_context(QOSState *s) -{ - global_qtest =3D s->qts; -} - static QDict *qmp_execute(QTestState *qts, const char *command) { return qtest_qmp(qts, "{ 'execute': %s }", command); @@ -92,8 +87,6 @@ void migrate(QOSState *from, QOSState *to, const char *ur= i) QDict *rsp, *sub; bool running; =20 - set_context(from); - /* Is the machine currently running? */ rsp =3D qmp_execute(from->qts, "query-status"); g_assert(qdict_haskey(rsp, "return")); @@ -117,7 +110,6 @@ void migrate(QOSState *from, QOSState *to, const char *= uri) /* If we were running, we can wait for an event. */ if (running) { migrate_allocator(from->alloc, to->alloc); - set_context(to); qtest_qmp_eventwait(to->qts, "RESUME"); return; } @@ -147,7 +139,6 @@ void migrate(QOSState *from, QOSState *to, const char *= uri) } =20 migrate_allocator(from->alloc, to->alloc); - set_context(to); } =20 bool have_qemu_img(void) diff --git a/tests/libqos/libqos.h b/tests/libqos/libqos.h index 07d4b93..9e020ef 100644 --- a/tests/libqos/libqos.h +++ b/tests/libqos/libqos.h @@ -29,7 +29,6 @@ void qtest_shutdown(QOSState *qs); bool have_qemu_img(void); void mkimg(const char *file, const char *fmt, unsigned size_mb); void mkqcow2(const char *file, unsigned size_mb); -void set_context(QOSState *s); void migrate(QOSState *from, QOSState *to, const char *uri); void prepare_blkdebug_script(const char *debug_fn, const char *event); void generate_pattern(void *buffer, size_t len, size_t cycle_len); --=20 1.8.3.1 From nobody Mon May 6 19:53:33 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 1542049856911176.06581559152653; Mon, 12 Nov 2018 11:10:56 -0800 (PST) Received: from localhost ([::1]:50341 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMHbr-0006Zy-KI for importer@patchew.org; Mon, 12 Nov 2018 14:10:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48760) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMHZq-0005Ji-KL for qemu-devel@nongnu.org; Mon, 12 Nov 2018 14:08:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gMHZo-00049L-73 for qemu-devel@nongnu.org; Mon, 12 Nov 2018 14:08:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36444) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gMHZn-0003yL-Sk for qemu-devel@nongnu.org; Mon, 12 Nov 2018 14:08:48 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 28E153082DDA; Mon, 12 Nov 2018 19:08:24 +0000 (UTC) Received: from thuth.com (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9296560C67; Mon, 12 Nov 2018 19:08:22 +0000 (UTC) From: Thomas Huth To: Eric Blake , qemu-devel@nongnu.org Date: Mon, 12 Nov 2018 20:08:07 +0100 Message-Id: <1542049690-12826-5-git-send-email-thuth@redhat.com> In-Reply-To: <1542049690-12826-1-git-send-email-thuth@redhat.com> References: <1542049690-12826-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Mon, 12 Nov 2018 19:08:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-3.2 4/7] ivshmem-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: , Cc: Laurent Vivier , Igor Mammedov , John Snow , Ben Warren , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake Managing parallel connections to two different monitors via the implicit global_qtest makes it hard to copy-and-paste code to tests that are not aware of the implicit state. Since we have already fixed qpci to avoid global_qtest, we can now simplify by not using global_qtest anywhere in ivshmem-test. We can assert that the conversion is correct by checking that global_qtest remains NULL throughout the test (a later patch that changes global_qtest to not be a public global variable will drop the assertions). Signed-off-by: Eric Blake [thuth: Dropped the changes to test_ivshmem_hotplug() - will be fixed later] Signed-off-by: Thomas Huth --- tests/ivshmem-test.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/tests/ivshmem-test.c b/tests/ivshmem-test.c index c37b196..089e268 100644 --- a/tests/ivshmem-test.c +++ b/tests/ivshmem-test.c @@ -71,13 +71,10 @@ static const char* reg2str(enum Reg reg) { static inline unsigned in_reg(IVState *s, enum Reg reg) { const char *name =3D reg2str(reg); - QTestState *qtest =3D global_qtest; unsigned res; =20 - global_qtest =3D s->qs->qts; res =3D qpci_io_readl(s->dev, s->reg_bar, reg); g_test_message("*%s -> %x\n", name, res); - global_qtest =3D qtest; =20 return res; } @@ -85,35 +82,25 @@ static inline unsigned in_reg(IVState *s, enum Reg reg) static inline void out_reg(IVState *s, enum Reg reg, unsigned v) { const char *name =3D reg2str(reg); - QTestState *qtest =3D global_qtest; =20 - global_qtest =3D s->qs->qts; g_test_message("%x -> *%s\n", v, name); qpci_io_writel(s->dev, s->reg_bar, reg, v); - global_qtest =3D qtest; } =20 static inline void read_mem(IVState *s, uint64_t off, void *buf, size_t le= n) { - QTestState *qtest =3D global_qtest; - - global_qtest =3D s->qs->qts; qpci_memread(s->dev, s->mem_bar, off, buf, len); - global_qtest =3D qtest; } =20 static inline void write_mem(IVState *s, uint64_t off, const void *buf, size_t len) { - QTestState *qtest =3D global_qtest; - - global_qtest =3D s->qs->qts; qpci_memwrite(s->dev, s->mem_bar, off, buf, len); - global_qtest =3D qtest; } =20 static void cleanup_vm(IVState *s) { + assert(!global_qtest); g_free(s->dev); qtest_shutdown(s->qs); } @@ -131,7 +118,6 @@ 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); @@ -354,7 +340,6 @@ static void test_ivshmem_server(bool msi) g_assert_cmpint(vm1, !=3D, vm2); =20 /* check number of MSI-X vectors */ - global_qtest =3D s1->qs->qts; if (msi) { ret =3D qpci_msix_table_size(s1->dev); g_assert_cmpuint(ret, =3D=3D, nvectors); @@ -377,7 +362,6 @@ static void test_ivshmem_server(bool msi) g_assert_cmpuint(ret, !=3D, 0); =20 /* ping vm1 -> vm2 on vector 1 */ - global_qtest =3D s2->qs->qts; if (msi) { ret =3D qpci_msix_pending(s2->dev, 1); g_assert_cmpuint(ret, =3D=3D, 0); --=20 1.8.3.1 From nobody Mon May 6 19:53:33 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 1542049861435560.9985994794752; Mon, 12 Nov 2018 11:11:01 -0800 (PST) Received: from localhost ([::1]:50342 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMHbs-0006bL-Tj for importer@patchew.org; Mon, 12 Nov 2018 14:10:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMHZq-0005JZ-HW for qemu-devel@nongnu.org; Mon, 12 Nov 2018 14:08:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gMHZn-00048X-5n for qemu-devel@nongnu.org; Mon, 12 Nov 2018 14:08:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60698) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gMHZj-00040M-4l for qemu-devel@nongnu.org; Mon, 12 Nov 2018 14:08:45 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0C717C049586; Mon, 12 Nov 2018 19:08:26 +0000 (UTC) Received: from thuth.com (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B7DE60C6C; Mon, 12 Nov 2018 19:08:24 +0000 (UTC) From: Thomas Huth To: Eric Blake , qemu-devel@nongnu.org Date: Mon, 12 Nov 2018 20:08:08 +0100 Message-Id: <1542049690-12826-6-git-send-email-thuth@redhat.com> In-Reply-To: <1542049690-12826-1-git-send-email-thuth@redhat.com> References: <1542049690-12826-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 12 Nov 2018 19:08:26 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-3.2 5/7] tests/acpi-utils: 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: , Cc: Laurent Vivier , Igor Mammedov , John Snow , Ben Warren , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" 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. bios-tables-test no longer depends on global_qtest, now that it passes explicit state through the testsuite data; an assert proves this fact (although we will get rid of it later, once global_qtest is gone). Signed-off-by: Eric Blake [thuth: adapted patch to current master branch] Signed-off-by: Thomas Huth Acked-by/Tested-by: Igor Mammedov --- tests/acpi-utils.c | 19 +++++------ tests/acpi-utils.h | 63 +++++++++++++++++++------------------ tests/bios-tables-test.c | 82 +++++++++++++++++++++++++-------------------= ---- tests/vmgenid-test.c | 24 +++++++------- 4 files changed, 96 insertions(+), 92 deletions(-) diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c index 41dc1ea..6dc8ca1 100644 --- a/tests/acpi-utils.c +++ b/tests/acpi-utils.c @@ -32,7 +32,7 @@ uint8_t acpi_calc_checksum(const uint8_t *data, int len) return sum; } =20 -uint32_t acpi_find_rsdp_address(void) +uint32_t acpi_find_rsdp_address(QTestState *qts) { uint32_t off; =20 @@ -42,7 +42,7 @@ uint32_t acpi_find_rsdp_address(void) int i; =20 for (i =3D 0; i < sizeof sig - 1; ++i) { - sig[i] =3D readb(off + i); + sig[i] =3D qtest_readb(qts, off + i); } =20 if (!memcmp(sig, "RSD PTR ", sizeof sig)) { @@ -52,14 +52,15 @@ uint32_t acpi_find_rsdp_address(void) return off; } =20 -void acpi_parse_rsdp_table(uint32_t addr, AcpiRsdpDescriptor *rsdp_table) +void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr, + AcpiRsdpDescriptor *rsdp_table) { - ACPI_READ_FIELD(rsdp_table->signature, addr); + ACPI_READ_FIELD(qts, rsdp_table->signature, addr); ACPI_ASSERT_CMP64(rsdp_table->signature, "RSD PTR "); =20 - ACPI_READ_FIELD(rsdp_table->checksum, addr); - ACPI_READ_ARRAY(rsdp_table->oem_id, addr); - ACPI_READ_FIELD(rsdp_table->revision, addr); - ACPI_READ_FIELD(rsdp_table->rsdt_physical_address, addr); - ACPI_READ_FIELD(rsdp_table->length, addr); + ACPI_READ_FIELD(qts, rsdp_table->checksum, addr); + ACPI_READ_ARRAY(qts, rsdp_table->oem_id, addr); + ACPI_READ_FIELD(qts, rsdp_table->revision, addr); + ACPI_READ_FIELD(qts, rsdp_table->rsdt_physical_address, addr); + ACPI_READ_FIELD(qts, rsdp_table->length, addr); } diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h index ac52abd..a06a4ed 100644 --- a/tests/acpi-utils.h +++ b/tests/acpi-utils.h @@ -28,34 +28,34 @@ typedef struct { bool tmp_files_retain; /* do not delete the temp asl/aml */ } AcpiSdtTable; =20 -#define ACPI_READ_FIELD(field, addr) \ - do { \ - memread(addr, &field, sizeof(field)); \ - addr +=3D sizeof(field); \ +#define ACPI_READ_FIELD(qts, field, addr) \ + do { \ + qtest_memread(qts, addr, &field, sizeof(field)); \ + addr +=3D sizeof(field); \ } while (0) =20 -#define ACPI_READ_ARRAY_PTR(arr, length, addr) \ - do { \ - int idx; \ - for (idx =3D 0; idx < length; ++idx) { \ - ACPI_READ_FIELD(arr[idx], addr); \ - } \ +#define ACPI_READ_ARRAY_PTR(qts, arr, length, addr) \ + do { \ + int idx; \ + for (idx =3D 0; idx < length; ++idx) { \ + ACPI_READ_FIELD(qts, arr[idx], addr); \ + } \ } while (0) =20 -#define ACPI_READ_ARRAY(arr, addr) \ - ACPI_READ_ARRAY_PTR(arr, sizeof(arr) / sizeof(arr[0]), addr) +#define ACPI_READ_ARRAY(qts, arr, addr) \ + ACPI_READ_ARRAY_PTR(qts, arr, sizeof(arr) / sizeof(arr[0]), addr) =20 -#define ACPI_READ_TABLE_HEADER(table, addr) \ +#define ACPI_READ_TABLE_HEADER(qts, table, addr) \ do { \ - ACPI_READ_FIELD((table)->signature, addr); \ - ACPI_READ_FIELD((table)->length, addr); \ - ACPI_READ_FIELD((table)->revision, addr); \ - ACPI_READ_FIELD((table)->checksum, addr); \ - ACPI_READ_ARRAY((table)->oem_id, addr); \ - ACPI_READ_ARRAY((table)->oem_table_id, addr); \ - ACPI_READ_FIELD((table)->oem_revision, addr); \ - ACPI_READ_ARRAY((table)->asl_compiler_id, addr); \ - ACPI_READ_FIELD((table)->asl_compiler_revision, addr); \ + ACPI_READ_FIELD(qts, (table)->signature, addr); \ + ACPI_READ_FIELD(qts, (table)->length, addr); \ + ACPI_READ_FIELD(qts, (table)->revision, addr); \ + ACPI_READ_FIELD(qts, (table)->checksum, addr); \ + ACPI_READ_ARRAY(qts, (table)->oem_id, addr); \ + ACPI_READ_ARRAY(qts, (table)->oem_table_id, addr); \ + ACPI_READ_FIELD(qts, (table)->oem_revision, addr); \ + ACPI_READ_ARRAY(qts, (table)->asl_compiler_id, addr); \ + ACPI_READ_FIELD(qts, (table)->asl_compiler_revision, addr); \ } while (0) =20 #define ACPI_ASSERT_CMP(actual, expected) do { \ @@ -70,18 +70,19 @@ typedef struct { g_assert_cmpstr(ACPI_ASSERT_CMP_str, =3D=3D, expected); \ } while (0) =20 -#define ACPI_READ_GENERIC_ADDRESS(field, addr) \ - do { \ - ACPI_READ_FIELD((field).space_id, addr); \ - ACPI_READ_FIELD((field).bit_width, addr); \ - ACPI_READ_FIELD((field).bit_offset, addr); \ - ACPI_READ_FIELD((field).access_width, addr); \ - ACPI_READ_FIELD((field).address, addr); \ +#define ACPI_READ_GENERIC_ADDRESS(qts, field, addr) \ + do { \ + ACPI_READ_FIELD(qts, (field).space_id, addr); \ + ACPI_READ_FIELD(qts, (field).bit_width, addr); \ + ACPI_READ_FIELD(qts, (field).bit_offset, addr); \ + ACPI_READ_FIELD(qts, (field).access_width, addr); \ + ACPI_READ_FIELD(qts, (field).address, addr); \ } while (0) =20 =20 uint8_t acpi_calc_checksum(const uint8_t *data, int len); -uint32_t acpi_find_rsdp_address(void); -void acpi_parse_rsdp_table(uint32_t addr, AcpiRsdpDescriptor *rsdp_table); +uint32_t acpi_find_rsdp_address(QTestState *qts); +void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr, + AcpiRsdpDescriptor *rsdp_table); =20 #endif /* TEST_ACPI_UTILS_H */ diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c index d661d9b..fabbed9 100644 --- a/tests/bios-tables-test.c +++ b/tests/bios-tables-test.c @@ -39,6 +39,7 @@ typedef struct { struct smbios_21_entry_point smbios_ep_table; uint8_t *required_struct_types; int required_struct_types_len; + QTestState *qts; } test_data; =20 static char disk[] =3D "tests/acpi-test-disk-XXXXXX"; @@ -78,7 +79,7 @@ static void free_test_data(test_data *data) =20 static void test_acpi_rsdp_address(test_data *data) { - uint32_t off =3D acpi_find_rsdp_address(); + uint32_t off =3D acpi_find_rsdp_address(data->qts); g_assert_cmphex(off, <, 0x100000); data->rsdp_addr =3D off; } @@ -88,7 +89,7 @@ static void test_acpi_rsdp_table(test_data *data) AcpiRsdpDescriptor *rsdp_table =3D &data->rsdp_table; uint32_t addr =3D data->rsdp_addr; =20 - acpi_parse_rsdp_table(addr, rsdp_table); + acpi_parse_rsdp_table(data->qts, addr, rsdp_table); =20 /* rsdp checksum is not for the whole table, but for the first 20 byte= s */ g_assert(!acpi_calc_checksum((uint8_t *)rsdp_table, 20)); @@ -104,7 +105,7 @@ static void test_acpi_rsdt_table(test_data *data) uint32_t rsdt_table_length; =20 /* read the header */ - ACPI_READ_TABLE_HEADER(rsdt_table, addr); + ACPI_READ_TABLE_HEADER(data->qts, rsdt_table, addr); ACPI_ASSERT_CMP(rsdt_table->signature, "RSDT"); =20 rsdt_table_length =3D le32_to_cpu(rsdt_table->length); @@ -116,7 +117,7 @@ static void test_acpi_rsdt_table(test_data *data) =20 /* get the addresses of the tables pointed by rsdt */ tables =3D g_new0(uint32_t, tables_nr); - ACPI_READ_ARRAY_PTR(tables, tables_nr, addr); + ACPI_READ_ARRAY_PTR(data->qts, tables, tables_nr, addr); =20 checksum =3D acpi_calc_checksum((uint8_t *)rsdt_table, rsdt_table_leng= th) + acpi_calc_checksum((uint8_t *)tables, @@ -135,11 +136,11 @@ static void fadt_fetch_facs_and_dsdt_ptrs(test_data *= data) =20 /* FADT table comes first */ addr =3D le32_to_cpu(data->rsdt_tables_addr[0]); - ACPI_READ_TABLE_HEADER(&hdr, addr); + ACPI_READ_TABLE_HEADER(data->qts, &hdr, addr); ACPI_ASSERT_CMP(hdr.signature, "FACP"); =20 - ACPI_READ_FIELD(data->facs_addr, addr); - ACPI_READ_FIELD(data->dsdt_addr, addr); + ACPI_READ_FIELD(data->qts, data->facs_addr, addr); + ACPI_READ_FIELD(data->qts, data->dsdt_addr, addr); } =20 static void sanitize_fadt_ptrs(test_data *data) @@ -182,13 +183,13 @@ static void test_acpi_facs_table(test_data *data) AcpiFacsDescriptorRev1 *facs_table =3D &data->facs_table; uint32_t addr =3D le32_to_cpu(data->facs_addr); =20 - ACPI_READ_FIELD(facs_table->signature, addr); - ACPI_READ_FIELD(facs_table->length, addr); - ACPI_READ_FIELD(facs_table->hardware_signature, addr); - ACPI_READ_FIELD(facs_table->firmware_waking_vector, addr); - ACPI_READ_FIELD(facs_table->global_lock, addr); - ACPI_READ_FIELD(facs_table->flags, addr); - ACPI_READ_ARRAY(facs_table->resverved3, addr); + ACPI_READ_FIELD(data->qts, facs_table->signature, addr); + ACPI_READ_FIELD(data->qts, facs_table->length, addr); + ACPI_READ_FIELD(data->qts, facs_table->hardware_signature, addr); + ACPI_READ_FIELD(data->qts, facs_table->firmware_waking_vector, addr); + ACPI_READ_FIELD(data->qts, facs_table->global_lock, addr); + ACPI_READ_FIELD(data->qts, facs_table->flags, addr); + ACPI_READ_ARRAY(data->qts, facs_table->resverved3, addr); =20 ACPI_ASSERT_CMP(facs_table->signature, "FACS"); } @@ -197,17 +198,17 @@ static void test_acpi_facs_table(test_data *data) * load ACPI table at @addr into table descriptor @sdt_table * and check that header checksum matches actual one. */ -static void fetch_table(AcpiSdtTable *sdt_table, uint32_t addr) +static void fetch_table(QTestState *qts, AcpiSdtTable *sdt_table, uint32_t= addr) { uint8_t checksum; =20 memset(sdt_table, 0, sizeof(*sdt_table)); - ACPI_READ_TABLE_HEADER(&sdt_table->header, addr); + ACPI_READ_TABLE_HEADER(qts, &sdt_table->header, addr); =20 sdt_table->aml_len =3D le32_to_cpu(sdt_table->header.length) - sizeof(AcpiTableHeader); sdt_table->aml =3D g_malloc0(sdt_table->aml_len); - ACPI_READ_ARRAY_PTR(sdt_table->aml, sdt_table->aml_len, addr); + ACPI_READ_ARRAY_PTR(qts, sdt_table->aml, sdt_table->aml_len, addr); =20 checksum =3D acpi_calc_checksum((uint8_t *)sdt_table, sizeof(AcpiTableHeader)) + @@ -221,7 +222,7 @@ static void test_acpi_dsdt_table(test_data *data) AcpiSdtTable dsdt_table; uint32_t addr =3D le32_to_cpu(data->dsdt_addr); =20 - fetch_table(&dsdt_table, addr); + fetch_table(data->qts, &dsdt_table, addr); ACPI_ASSERT_CMP(dsdt_table.header.signature, "DSDT"); =20 /* Since DSDT isn't in RSDT, add DSDT to ASL test tables list manually= */ @@ -239,7 +240,7 @@ static void fetch_rsdt_referenced_tables(test_data *dat= a) uint32_t addr; =20 addr =3D le32_to_cpu(data->rsdt_tables_addr[i]); - fetch_table(&ssdt_table, addr); + fetch_table(data->qts, &ssdt_table, addr); =20 /* Add table to ASL test tables list */ g_array_append_val(data->tables, ssdt_table); @@ -482,32 +483,32 @@ static bool smbios_ep_table_ok(test_data *data) struct smbios_21_entry_point *ep_table =3D &data->smbios_ep_table; uint32_t addr =3D data->smbios_ep_addr; =20 - ACPI_READ_ARRAY(ep_table->anchor_string, addr); + ACPI_READ_ARRAY(data->qts, ep_table->anchor_string, addr); if (memcmp(ep_table->anchor_string, "_SM_", 4)) { return false; } - ACPI_READ_FIELD(ep_table->checksum, addr); - ACPI_READ_FIELD(ep_table->length, addr); - ACPI_READ_FIELD(ep_table->smbios_major_version, addr); - ACPI_READ_FIELD(ep_table->smbios_minor_version, addr); - ACPI_READ_FIELD(ep_table->max_structure_size, addr); - ACPI_READ_FIELD(ep_table->entry_point_revision, addr); - ACPI_READ_ARRAY(ep_table->formatted_area, addr); - ACPI_READ_ARRAY(ep_table->intermediate_anchor_string, addr); + ACPI_READ_FIELD(data->qts, ep_table->checksum, addr); + ACPI_READ_FIELD(data->qts, ep_table->length, addr); + ACPI_READ_FIELD(data->qts, ep_table->smbios_major_version, addr); + ACPI_READ_FIELD(data->qts, ep_table->smbios_minor_version, addr); + ACPI_READ_FIELD(data->qts, ep_table->max_structure_size, addr); + ACPI_READ_FIELD(data->qts, ep_table->entry_point_revision, addr); + ACPI_READ_ARRAY(data->qts, ep_table->formatted_area, addr); + ACPI_READ_ARRAY(data->qts, ep_table->intermediate_anchor_string, addr); if (memcmp(ep_table->intermediate_anchor_string, "_DMI_", 5)) { return false; } - ACPI_READ_FIELD(ep_table->intermediate_checksum, addr); - ACPI_READ_FIELD(ep_table->structure_table_length, addr); + ACPI_READ_FIELD(data->qts, ep_table->intermediate_checksum, addr); + ACPI_READ_FIELD(data->qts, ep_table->structure_table_length, addr); if (ep_table->structure_table_length =3D=3D 0) { return false; } - ACPI_READ_FIELD(ep_table->structure_table_address, addr); - ACPI_READ_FIELD(ep_table->number_of_structures, addr); + ACPI_READ_FIELD(data->qts, ep_table->structure_table_address, addr); + ACPI_READ_FIELD(data->qts, ep_table->number_of_structures, addr); if (ep_table->number_of_structures =3D=3D 0) { return false; } - ACPI_READ_FIELD(ep_table->smbios_bcd_revision, addr); + ACPI_READ_FIELD(data->qts, ep_table->smbios_bcd_revision, addr); if (acpi_calc_checksum((uint8_t *)ep_table, sizeof *ep_table) || acpi_calc_checksum((uint8_t *)ep_table + 0x10, sizeof *ep_table - 0x10)) { @@ -526,7 +527,7 @@ static void test_smbios_entry_point(test_data *data) int i; =20 for (i =3D 0; i < sizeof sig - 1; ++i) { - sig[i] =3D readb(off + i); + sig[i] =3D qtest_readb(data->qts, off + i); } =20 if (!memcmp(sig, "_SM_", sizeof sig)) { @@ -569,9 +570,9 @@ static void test_smbios_structs(test_data *data) for (i =3D 0; i < le16_to_cpu(ep_table->number_of_structures); i++) { =20 /* grab type and formatted area length from struct header */ - type =3D readb(addr); + type =3D qtest_readb(data->qts, addr); g_assert_cmpuint(type, <=3D, SMBIOS_MAX_TYPE); - len =3D readb(addr + 1); + len =3D qtest_readb(data->qts, addr + 1); =20 /* single-instance structs must not have been encountered before */ if (smbios_single_instance(type)) { @@ -583,7 +584,7 @@ static void test_smbios_structs(test_data *data) prv =3D crt =3D 1; while (prv || crt) { prv =3D crt; - crt =3D readb(addr + len); + crt =3D qtest_readb(data->qts, addr + len); len++; } =20 @@ -620,9 +621,9 @@ static void test_acpi_one(const char *params, test_data= *data) data->machine, "kvm:tcg", params ? params : "", disk); =20 - qtest_start(args); + data->qts =3D qtest_init(args); =20 - boot_sector_test(global_qtest); + boot_sector_test(data->qts); =20 data->tables =3D g_array_new(false, true, sizeof(AcpiSdtTable)); test_acpi_rsdp_address(data); @@ -646,7 +647,8 @@ static void test_acpi_one(const char *params, test_data= *data) test_smbios_entry_point(data); test_smbios_structs(data); =20 - qtest_quit(global_qtest); + assert(!global_qtest); + qtest_quit(data->qts); g_free(args); } =20 diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c index 0a6fb55..c9c4f8c 100644 --- a/tests/vmgenid-test.c +++ b/tests/vmgenid-test.c @@ -31,7 +31,7 @@ typedef struct { uint32_t vgia_val; } QEMU_PACKED VgidTable; =20 -static uint32_t acpi_find_vgia(void) +static uint32_t acpi_find_vgia(QTestState *qts) { uint32_t rsdp_offset; uint32_t guid_offset =3D 0; @@ -45,18 +45,18 @@ static uint32_t acpi_find_vgia(void) int i; =20 /* Wait for guest firmware to finish and start the payload. */ - boot_sector_test(global_qtest); + boot_sector_test(qts); =20 /* Tables should be initialized now. */ - rsdp_offset =3D acpi_find_rsdp_address(); + rsdp_offset =3D acpi_find_rsdp_address(qts); =20 g_assert_cmphex(rsdp_offset, <, RSDP_ADDR_INVALID); =20 - acpi_parse_rsdp_table(rsdp_offset, &rsdp_table); + acpi_parse_rsdp_table(qts, rsdp_offset, &rsdp_table); =20 rsdt =3D le32_to_cpu(rsdp_table.rsdt_physical_address); /* read the header */ - ACPI_READ_TABLE_HEADER(&rsdt_table, rsdt); + ACPI_READ_TABLE_HEADER(qts, &rsdt_table, rsdt); ACPI_ASSERT_CMP(rsdt_table.signature, "RSDT"); rsdt_table_length =3D le32_to_cpu(rsdt_table.length); =20 @@ -67,22 +67,22 @@ static uint32_t acpi_find_vgia(void) =20 /* get the addresses of the tables pointed by rsdt */ tables =3D g_new0(uint32_t, tables_nr); - ACPI_READ_ARRAY_PTR(tables, tables_nr, rsdt); + ACPI_READ_ARRAY_PTR(qts, tables, tables_nr, rsdt); =20 for (i =3D 0; i < tables_nr; i++) { uint32_t addr =3D le32_to_cpu(tables[i]); - ACPI_READ_TABLE_HEADER(&ssdt_table, addr); + ACPI_READ_TABLE_HEADER(qts, &ssdt_table, addr); if (!strncmp((char *)ssdt_table.oem_table_id, "VMGENID", 7)) { /* the first entry in the table should be VGIA * That's all we need */ - ACPI_READ_FIELD(vgid_table.name_op, addr); + ACPI_READ_FIELD(qts, vgid_table.name_op, addr); g_assert(vgid_table.name_op =3D=3D 0x08); /* name */ - ACPI_READ_ARRAY(vgid_table.vgia, addr); + ACPI_READ_ARRAY(qts, vgid_table.vgia, addr); g_assert(memcmp(vgid_table.vgia, "VGIA", 4) =3D=3D 0); - ACPI_READ_FIELD(vgid_table.val_op, addr); + ACPI_READ_FIELD(qts, vgid_table.val_op, addr); g_assert(vgid_table.val_op =3D=3D 0x0C); /* dword */ - ACPI_READ_FIELD(vgid_table.vgia_val, addr); + ACPI_READ_FIELD(qts, vgid_table.vgia_val, addr); /* The GUID is written at a fixed offset into the fw_cfg file * in order to implement the "OVMF SDT Header probe suppressor" * see docs/specs/vmgenid.txt for more details @@ -100,7 +100,7 @@ static void read_guid_from_memory(QemuUUID *guid) uint32_t vmgenid_addr; int i; =20 - vmgenid_addr =3D acpi_find_vgia(); + vmgenid_addr =3D acpi_find_vgia(global_qtest); g_assert(vmgenid_addr); =20 /* Read the GUID directly from guest memory */ --=20 1.8.3.1 From nobody Mon May 6 19:53:33 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 1542049855258938.2286844315092; Mon, 12 Nov 2018 11:10:55 -0800 (PST) Received: from localhost ([::1]:50340 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMHbn-0006WQ-0b for importer@patchew.org; Mon, 12 Nov 2018 14:10:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMHZq-0005JY-HJ for qemu-devel@nongnu.org; Mon, 12 Nov 2018 14:08:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gMHZo-00049T-Be for qemu-devel@nongnu.org; Mon, 12 Nov 2018 14:08:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37308) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gMHZo-000418-1P for qemu-devel@nongnu.org; Mon, 12 Nov 2018 14:08:48 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D232DC0587CE; Mon, 12 Nov 2018 19:08:27 +0000 (UTC) Received: from thuth.com (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4CE4260C6B; Mon, 12 Nov 2018 19:08:26 +0000 (UTC) From: Thomas Huth To: Eric Blake , qemu-devel@nongnu.org Date: Mon, 12 Nov 2018 20:08:09 +0100 Message-Id: <1542049690-12826-7-git-send-email-thuth@redhat.com> In-Reply-To: <1542049690-12826-1-git-send-email-thuth@redhat.com> References: <1542049690-12826-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 12 Nov 2018 19:08:27 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-3.2 6/7] tests/vmgenid: Make test independent of 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: , Cc: Laurent Vivier , Igor Mammedov , John Snow , Ben Warren , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The biggest part has already been done in the previous patch, we now only have to replace some few qmp() and readb() calls with the corresponding qtest_*() functions to get there. Signed-off-by: Thomas Huth Acked-by: Igor Mammedov --- tests/vmgenid-test.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c index c9c4f8c..84449ce 100644 --- a/tests/vmgenid-test.c +++ b/tests/vmgenid-test.c @@ -95,17 +95,17 @@ static uint32_t acpi_find_vgia(QTestState *qts) return guid_offset; } =20 -static void read_guid_from_memory(QemuUUID *guid) +static void read_guid_from_memory(QTestState *qts, QemuUUID *guid) { uint32_t vmgenid_addr; int i; =20 - vmgenid_addr =3D acpi_find_vgia(global_qtest); + vmgenid_addr =3D acpi_find_vgia(qts); g_assert(vmgenid_addr); =20 /* Read the GUID directly from guest memory */ for (i =3D 0; i < 16; i++) { - guid->data[i] =3D readb(vmgenid_addr + i); + guid->data[i] =3D qtest_readb(qts, vmgenid_addr + i); } /* The GUID is in little-endian format in the guest, while QEMU * uses big-endian. Swap after reading. @@ -113,12 +113,12 @@ static void read_guid_from_memory(QemuUUID *guid) qemu_uuid_bswap(guid); } =20 -static void read_guid_from_monitor(QemuUUID *guid) +static void read_guid_from_monitor(QTestState *qts, QemuUUID *guid) { QDict *rsp, *rsp_ret; const char *guid_str; =20 - rsp =3D qmp("{ 'execute': 'query-vm-generation-id' }"); + rsp =3D qtest_qmp(qts, "{ 'execute': 'query-vm-generation-id' }"); if (qdict_haskey(rsp, "return")) { rsp_ret =3D qdict_get_qdict(rsp, "return"); g_assert(qdict_haskey(rsp_ret, "guid")); @@ -139,45 +139,48 @@ static char disk[] =3D "tests/vmgenid-test-disk-XXXXX= X"; static void vmgenid_set_guid_test(void) { QemuUUID expected, measured; + QTestState *qts; =20 g_assert(qemu_uuid_parse(VGID_GUID, &expected) =3D=3D 0); =20 - global_qtest =3D qtest_initf(GUID_CMD(VGID_GUID)); + qts =3D qtest_initf(GUID_CMD(VGID_GUID)); =20 /* Read the GUID from accessing guest memory */ - read_guid_from_memory(&measured); + read_guid_from_memory(qts, &measured); g_assert(memcmp(measured.data, expected.data, sizeof(measured.data)) = =3D=3D 0); =20 - qtest_quit(global_qtest); + qtest_quit(qts); } =20 static void vmgenid_set_guid_auto_test(void) { QemuUUID measured; + QTestState *qts; =20 - global_qtest =3D qtest_initf(GUID_CMD("auto")); + qts =3D qtest_initf(GUID_CMD("auto")); =20 - read_guid_from_memory(&measured); + read_guid_from_memory(qts, &measured); =20 /* Just check that the GUID is non-null */ g_assert(!qemu_uuid_is_null(&measured)); =20 - qtest_quit(global_qtest); + qtest_quit(qts); } =20 static void vmgenid_query_monitor_test(void) { QemuUUID expected, measured; + QTestState *qts; =20 g_assert(qemu_uuid_parse(VGID_GUID, &expected) =3D=3D 0); =20 - global_qtest =3D qtest_initf(GUID_CMD(VGID_GUID)); + qts =3D qtest_initf(GUID_CMD(VGID_GUID)); =20 /* Read the GUID via the monitor */ - read_guid_from_monitor(&measured); + read_guid_from_monitor(qts, &measured); g_assert(memcmp(measured.data, expected.data, sizeof(measured.data)) = =3D=3D 0); =20 - qtest_quit(global_qtest); + qtest_quit(qts); } =20 int main(int argc, char **argv) --=20 1.8.3.1 From nobody Mon May 6 19:53:33 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 154205005121452.56790124645045; Mon, 12 Nov 2018 11:14:11 -0800 (PST) Received: from localhost ([::1]:50359 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMHf0-0000c0-2Z for importer@patchew.org; Mon, 12 Nov 2018 14:14:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48752) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMHZq-0005Jc-Hp for qemu-devel@nongnu.org; Mon, 12 Nov 2018 14:08:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gMHZo-00049C-0t for qemu-devel@nongnu.org; Mon, 12 Nov 2018 14:08:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38876) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gMHZn-00041k-PZ for qemu-devel@nongnu.org; Mon, 12 Nov 2018 14:08:47 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AE7402D7E1; Mon, 12 Nov 2018 19:08:29 +0000 (UTC) Received: from thuth.com (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2569160C67; Mon, 12 Nov 2018 19:08:27 +0000 (UTC) From: Thomas Huth To: Eric Blake , qemu-devel@nongnu.org Date: Mon, 12 Nov 2018 20:08:10 +0100 Message-Id: <1542049690-12826-8-git-send-email-thuth@redhat.com> In-Reply-To: <1542049690-12826-1-git-send-email-thuth@redhat.com> References: <1542049690-12826-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 12 Nov 2018 19:08:29 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-3.2 7/7] tests/boot-serial: Get rid of global_qtest variable 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: , Cc: Laurent Vivier , Igor Mammedov , John Snow , Ben Warren , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The test does not use any of the functions that require global_qtest, so we can simply get rid of this global variable here. Signed-off-by: Thomas Huth --- tests/boot-serial-test.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c index 8ec6aed..f085165 100644 --- a/tests/boot-serial-test.c +++ b/tests/boot-serial-test.c @@ -161,6 +161,7 @@ static void test_machine(const void *data) char codetmp[] =3D "/tmp/qtest-boot-serial-cXXXXXX"; const char *codeparam =3D ""; const uint8_t *code =3D NULL; + QTestState *qts; int ser_fd; =20 ser_fd =3D mkstemp(serialtmp); @@ -189,11 +190,11 @@ static void test_machine(const void *data) * Make sure that this test uses tcg if available: It is used as a * fast-enough smoketest for that. */ - global_qtest =3D qtest_initf("%s %s -M %s,accel=3Dtcg:kvm " - "-chardev file,id=3Dserial0,path=3D%s " - "-no-shutdown -serial chardev:serial0 %s", - codeparam, code ? codetmp : "", - test->machine, serialtmp, test->extra); + qts =3D qtest_initf("%s %s -M %s,accel=3Dtcg:kvm -no-shutdown " + "-chardev file,id=3Dserial0,path=3D%s " + " -serial chardev:serial0 %s", + codeparam, code ? codetmp : "", test->machine, + serialtmp, test->extra); if (code) { unlink(codetmp); } @@ -204,7 +205,7 @@ static void test_machine(const void *data) } unlink(serialtmp); =20 - qtest_quit(global_qtest); + qtest_quit(qts); =20 close(ser_fd); } --=20 1.8.3.1