From nobody Tue Feb 10 20:07:29 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1516751079157431.9295398412985; Tue, 23 Jan 2018 15:44:39 -0800 (PST) Received: from localhost ([::1]:33811 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ee8F3-0005I5-DW for importer@patchew.org; Tue, 23 Jan 2018 18:44:37 -0500 Received: from eggs.gnu.org ([208.118.235.92]:33736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ee8A3-0001aP-KL for qemu-devel@nongnu.org; Tue, 23 Jan 2018 18:39:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ee89w-0006UW-NN for qemu-devel@nongnu.org; Tue, 23 Jan 2018 18:39:27 -0500 Received: from 7.mo68.mail-out.ovh.net ([46.105.63.230]:58398) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ee89w-0006Sd-AH for qemu-devel@nongnu.org; Tue, 23 Jan 2018 18:39:20 -0500 Received: from player698.ha.ovh.net (b7.ovh.net [213.186.33.57]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id 800ABB9C78 for ; Wed, 24 Jan 2018 00:39:18 +0100 (CET) Received: from bahia.lan (lns-bzn-46-82-253-208-248.adsl.proxad.net [82.253.208.248]) (Authenticated sender: groug@kaod.org) by player698.ha.ovh.net (Postfix) with ESMTPA id 2DE245200A3; Wed, 24 Jan 2018 00:39:14 +0100 (CET) From: Greg Kurz To: qemu-devel@nongnu.org Date: Wed, 24 Jan 2018 00:39:14 +0100 Message-ID: <151675075407.29381.15200950476480101972.stgit@bahia.lan> In-Reply-To: <151675071042.29381.16225631028845063799.stgit@bahia.lan> References: <151675071042.29381.16225631028845063799.stgit@bahia.lan> User-Agent: StGit/0.17.1-46-g6855-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 14386186060419996110 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtvddrudehgddugecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.63.230 Subject: [Qemu-devel] [PATCH 4/7] tests: virtio-9p: add LOPEN operation test 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: Paolo Bonzini , Jason Wang , Fam Zheng , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Trivial test of a successful open. Signed-off-by: Greg Kurz --- hw/9pfs/9p-synth.c | 5 +++++ hw/9pfs/9p-synth.h | 1 + tests/virtio-9p-test.c | 47 ++++++++++++++++++++++++++++++++++++++++++++= +++ 3 files changed, 53 insertions(+) diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c index dcbd320da17a..f17b74f44461 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -541,6 +541,11 @@ static int synth_init(FsContext *ctx, Error **errp) assert(!ret); g_free(name); } + + /* File for LOPEN test */ + ret =3D qemu_v9fs_synth_add_file(NULL, 0, QTEST_V9FS_SYNTH_LOPEN_F= ILE, + NULL, NULL, ctx); + assert(!ret); } =20 return 0; diff --git a/hw/9pfs/9p-synth.h b/hw/9pfs/9p-synth.h index 876b4ef58288..2a8d6fd00d69 100644 --- a/hw/9pfs/9p-synth.h +++ b/hw/9pfs/9p-synth.h @@ -52,5 +52,6 @@ int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int m= ode, /* qtest stuff */ =20 #define QTEST_V9FS_SYNTH_WALK_FILE "WALK%d" +#define QTEST_V9FS_SYNTH_LOPEN_FILE "LOPEN" =20 #endif diff --git a/tests/virtio-9p-test.c b/tests/virtio-9p-test.c index 652198156731..6ba782e24f3a 100644 --- a/tests/virtio-9p-test.c +++ b/tests/virtio-9p-test.c @@ -238,6 +238,7 @@ static const char *rmessage_name(uint8_t id) id =3D=3D P9_RVERSION ? "RVERSION" : id =3D=3D P9_RATTACH ? "RATTACH" : id =3D=3D P9_RWALK ? "RWALK" : + id =3D=3D P9_RLOPEN ? "RLOPEN" : ""; } =20 @@ -389,6 +390,34 @@ static void v9fs_rwalk(P9Req *req, uint16_t *nwqid, v9= fs_qid **wqid) v9fs_req_free(req); } =20 +/* size[4] Tlopen tag[2] fid[4] flags[4] */ +static P9Req *v9fs_tlopen(QVirtIO9P *v9p, uint32_t fid, uint32_t flags, + uint16_t tag) +{ + P9Req *req; + + req =3D v9fs_req_init(v9p, 4 + 4, P9_TLOPEN, tag); + v9fs_uint32_write(req, fid); + v9fs_uint32_write(req, flags); + v9fs_req_send(req); + return req; +} + +/* size[4] Rlopen tag[2] qid[13] iounit[4] */ +static void v9fs_rlopen(P9Req *req, v9fs_qid *qid, uint32_t *iounit) +{ + v9fs_req_recv(req, P9_RLOPEN); + if (qid) { + v9fs_memread(req, qid, 13); + } else { + v9fs_memskip(req, 13); + } + if (iounit) { + v9fs_uint32_read(req, iounit); + } + v9fs_req_free(req); +} + static void fs_version(QVirtIO9P *v9p) { const char *version =3D "9P2000.L"; @@ -478,6 +507,23 @@ static void fs_walk_dotdot(QVirtIO9P *v9p) g_free(wnames[0]); } =20 +static void fs_lopen(QVirtIO9P *v9p) +{ + char *const wnames[] =3D { g_strdup(QTEST_V9FS_SYNTH_LOPEN_FILE) }; + P9Req *req; + + fs_attach(v9p); + req =3D v9fs_twalk(v9p, 0, 1, 1, wnames, 0); + v9fs_req_wait_for_reply(req); + v9fs_rwalk(req, NULL, NULL); + + req =3D v9fs_tlopen(v9p, 1, O_WRONLY, 0); + v9fs_req_wait_for_reply(req); + v9fs_rlopen(req, NULL, NULL); + + g_free(wnames[0]); +} + typedef void (*v9fs_test_fn)(QVirtIO9P *v9p); =20 static void v9fs_run_pci_test(gconstpointer data) @@ -507,6 +553,7 @@ int main(int argc, char **argv) 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); =20 return g_test_run(); }