From patchwork Thu Jan 5 15:29:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 711448 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tvWqZ5P6Wz9sCg for ; Fri, 6 Jan 2017 02:31:22 +1100 (AEDT) Received: from localhost ([::1]:47006 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cPA0e-0004yH-Fx for incoming@patchwork.ozlabs.org; Thu, 05 Jan 2017 10:31:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59500) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cP9zN-0003xj-L6 for qemu-devel@nongnu.org; Thu, 05 Jan 2017 10:30:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cP9zM-0004ph-OR for qemu-devel@nongnu.org; Thu, 05 Jan 2017 10:30:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60980) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cP9zM-0004pL-Fl; Thu, 05 Jan 2017 10:30:00 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9C96421728; Thu, 5 Jan 2017 15:30:00 +0000 (UTC) Received: from thinkpad.redhat.com (ovpn-116-163.ams2.redhat.com [10.36.116.163]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v05FTnx9026830; Thu, 5 Jan 2017 10:29:58 -0500 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Thu, 5 Jan 2017 16:29:47 +0100 Message-Id: <1483630188-32021-5-git-send-email-lvivier@redhat.com> In-Reply-To: <1483630188-32021-1-git-send-email-lvivier@redhat.com> References: <1483630188-32021-1-git-send-email-lvivier@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 05 Jan 2017 15:30:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 4/5] qtest: convert ivshmem-test to use libqos 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 , Thomas Huth , Greg Kurz , Markus Armbruster , qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This will allow to use it with ppc64. Signed-off-by: Laurent Vivier --- tests/ivshmem-test.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/tests/ivshmem-test.c b/tests/ivshmem-test.c index 04a5c5d..8095d72 100644 --- a/tests/ivshmem-test.c +++ b/tests/ivshmem-test.c @@ -11,7 +11,7 @@ #include "qemu/osdep.h" #include #include "contrib/ivshmem-server/ivshmem-server.h" -#include "libqos/pci-pc.h" +#include "libqos/libqos-pc.h" #include "libqtest.h" #include "qemu-common.h" @@ -40,9 +40,8 @@ static QPCIDevice *get_device(QPCIBus *pcibus) } typedef struct _IVState { - QTestState *qtest; + QOSState *qs; QPCIBar reg_bar, mem_bar; - QPCIBus *pcibus; QPCIDevice *dev; } IVState; @@ -74,7 +73,7 @@ static inline unsigned in_reg(IVState *s, enum Reg reg) QTestState *qtest = global_qtest; unsigned res; - global_qtest = s->qtest; + global_qtest = s->qs->qts; res = qpci_io_readl(s->dev, s->reg_bar, reg); g_test_message("*%s -> %x\n", name, res); global_qtest = qtest; @@ -87,7 +86,7 @@ static inline void out_reg(IVState *s, enum Reg reg, unsigned v) const char *name = reg2str(reg); QTestState *qtest = global_qtest; - global_qtest = s->qtest; + global_qtest = s->qs->qts; g_test_message("%x -> *%s\n", v, name); qpci_io_writel(s->dev, s->reg_bar, reg, v); global_qtest = qtest; @@ -97,7 +96,7 @@ static inline void read_mem(IVState *s, uint64_t off, void *buf, size_t len) { QTestState *qtest = global_qtest; - global_qtest = s->qtest; + global_qtest = s->qs->qts; qpci_memread(s->dev, s->mem_bar, off, buf, len); global_qtest = qtest; } @@ -107,7 +106,7 @@ static inline void write_mem(IVState *s, uint64_t off, { QTestState *qtest = global_qtest; - global_qtest = s->qtest; + global_qtest = s->qs->qts; qpci_memwrite(s->dev, s->mem_bar, off, buf, len); global_qtest = qtest; } @@ -115,17 +114,21 @@ static inline void write_mem(IVState *s, uint64_t off, static void cleanup_vm(IVState *s) { g_free(s->dev); - qpci_free_pc(s->pcibus); - qtest_quit(s->qtest); + qtest_shutdown(s->qs); } static void setup_vm_cmd(IVState *s, const char *cmd, bool msix) { uint64_t barsize; + const char *arch = qtest_get_arch(); - s->qtest = qtest_start(cmd); - s->pcibus = qpci_init_pc(NULL); - s->dev = get_device(s->pcibus); + if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { + s->qs = qtest_pc_boot(cmd); + } else { + g_printerr("ivshmem-test tests are only available on x86\n"); + exit(EXIT_FAILURE); + } + s->dev = get_device(s->qs->pcibus); s->reg_bar = qpci_iomap(s->dev, 0, &barsize); g_assert_cmpuint(barsize, ==, 256); @@ -347,7 +350,7 @@ static void test_ivshmem_server(bool msi) g_assert_cmpint(vm1, !=, vm2); /* check number of MSI-X vectors */ - global_qtest = s1->qtest; + global_qtest = s1->qs->qts; if (msi) { ret = qpci_msix_table_size(s1->dev); g_assert_cmpuint(ret, ==, nvectors); @@ -370,7 +373,7 @@ static void test_ivshmem_server(bool msi) g_assert_cmpuint(ret, !=, 0); /* ping vm1 -> vm2 on vector 1 */ - global_qtest = s2->qtest; + global_qtest = s2->qs->qts; if (msi) { ret = qpci_msix_pending(s2->dev, 1); g_assert_cmpuint(ret, ==, 0);