From nobody Wed Nov 5 10:45:07 2025 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; dkim=fail; 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=gmail.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1534156645261871.2857104588969; Mon, 13 Aug 2018 03:37:25 -0700 (PDT) Received: from localhost ([::1]:38680 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fpADs-0002cD-RY for importer@patchew.org; Mon, 13 Aug 2018 06:37:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44168) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fp9tO-0007n4-SA for qemu-devel@nongnu.org; Mon, 13 Aug 2018 06:16:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fp9tM-0002oV-Nx for qemu-devel@nongnu.org; Mon, 13 Aug 2018 06:16:06 -0400 Received: from mail-ed1-x543.google.com ([2a00:1450:4864:20::543]:36078) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fp9tM-0002nx-BN; Mon, 13 Aug 2018 06:16:04 -0400 Received: by mail-ed1-x543.google.com with SMTP id k15-v6so7957663edr.3; Mon, 13 Aug 2018 03:16:04 -0700 (PDT) Received: from localhost.localdomain ([194.230.159.125]) by smtp.gmail.com with ESMTPSA id s27-v6sm11670006edb.73.2018.08.13.03.16.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Aug 2018 03:16:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NEPouckqfONQecFq+NoXjSHQjHkaxCCMa/Ith1x6jd4=; b=AwVxEfzufafcP5FO/QnP7bzJKWqESdoyTV7T3yXvCtSHr9KKr5Aq+P78g5ss7JaIBq 8vcTIFuNTmtOsMytgHNHMf+tukmZsCKToq90NFxRV779XEfV3ncRRzjKANfPeeKs2oza 5iSKt70zSlNLm3zyShMmTRrT6rRboHmVxXUAg6SWJfW5dDOgqKSohnov2g0WbLWUv0lt icgtD6GXKj6mP6VJKfH25KOhvMxvC92obix4sD03ZACQSTTs/BulDRwmLKCTvEpFh0jW V8l5xOGTupDZSpY2TE6rX/O3avtQ/6Gf3BHojsO6ESIciMPMneysJ8E9EgIo2y39+GI4 ewSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NEPouckqfONQecFq+NoXjSHQjHkaxCCMa/Ith1x6jd4=; b=mIIieJSwe8PwfOtAYKgveLiuQsy0cs3X9gYk4jO5yMNEHLEMgHbMXFQ+3r+plnbhKN 1qvQ5JxI6rFu1YdIR0BotSIW+Yt7flvhi5oFHTfmfLUrKdB4KdRdAjuohGngd/MQb4UW ewolOW92HxTdrfHXZBj0TUC2n9+Fivvsq/dHpTZUY9mSYPKHflB6ALyDPvHejL9v5xmX 34tO0YSAEYD5DRloq8W/4P4sMAKLrzHVmjAMK1Z7akOixeqbaNq4eYSNs4fCkf6FpTY+ 6ziGCgQOn+eB7Hrh7uyD3vlcBxigy14SJibFirl/1mAMz5O31Mq9XKJLGuUYqJZPjkwL miKg== X-Gm-Message-State: AOUpUlF8Zr5KpbqDlG/WGmYhs1Vw8b4IZHQ3j6Ce4NDlvPiRSTsewglx JDpIG3Ing+2odzLsyQUdZq0pupclgPg= X-Google-Smtp-Source: AA+uWPxEREVXrtd+oiBtuTtnN50nBULwf4/r+/AdR+AzqnQFQuwad114revSSngbBHnOtv8WHAgPSg== X-Received: by 2002:a50:f5e8:: with SMTP id x37-v6mr21243503edm.132.1534155362885; Mon, 13 Aug 2018 03:16:02 -0700 (PDT) From: Emanuele Giuseppe Esposito To: qemu-devel@nongnu.org Date: Mon, 13 Aug 2018 12:14:42 +0200 Message-Id: <20180813101453.10200-23-e.emanuelegiuseppe@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180813101453.10200-1-e.emanuelegiuseppe@gmail.com> References: <20180813101453.10200-1-e.emanuelegiuseppe@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::543 Subject: [Qemu-devel] [PATCH 22/33] tests/qgraph: 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: Laurent Vivier , Fam Zheng , qemu-block@nongnu.org, "Michael S. Tsirkin" , Jason Wang , Amit Shah , Emanuele Giuseppe Esposito , Alexander Graf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Greg Kurz , qemu-ppc@nongnu.org, Gerd Hoffmann , Stefan Hajnoczi , Paolo Bonzini , John Snow , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add qgraph nodes for virtio-9p-pci and virtio-9p-device. Both nodes produce virtio-9p, but virtio-9p-pci receives a pci-bus and uses virtio-pci QOSGraphObject and functions, while virtio-9p-device receives a virtio and implements its own functions Signed-off-by: Emanuele Giuseppe Esposito --- tests/Makefile.include | 3 +- tests/virtio-9p-test.c | 219 +++++++++++++++-------------------------- 2 files changed, 82 insertions(+), 140 deletions(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index 48d3aab447..495ff5ca9b 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -201,7 +201,6 @@ gcov-files-virtio-y +=3D hw/virtio/virtio-rng.c check-qtest-virtio-y +=3D tests/virtio-scsi-test$(EXESUF) gcov-files-virtio-y +=3D i386-softmmu/hw/scsi/virtio-scsi.c ifeq ($(CONFIG_VIRTIO)$(CONFIG_VIRTFS)$(CONFIG_PCI),yyy) -check-qtest-virtio-y +=3D tests/virtio-9p-test$(EXESUF) gcov-files-virtio-y +=3D hw/9pfs/virtio-9p.c gcov-files-virtio-y +=3D i386-softmmu/hw/9pfs/virtio-9p-device.c endif @@ -783,6 +782,7 @@ libqgraph-tests-obj-y +=3D tests/sdhci-test.o libqgraph-tests-obj-y +=3D tests/e1000e-test.o libqgraph-tests-obj-y +=3D tests/virtio-serial-test.o libqgraph-tests-obj-y +=3D tests/virtio-console-test.o +libqgraph-tests-obj-y +=3D tests/virtio-9p-test.o =20 check-unit-y +=3D tests/test-qgraph$(EXESUF) tests/test-qgraph$(EXESUF): tests/test-qgraph.o $(libqgraph-obj-y) @@ -831,7 +831,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 d275c74106..7a80c1d785 100644 --- a/tests/virtio-9p-test.c +++ b/tests/virtio-9p-test.c @@ -9,99 +9,36 @@ =20 #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" =20 #define QVIRTIO_9P_TIMEOUT_US (10 * 1000 * 1000) +static QGuestAllocator *alloc; =20 -static const char mount_tag[] =3D "qtest"; - -typedef struct { - QVirtioDevice *dev; - QOSState *qs; - QVirtQueue *vq; -} QVirtIO9P; - -static QVirtIO9P *qvirtio_9p_start(const char *driver) -{ - const char *arch =3D qtest_get_arch(); - const char *cmd =3D "-fsdev synth,id=3Dfsdev0 " - "-device %s,fsdev=3Dfsdev0,mount_tag=3D%s"; - QVirtIO9P *v9p =3D g_new0(QVirtIO9P, 1); - - if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { - v9p->qs =3D qtest_pc_boot(cmd, driver, mount_tag); - } else if (strcmp(arch, "ppc64") =3D=3D 0) { - v9p->qs =3D 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 =3D 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 =3D qvirtio_9p_start("virtio-9p-pci"); - QVirtioPCIDevice *dev =3D qvirtio_pci_device_find(v9p->qs->pcibus, - VIRTIO_ID_9P); - g_assert_nonnull(dev); - g_assert_cmphex(dev->vdev.device_type, =3D=3D, VIRTIO_ID_9P); - v9p->dev =3D (QVirtioDevice *) dev; - - qvirtio_pci_device_enable(dev); - qvirtio_start_device(v9p->dev); - - v9p->vq =3D qvirtqueue_setup(v9p->dev, v9p->qs->alloc, 0); - - qvirtio_set_driver_ok(v9p->dev); - - return v9p; -} - -static void qvirtio_9p_pci_stop(QVirtIO9P *v9p) +static void pci_config(void *obj, void *data, QGuestAllocator *t_alloc) { - qvirtqueue_cleanup(v9p->dev->bus, v9p->vq, v9p->qs->alloc); - qvirtio_pci_device_disable(container_of(v9p->dev, QVirtioPCIDevice, vd= ev)); - qvirtio_pci_device_free((QVirtioPCIDevice *)v9p->dev); - qvirtio_9p_stop(v9p); -} - -static void pci_config(QVirtIO9P *v9p) -{ - size_t tag_len =3D qvirtio_config_readw(v9p->dev, 0); + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; + size_t tag_len =3D qvirtio_config_readw(v9p->vdev, 0); char *tag; int i; =20 - g_assert_cmpint(tag_len, =3D=3D, strlen(mount_tag)); + g_assert_cmpint(tag_len, =3D=3D, strlen(MOUNT_TAG)); =20 tag =3D g_malloc(tag_len); for (i =3D 0; i < tag_len; i++) { - tag[i] =3D qvirtio_config_readb(v9p->dev, i + 2); + tag[i] =3D 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); } =20 #define P9_MAX_SIZE 4096 /* Max size of a T-message or R-message */ =20 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; =20 -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 =3D g_new0(P9Req, 1); @@ -222,7 +159,7 @@ static P9Req *v9fs_req_init(QVirtIO9P *v9p, uint32_t si= ze, uint8_t id, =20 req->v9p =3D v9p; req->t_size =3D total_size; - req->t_msg =3D guest_alloc(v9p->qs->alloc, req->t_size); + req->t_msg =3D guest_alloc(alloc, req->t_size); v9fs_memwrite(req, &hdr, 7); req->tag =3D tag; return req; @@ -230,13 +167,13 @@ static P9Req *v9fs_req_init(QVirtIO9P *v9p, uint32_t = size, uint8_t id, =20 static void v9fs_req_send(P9Req *req) { - QVirtIO9P *v9p =3D req->v9p; + QVirtio9P *v9p =3D req->v9p; =20 - req->r_msg =3D guest_alloc(v9p->qs->alloc, P9_MAX_SIZE); + req->r_msg =3D guest_alloc(alloc, P9_MAX_SIZE); req->free_head =3D qvirtqueue_add(v9p->vq, req->t_msg, req->t_size, fa= lse, 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 =3D 0; } =20 @@ -255,9 +192,9 @@ static const char *rmessage_name(uint8_t id) =20 static void v9fs_req_wait_for_reply(P9Req *req, uint32_t *len) { - QVirtIO9P *v9p =3D req->v9p; + QVirtio9P *v9p =3D req->v9p; =20 - 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); } =20 @@ -288,10 +225,8 @@ static void v9fs_req_recv(P9Req *req, uint8_t id) =20 static void v9fs_req_free(P9Req *req) { - QVirtIO9P *v9p =3D 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); } =20 @@ -304,7 +239,7 @@ static void v9fs_rlerror(P9Req *req, uint32_t *err) } =20 /* size[4] Tversion tag[2] msize[4] version[s] */ -static P9Req *v9fs_tversion(QVirtIO9P *v9p, uint32_t msize, const char *ve= rsion, +static P9Req *v9fs_tversion(QVirtio9P *v9p, uint32_t msize, const char *ve= rsion, uint16_t tag) { P9Req *req; @@ -339,7 +274,7 @@ static void v9fs_rversion(P9Req *req, uint16_t *len, ch= ar **version) } =20 /* 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 =3D ""; /* ignored by QEMU */ @@ -368,7 +303,7 @@ static void v9fs_rattach(P9Req *req, v9fs_qid *qid) } =20 /* 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 t= ag) { P9Req *req; @@ -410,7 +345,7 @@ static void v9fs_rwalk(P9Req *req, uint16_t *nwqid, v9f= s_qid **wqid) } =20 /* 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, uint= 32_t *iounit) } =20 /* 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) } =20 /* 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; =20 @@ -483,8 +418,10 @@ static void v9fs_rflush(P9Req *req) v9fs_req_free(req); } =20 -static void fs_version(QVirtIO9P *v9p) +static void fs_version(void *obj, void *data, QGuestAllocator *t_alloc) { + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; const char *version =3D "9P2000.L"; uint16_t server_len; char *server_version; @@ -499,18 +436,22 @@ static void fs_version(QVirtIO9P *v9p) g_free(server_version); } =20 -static void fs_attach(QVirtIO9P *v9p) +static void fs_attach(void *obj, void *data, QGuestAllocator *t_alloc) { + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; P9Req *req; =20 - fs_version(v9p); + fs_version(v9p, NULL, t_alloc); req =3D v9fs_tattach(v9p, 0, getuid(), 0); v9fs_req_wait_for_reply(req, NULL); v9fs_rattach(req, NULL); } =20 -static void fs_walk(QVirtIO9P *v9p) +static void fs_walk(void *obj, void *data, QGuestAllocator *t_alloc) { + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; char *wnames[P9_MAXWELEM]; uint16_t nwqid; v9fs_qid *wqid; @@ -521,7 +462,7 @@ static void fs_walk(QVirtIO9P *v9p) wnames[i] =3D g_strdup_printf(QTEST_V9FS_SYNTH_WALK_FILE, i); } =20 - fs_attach(v9p); + fs_attach(v9p, NULL, t_alloc); req =3D 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); } =20 -static void fs_walk_no_slash(QVirtIO9P *v9p) +static void fs_walk_no_slash(void *obj, void *data, QGuestAllocator *t_all= oc) { + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; char *const wnames[] =3D { g_strdup(" /") }; P9Req *req; uint32_t err; =20 - fs_attach(v9p); + fs_attach(v9p, NULL, t_alloc); req =3D 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]); } =20 -static void fs_walk_dotdot(QVirtIO9P *v9p) +static void fs_walk_dotdot(void *obj, void *data, QGuestAllocator *t_alloc) { + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; char *const wnames[] =3D { g_strdup("..") }; v9fs_qid root_qid, *wqid; P9Req *req; =20 - fs_version(v9p); + fs_version(v9p, NULL, t_alloc); req =3D 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]); } =20 -static void fs_lopen(QVirtIO9P *v9p) +static void fs_lopen(void *obj, void *data, QGuestAllocator *t_alloc) { + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; char *const wnames[] =3D { g_strdup(QTEST_V9FS_SYNTH_LOPEN_FILE) }; P9Req *req; =20 - fs_attach(v9p); + fs_attach(v9p, NULL, t_alloc); req =3D 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]); } =20 -static void fs_write(QVirtIO9P *v9p) +static void fs_write(void *obj, void *data, QGuestAllocator *t_alloc) { + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; static const uint32_t write_count =3D P9_MAX_SIZE / 2; char *const wnames[] =3D { g_strdup(QTEST_V9FS_SYNTH_WRITE_FILE) }; char *buf =3D g_malloc0(write_count); uint32_t count; P9Req *req; =20 - fs_attach(v9p); + fs_attach(v9p, NULL, t_alloc); req =3D 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]); } =20 -static void fs_flush_success(QVirtIO9P *v9p) +static void fs_flush_success(void *obj, void *data, QGuestAllocator *t_all= oc) { + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; char *const wnames[] =3D { g_strdup(QTEST_V9FS_SYNTH_FLUSH_FILE) }; P9Req *req, *flush_req; uint32_t reply_len; uint8_t should_block; =20 - fs_attach(v9p); + fs_attach(v9p, NULL, t_alloc); req =3D 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]); } =20 -static void fs_flush_ignored(QVirtIO9P *v9p) +static void fs_flush_ignored(void *obj, void *data, QGuestAllocator *t_all= oc) { + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; char *const wnames[] =3D { g_strdup(QTEST_V9FS_SYNTH_FLUSH_FILE) }; P9Req *req, *flush_req; uint32_t count; uint8_t should_block; =20 - fs_attach(v9p); + fs_attach(v9p, NULL, t_alloc); req =3D v9fs_twalk(v9p, 0, 1, 1, wnames, 0); v9fs_req_wait_for_reply(req, NULL); v9fs_rwalk(req, NULL, NULL); @@ -685,39 +638,29 @@ static void fs_flush_ignored(QVirtIO9P *v9p) g_free(wnames[0]); } =20 -typedef void (*v9fs_test_fn)(QVirtIO9P *v9p); - -static void v9fs_run_pci_test(gconstpointer data) +static void virtio_nop(void *obj, void *data, QGuestAllocator *t_alloc) { - v9fs_test_fn fn =3D data; - QVirtIO9P *v9p =3D qvirtio_9p_pci_start(); - - if (fn) { - fn(v9p); - } - qvirtio_9p_pci_stop(v9p); + /* no operation */ } =20 -static void v9fs_qtest_pci_add(const char *path, v9fs_test_fn fn) -{ - qtest_add_data_func(path, fn, v9fs_run_pci_test); -} =20 -int main(int argc, char **argv) +static void register_virtio_9p_test(void) { - 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(); + qos_add_test("virtio-9p-nop", "virtio-9p", virtio_nop, NULL); + qos_add_test("virtio-9p-config", "virtio-9p", pci_config, NULL); + qos_add_test("virtio-9p-fs/version/basic", "virtio-9p", fs_version, NU= LL); + qos_add_test("virtio-9p-fs/attach/basic", "virtio-9p", fs_attach, NULL= ); + qos_add_test("virtio-9p-fs/walk/basic", "virtio-9p", fs_walk, NULL); + qos_add_test("virtio-9p-fs/walk/no_slash", "virtio-9p", fs_walk_no_sla= sh, + NULL); + qos_add_test("virtio-9p-fs/walk/dotdot_from_root", "virtio-9p", + fs_walk_dotdot, NULL); + qos_add_test("virtio-9p-fs/lopen/basic", "virtio-9p", fs_lopen, NULL); + qos_add_test("virtio-9p-fs/write/basic", "virtio-9p", fs_write, NULL); + qos_add_test("virtio-9p-fs/flush/success", "virtio-9p", fs_flush_succe= ss, + NULL); + qos_add_test("virtio-9p-fs/flush/ignored", "virtio-9p", fs_flush_ignor= ed, + NULL); } + +libqos_init(register_virtio_9p_test); --=20 2.17.1