From patchwork Thu Mar 7 17:29:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1053187 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Dg2JUm+4"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44Ff6b5cXkz9s70 for ; Fri, 8 Mar 2019 05:19:35 +1100 (AEDT) Received: from localhost ([127.0.0.1]:56790 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1xcD-0001Q0-Kw for incoming@patchwork.ozlabs.org; Thu, 07 Mar 2019 13:19:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39760) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1wr3-0003VE-IC for qemu-devel@nongnu.org; Thu, 07 Mar 2019 12:30:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1wqx-0008GA-O1 for qemu-devel@nongnu.org; Thu, 07 Mar 2019 12:30:49 -0500 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:38200) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1wqv-0008Ca-Op for qemu-devel@nongnu.org; Thu, 07 Mar 2019 12:30:43 -0500 Received: by mail-wm1-x343.google.com with SMTP id a188so10001843wmf.3 for ; Thu, 07 Mar 2019 09:30:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=7TR6DlnweAxCx8K5J44dvhYJYQSKpqKMrNRDI1lDL2w=; b=Dg2JUm+46DPRMqkQ0//tR1z/seDFNxXTDKdRaDftJfzpHphXPahh7AX7OGHN8idZeG Gdu1o/6ealuQjb5fCY5K5cnWL69anGS7jqgnADKKb4vtulHRxA5frcSeZTHG4xMEy8wn DYwfg1NYSzXRu9CCJeXCLKOq6ar0tC6OJ6UZBEsllrCkQRprcjvxiJ5owApnU21SPRrd yPit0sXA6to+2HBMzKDjnPl4t2sdzLkISSwA23Y8LZFxgyeBWRuVYvYifK/+Htn1q9C+ 55dRxHQO1+rf7fsIPF8K8pzqz8rVpG/oKVfk78cZAysGvlAOi0R/wXqOCYjoFzJbFyIF PI5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=7TR6DlnweAxCx8K5J44dvhYJYQSKpqKMrNRDI1lDL2w=; b=Mf3Ow7XLJ+cDHcR9fedA5CZueIZ5pHsNzG1n9S8pIfu1QmZglVV6sjaouu8zCTMXDB skeGA0wz/zNWQ2NfU9GiEJUblcfYa1Lf3hTU0WGWXAFT/EmnzLk3AH6jl/EOoaz31QWG xgNSeOsM4Ep4aMDdDRQ7pTUleLjusF65m2jMAfWfVJk6tlw17WktZSPO6IR0Xn/LKOKS g8S5UZZsZaLWk9SgCKZ71Ujxyj2vPRwJawwOQ2yKH+Y4yRWS33cynPVoV8VXnr2XajG0 kG0oP/DfHZyoTcKsyWPSiD2z69u0kA6uWTPNczVsz6Lt6JGyWOy3JBU/01NblD64zlom rOyQ== X-Gm-Message-State: APjAAAX9Js9mwlrSMiRkxgp44e0bEfRDFLe6Z70wWRyRG1OYwK7Xh6k1 GjYQrVSLhV3o6vAsudscS0VnYmFd X-Google-Smtp-Source: APXvYqx7W97NKa++a/Ixd41Mq3CCZBEvyjWexz1ix1atAtm0Op+dd/+HZRtXF2hSf2PGI9Loc6OfnA== X-Received: by 2002:a1c:ce46:: with SMTP id e67mr6700437wmg.40.1551979838399; Thu, 07 Mar 2019 09:30:38 -0800 (PST) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id d206sm9979753wmc.11.2019.03.07.09.30.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 09:30:37 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 7 Mar 2019 18:29:36 +0100 Message-Id: <1551979804-6060-30-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1551979804-6060-1-git-send-email-pbonzini@redhat.com> References: <1551979804-6060-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PULL 29/57] qos-test: virtio-9p test node 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: thuth@redhat.com, Emanuele Giuseppe Esposito , lviver@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Emanuele Giuseppe Esposito Convert tests/virtio-9p-test into a qgraph test node. This test consumes a virtio-9p interface and checks that its functions return the expected values. Note that this test does not allocate any virtio-9p structure, it's all done by the qtest walking graph mechanism Signed-off-by: Emanuele Giuseppe Esposito Signed-off-by: Paolo Bonzini --- tests/Makefile.include | 5 +- tests/virtio-9p-test.c | 218 +++++++++++++++++-------------------------------- 2 files changed, 78 insertions(+), 145 deletions(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index cb8f0c5..8feca79 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -158,9 +158,6 @@ check-qtest-virtio-y += tests/virtio-balloon-test$(EXESUF) check-qtest-virtio-y += tests/virtio-blk-test$(EXESUF) check-qtest-virtio-y += tests/virtio-rng-test$(EXESUF) check-qtest-virtio-y += tests/virtio-scsi-test$(EXESUF) -ifeq ($(CONFIG_VIRTIO)$(CONFIG_VIRTFS)$(CONFIG_PCI),yyy) -check-qtest-virtio-$(CONFIG_VIRTIO_9P) += tests/virtio-9p-test$(EXESUF) -endif check-qtest-pci-y += tests/e1000-test$(EXESUF) check-qtest-pci-$(CONFIG_RTL8139_PCI) += tests/rtl8139-test$(EXESUF) @@ -766,6 +763,7 @@ qos-test-obj-y += tests/e1000e-test.o qos-test-obj-y += tests/pci-test.o qos-test-obj-y += tests/sdhci-test.o qos-test-obj-y += tests/virtio-test.o +qos-test-obj-$(CONFIG_VIRTFS) += tests/virtio-9p-test.o qos-test-obj-y += tests/virtio-serial-test.o check-unit-y += tests/test-qgraph$(EXESUF) @@ -818,7 +816,6 @@ tests/virtio-ccw-test$(EXESUF): tests/virtio-ccw-test.o tests/virtio-net-test$(EXESUF): tests/virtio-net-test.o $(libqos-pc-obj-y) $(libqos-virtio-obj-y) tests/virtio-rng-test$(EXESUF): tests/virtio-rng-test.o $(libqos-pc-obj-y) tests/virtio-scsi-test$(EXESUF): tests/virtio-scsi-test.o $(libqos-virtio-obj-y) -tests/virtio-9p-test$(EXESUF): tests/virtio-9p-test.o $(libqos-virtio-obj-y) tests/tpci200-test$(EXESUF): tests/tpci200-test.o tests/display-vga-test$(EXESUF): tests/display-vga-test.o tests/ipoctal232-test$(EXESUF): tests/ipoctal232-test.o diff --git a/tests/virtio-9p-test.c b/tests/virtio-9p-test.c index 8fd74f6..16107ad 100644 --- a/tests/virtio-9p-test.c +++ b/tests/virtio-9p-test.c @@ -9,99 +9,36 @@ #include "qemu/osdep.h" #include "libqtest.h" -#include "qemu-common.h" -#include "libqos/libqos-pc.h" -#include "libqos/libqos-spapr.h" -#include "libqos/virtio.h" -#include "libqos/virtio-pci.h" -#include "standard-headers/linux/virtio_ids.h" -#include "standard-headers/linux/virtio_pci.h" #include "hw/9pfs/9p.h" #include "hw/9pfs/9p-synth.h" +#include "libqos/virtio-9p.h" +#include "libqos/qgraph.h" #define QVIRTIO_9P_TIMEOUT_US (10 * 1000 * 1000) +static QGuestAllocator *alloc; -static const char mount_tag[] = "qtest"; - -typedef struct { - QVirtioDevice *dev; - QOSState *qs; - QVirtQueue *vq; -} QVirtIO9P; - -static QVirtIO9P *qvirtio_9p_start(const char *driver) -{ - const char *arch = qtest_get_arch(); - const char *cmd = "-fsdev synth,id=fsdev0 " - "-device %s,fsdev=fsdev0,mount_tag=%s"; - QVirtIO9P *v9p = g_new0(QVirtIO9P, 1); - - if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { - v9p->qs = qtest_pc_boot(cmd, driver, mount_tag); - } else if (strcmp(arch, "ppc64") == 0) { - v9p->qs = qtest_spapr_boot(cmd, driver, mount_tag); - } else { - g_printerr("virtio-9p tests are only available on x86 or ppc64\n"); - exit(EXIT_FAILURE); - } - global_qtest = v9p->qs->qts; - - return v9p; -} - -static void qvirtio_9p_stop(QVirtIO9P *v9p) -{ - qtest_shutdown(v9p->qs); - g_free(v9p); -} - -static QVirtIO9P *qvirtio_9p_pci_start(void) -{ - QVirtIO9P *v9p = qvirtio_9p_start("virtio-9p-pci"); - QVirtioPCIDevice *dev = qvirtio_pci_device_find(v9p->qs->pcibus, - VIRTIO_ID_9P); - g_assert_nonnull(dev); - g_assert_cmphex(dev->vdev.device_type, ==, VIRTIO_ID_9P); - v9p->dev = (QVirtioDevice *) dev; - - qvirtio_pci_device_enable(dev); - qvirtio_start_device(v9p->dev); - - v9p->vq = qvirtqueue_setup(v9p->dev, &v9p->qs->alloc, 0); - - qvirtio_set_driver_ok(v9p->dev); - - return v9p; -} - -static void qvirtio_9p_pci_stop(QVirtIO9P *v9p) -{ - qvirtqueue_cleanup(v9p->dev->bus, v9p->vq, &v9p->qs->alloc); - qvirtio_pci_device_disable(container_of(v9p->dev, QVirtioPCIDevice, vdev)); - qvirtio_pci_device_free((QVirtioPCIDevice *)v9p->dev); - qvirtio_9p_stop(v9p); -} - -static void pci_config(QVirtIO9P *v9p) +static void pci_config(void *obj, void *data, QGuestAllocator *t_alloc) { - size_t tag_len = qvirtio_config_readw(v9p->dev, 0); + QVirtio9P *v9p = obj; + alloc = t_alloc; + size_t tag_len = qvirtio_config_readw(v9p->vdev, 0); char *tag; int i; - g_assert_cmpint(tag_len, ==, strlen(mount_tag)); + g_assert_cmpint(tag_len, ==, strlen(MOUNT_TAG)); tag = g_malloc(tag_len); for (i = 0; i < tag_len; i++) { - tag[i] = qvirtio_config_readb(v9p->dev, i + 2); + tag[i] = qvirtio_config_readb(v9p->vdev, i + 2); } - g_assert_cmpmem(tag, tag_len, mount_tag, tag_len); + g_assert_cmpmem(tag, tag_len, MOUNT_TAG, tag_len); g_free(tag); } #define P9_MAX_SIZE 4096 /* Max size of a T-message or R-message */ typedef struct { - QVirtIO9P *v9p; + QVirtio9P *v9p; uint16_t tag; uint64_t t_msg; uint32_t t_size; @@ -204,7 +141,7 @@ static void v9fs_string_read(P9Req *req, uint16_t *len, char **string) uint16_t tag; } QEMU_PACKED P9Hdr; -static P9Req *v9fs_req_init(QVirtIO9P *v9p, uint32_t size, uint8_t id, +static P9Req *v9fs_req_init(QVirtio9P *v9p, uint32_t size, uint8_t id, uint16_t tag) { P9Req *req = g_new0(P9Req, 1); @@ -222,7 +159,7 @@ static P9Req *v9fs_req_init(QVirtIO9P *v9p, uint32_t size, uint8_t id, req->v9p = v9p; req->t_size = total_size; - req->t_msg = guest_alloc(&v9p->qs->alloc, req->t_size); + req->t_msg = guest_alloc(alloc, req->t_size); v9fs_memwrite(req, &hdr, 7); req->tag = tag; return req; @@ -230,13 +167,13 @@ static P9Req *v9fs_req_init(QVirtIO9P *v9p, uint32_t size, uint8_t id, static void v9fs_req_send(P9Req *req) { - QVirtIO9P *v9p = req->v9p; + QVirtio9P *v9p = req->v9p; - req->r_msg = guest_alloc(&v9p->qs->alloc, P9_MAX_SIZE); + req->r_msg = guest_alloc(alloc, P9_MAX_SIZE); req->free_head = qvirtqueue_add(v9p->vq, req->t_msg, req->t_size, false, true); qvirtqueue_add(v9p->vq, req->r_msg, P9_MAX_SIZE, true, false); - qvirtqueue_kick(v9p->dev, v9p->vq, req->free_head); + qvirtqueue_kick(v9p->vdev, v9p->vq, req->free_head); req->t_off = 0; } @@ -255,9 +192,9 @@ static const char *rmessage_name(uint8_t id) static void v9fs_req_wait_for_reply(P9Req *req, uint32_t *len) { - QVirtIO9P *v9p = req->v9p; + QVirtio9P *v9p = req->v9p; - qvirtio_wait_used_elem(v9p->dev, v9p->vq, req->free_head, len, + qvirtio_wait_used_elem(v9p->vdev, v9p->vq, req->free_head, len, QVIRTIO_9P_TIMEOUT_US); } @@ -288,10 +225,8 @@ static void v9fs_req_recv(P9Req *req, uint8_t id) static void v9fs_req_free(P9Req *req) { - QVirtIO9P *v9p = req->v9p; - - guest_free(&v9p->qs->alloc, req->t_msg); - guest_free(&v9p->qs->alloc, req->r_msg); + guest_free(alloc, req->t_msg); + guest_free(alloc, req->r_msg); g_free(req); } @@ -304,7 +239,7 @@ static void v9fs_rlerror(P9Req *req, uint32_t *err) } /* size[4] Tversion tag[2] msize[4] version[s] */ -static P9Req *v9fs_tversion(QVirtIO9P *v9p, uint32_t msize, const char *version, +static P9Req *v9fs_tversion(QVirtio9P *v9p, uint32_t msize, const char *version, uint16_t tag) { P9Req *req; @@ -339,7 +274,7 @@ static void v9fs_rversion(P9Req *req, uint16_t *len, char **version) } /* size[4] Tattach tag[2] fid[4] afid[4] uname[s] aname[s] n_uname[4] */ -static P9Req *v9fs_tattach(QVirtIO9P *v9p, uint32_t fid, uint32_t n_uname, +static P9Req *v9fs_tattach(QVirtio9P *v9p, uint32_t fid, uint32_t n_uname, uint16_t tag) { const char *uname = ""; /* ignored by QEMU */ @@ -368,7 +303,7 @@ static void v9fs_rattach(P9Req *req, v9fs_qid *qid) } /* size[4] Twalk tag[2] fid[4] newfid[4] nwname[2] nwname*(wname[s]) */ -static P9Req *v9fs_twalk(QVirtIO9P *v9p, uint32_t fid, uint32_t newfid, +static P9Req *v9fs_twalk(QVirtio9P *v9p, uint32_t fid, uint32_t newfid, uint16_t nwname, char *const wnames[], uint16_t tag) { P9Req *req; @@ -410,7 +345,7 @@ static void v9fs_rwalk(P9Req *req, uint16_t *nwqid, v9fs_qid **wqid) } /* size[4] Tlopen tag[2] fid[4] flags[4] */ -static P9Req *v9fs_tlopen(QVirtIO9P *v9p, uint32_t fid, uint32_t flags, +static P9Req *v9fs_tlopen(QVirtio9P *v9p, uint32_t fid, uint32_t flags, uint16_t tag) { P9Req *req; @@ -438,7 +373,7 @@ static void v9fs_rlopen(P9Req *req, v9fs_qid *qid, uint32_t *iounit) } /* size[4] Twrite tag[2] fid[4] offset[8] count[4] data[count] */ -static P9Req *v9fs_twrite(QVirtIO9P *v9p, uint32_t fid, uint64_t offset, +static P9Req *v9fs_twrite(QVirtio9P *v9p, uint32_t fid, uint64_t offset, uint32_t count, const void *data, uint16_t tag) { P9Req *req; @@ -466,7 +401,7 @@ static void v9fs_rwrite(P9Req *req, uint32_t *count) } /* size[4] Tflush tag[2] oldtag[2] */ -static P9Req *v9fs_tflush(QVirtIO9P *v9p, uint16_t oldtag, uint16_t tag) +static P9Req *v9fs_tflush(QVirtio9P *v9p, uint16_t oldtag, uint16_t tag) { P9Req *req; @@ -483,8 +418,10 @@ static void v9fs_rflush(P9Req *req) v9fs_req_free(req); } -static void fs_version(QVirtIO9P *v9p) +static void fs_version(void *obj, void *data, QGuestAllocator *t_alloc) { + QVirtio9P *v9p = obj; + alloc = t_alloc; const char *version = "9P2000.L"; uint16_t server_len; char *server_version; @@ -499,18 +436,22 @@ static void fs_version(QVirtIO9P *v9p) g_free(server_version); } -static void fs_attach(QVirtIO9P *v9p) +static void fs_attach(void *obj, void *data, QGuestAllocator *t_alloc) { + QVirtio9P *v9p = obj; + alloc = t_alloc; P9Req *req; - fs_version(v9p); + fs_version(v9p, NULL, t_alloc); req = v9fs_tattach(v9p, 0, getuid(), 0); v9fs_req_wait_for_reply(req, NULL); v9fs_rattach(req, NULL); } -static void fs_walk(QVirtIO9P *v9p) +static void fs_walk(void *obj, void *data, QGuestAllocator *t_alloc) { + QVirtio9P *v9p = obj; + alloc = t_alloc; char *wnames[P9_MAXWELEM]; uint16_t nwqid; v9fs_qid *wqid; @@ -521,7 +462,7 @@ static void fs_walk(QVirtIO9P *v9p) wnames[i] = g_strdup_printf(QTEST_V9FS_SYNTH_WALK_FILE, i); } - fs_attach(v9p); + fs_attach(v9p, NULL, t_alloc); req = v9fs_twalk(v9p, 0, 1, P9_MAXWELEM, wnames, 0); v9fs_req_wait_for_reply(req, NULL); v9fs_rwalk(req, &nwqid, &wqid); @@ -535,13 +476,15 @@ static void fs_walk(QVirtIO9P *v9p) g_free(wqid); } -static void fs_walk_no_slash(QVirtIO9P *v9p) +static void fs_walk_no_slash(void *obj, void *data, QGuestAllocator *t_alloc) { + QVirtio9P *v9p = obj; + alloc = t_alloc; char *const wnames[] = { g_strdup(" /") }; P9Req *req; uint32_t err; - fs_attach(v9p); + fs_attach(v9p, NULL, t_alloc); req = v9fs_twalk(v9p, 0, 1, 1, wnames, 0); v9fs_req_wait_for_reply(req, NULL); v9fs_rlerror(req, &err); @@ -551,13 +494,15 @@ static void fs_walk_no_slash(QVirtIO9P *v9p) g_free(wnames[0]); } -static void fs_walk_dotdot(QVirtIO9P *v9p) +static void fs_walk_dotdot(void *obj, void *data, QGuestAllocator *t_alloc) { + QVirtio9P *v9p = obj; + alloc = t_alloc; char *const wnames[] = { g_strdup("..") }; v9fs_qid root_qid, *wqid; P9Req *req; - fs_version(v9p); + fs_version(v9p, NULL, t_alloc); req = v9fs_tattach(v9p, 0, getuid(), 0); v9fs_req_wait_for_reply(req, NULL); v9fs_rattach(req, &root_qid); @@ -572,12 +517,14 @@ static void fs_walk_dotdot(QVirtIO9P *v9p) g_free(wnames[0]); } -static void fs_lopen(QVirtIO9P *v9p) +static void fs_lopen(void *obj, void *data, QGuestAllocator *t_alloc) { + QVirtio9P *v9p = obj; + alloc = t_alloc; char *const wnames[] = { g_strdup(QTEST_V9FS_SYNTH_LOPEN_FILE) }; P9Req *req; - fs_attach(v9p); + fs_attach(v9p, NULL, t_alloc); req = v9fs_twalk(v9p, 0, 1, 1, wnames, 0); v9fs_req_wait_for_reply(req, NULL); v9fs_rwalk(req, NULL, NULL); @@ -589,15 +536,17 @@ static void fs_lopen(QVirtIO9P *v9p) g_free(wnames[0]); } -static void fs_write(QVirtIO9P *v9p) +static void fs_write(void *obj, void *data, QGuestAllocator *t_alloc) { + QVirtio9P *v9p = obj; + alloc = t_alloc; static const uint32_t write_count = P9_MAX_SIZE / 2; char *const wnames[] = { g_strdup(QTEST_V9FS_SYNTH_WRITE_FILE) }; char *buf = g_malloc0(write_count); uint32_t count; P9Req *req; - fs_attach(v9p); + fs_attach(v9p, NULL, t_alloc); req = v9fs_twalk(v9p, 0, 1, 1, wnames, 0); v9fs_req_wait_for_reply(req, NULL); v9fs_rwalk(req, NULL, NULL); @@ -615,14 +564,16 @@ static void fs_write(QVirtIO9P *v9p) g_free(wnames[0]); } -static void fs_flush_success(QVirtIO9P *v9p) +static void fs_flush_success(void *obj, void *data, QGuestAllocator *t_alloc) { + QVirtio9P *v9p = obj; + alloc = t_alloc; char *const wnames[] = { g_strdup(QTEST_V9FS_SYNTH_FLUSH_FILE) }; P9Req *req, *flush_req; uint32_t reply_len; uint8_t should_block; - fs_attach(v9p); + fs_attach(v9p, NULL, t_alloc); req = v9fs_twalk(v9p, 0, 1, 1, wnames, 0); v9fs_req_wait_for_reply(req, NULL); v9fs_rwalk(req, NULL, NULL); @@ -650,14 +601,16 @@ static void fs_flush_success(QVirtIO9P *v9p) g_free(wnames[0]); } -static void fs_flush_ignored(QVirtIO9P *v9p) +static void fs_flush_ignored(void *obj, void *data, QGuestAllocator *t_alloc) { + QVirtio9P *v9p = obj; + alloc = t_alloc; char *const wnames[] = { g_strdup(QTEST_V9FS_SYNTH_FLUSH_FILE) }; P9Req *req, *flush_req; uint32_t count; uint8_t should_block; - fs_attach(v9p); + fs_attach(v9p, NULL, t_alloc); req = v9fs_twalk(v9p, 0, 1, 1, wnames, 0); v9fs_req_wait_for_reply(req, NULL); v9fs_rwalk(req, NULL, NULL); @@ -685,39 +638,22 @@ static void fs_flush_ignored(QVirtIO9P *v9p) g_free(wnames[0]); } -typedef void (*v9fs_test_fn)(QVirtIO9P *v9p); - -static void v9fs_run_pci_test(gconstpointer data) +static void register_virtio_9p_test(void) { - v9fs_test_fn fn = data; - QVirtIO9P *v9p = qvirtio_9p_pci_start(); - - if (fn) { - fn(v9p); - } - qvirtio_9p_pci_stop(v9p); -} - -static void v9fs_qtest_pci_add(const char *path, v9fs_test_fn fn) -{ - qtest_add_data_func(path, fn, v9fs_run_pci_test); + qos_add_test("config", "virtio-9p", pci_config, NULL); + qos_add_test("fs/version/basic", "virtio-9p", fs_version, NULL); + qos_add_test("fs/attach/basic", "virtio-9p", fs_attach, NULL); + qos_add_test("fs/walk/basic", "virtio-9p", fs_walk, NULL); + qos_add_test("fs/walk/no_slash", "virtio-9p", fs_walk_no_slash, + NULL); + qos_add_test("fs/walk/dotdot_from_root", "virtio-9p", + fs_walk_dotdot, NULL); + qos_add_test("fs/lopen/basic", "virtio-9p", fs_lopen, NULL); + qos_add_test("fs/write/basic", "virtio-9p", fs_write, NULL); + qos_add_test("fs/flush/success", "virtio-9p", fs_flush_success, + NULL); + qos_add_test("fs/flush/ignored", "virtio-9p", fs_flush_ignored, + NULL); } -int main(int argc, char **argv) -{ - g_test_init(&argc, &argv, NULL); - v9fs_qtest_pci_add("/virtio/9p/pci/nop", NULL); - v9fs_qtest_pci_add("/virtio/9p/pci/config", pci_config); - v9fs_qtest_pci_add("/virtio/9p/pci/fs/version/basic", fs_version); - v9fs_qtest_pci_add("/virtio/9p/pci/fs/attach/basic", fs_attach); - v9fs_qtest_pci_add("/virtio/9p/pci/fs/walk/basic", fs_walk); - v9fs_qtest_pci_add("/virtio/9p/pci/fs/walk/no_slash", fs_walk_no_slash); - v9fs_qtest_pci_add("/virtio/9p/pci/fs/walk/dotdot_from_root", - fs_walk_dotdot); - v9fs_qtest_pci_add("/virtio/9p/pci/fs/lopen/basic", fs_lopen); - v9fs_qtest_pci_add("/virtio/9p/pci/fs/write/basic", fs_write); - v9fs_qtest_pci_add("/virtio/9p/pci/fs/flush/success", fs_flush_success); - v9fs_qtest_pci_add("/virtio/9p/pci/fs/flush/ignored", fs_flush_ignored); - - return g_test_run(); -} +libqos_init(register_virtio_9p_test);