From nobody Mon Feb 9 18:47:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1666612570; cv=none; d=zohomail.com; s=zohoarc; b=VcARpvpDGrlksV+fBbfyNBQydnAnQhwVkFo72ahpYt4A6xO6Zj6dd0lzpbyXhUTu2gRyO4RYMP/j37wJ9INtf3EJixE3ZX38+PPwDVJ3CkKnnPaWS16qekC8J4jki8SP/7NVWsiVoWMeGjoKJyWKarkK/jHcQlEzusjMXbx7QXs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666612570; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=XC8UVl5vRCl7diWbPgGipvNeEWETBhkDQgpl1FpLEJc=; b=Mo/ziO7+RryMN/3PfKvbUXrVGa1shM0gkv+XzfENfXgTJ6iFs4FWn3dBJCpd3xMIhybiO/lWmoXOmE/sTiC7YdZc00IFZxd/36QDzn6+ohhtLTyXjsisPqN+7gIidjoplFyJ9Mw3vsLiA2lZmX2tzDsY/BuOdSpPwcVHq0F8GUg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 166661257042778.74899725965395; Mon, 24 Oct 2022 04:56:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1omvMm-0000jE-Ft; Mon, 24 Oct 2022 07:11:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <1ebacc40ca925626cf601543326066434c7c1a7f@lizzy.crudebyte.com>) id 1omvMP-0000Y0-GW for qemu-devel@nongnu.org; Mon, 24 Oct 2022 07:11:21 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <1ebacc40ca925626cf601543326066434c7c1a7f@lizzy.crudebyte.com>) id 1omvMI-000737-Gp for qemu-devel@nongnu.org; Mon, 24 Oct 2022 07:11:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=XC8UVl5vRCl7diWbPgGipvNeEWETBhkDQgpl1FpLEJc=; b=A09jG 3UIx9N24tjlLIa2IOiz/JTqM0e/b2d+KewY8GNDO/N9Ws+3WZyqEPhaUr2BtURZHI36Wv5jBTkdUm uk6C8zWbpESjzDVAWB9tc8c+QNDfcVr6Be6Vprw8hL4sN7m+cTTrM0Ozm17DrfTJZh5JaBccthaWd Dd2HWwgJrPksh+2nz7OcRHQ5cYJka3vnHDfYG5Mn3T0jcNhmSxQsjCUrxDhRvrgJ8tIU8432VBJOj PjlWVttkbLwsYeA7VVcUPcEE3Pd3hF7IXGk9djeOagcsJKYvy7DJnYJyovxLA+l/4Eh5eOdCK13J2 p7UzrKK7GbZ+FJF/EUOGk3Gkd1jWw==; Message-Id: <1ebacc40ca925626cf601543326066434c7c1a7f.1666608862.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Mon, 24 Oct 2022 12:54:23 +0200 Subject: [PULL 11/23] tests/9p: convert v9fs_treaddir() to declarative arguments To: qemu-devel@nongnu.org, Stefan Hajnoczi Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=1ebacc40ca925626cf601543326066434c7c1a7f@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1666612571940100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Use declarative function arguments for function v9fs_treaddir(). Signed-off-by: Christian Schoenebeck Message-Id: --- tests/qtest/libqos/virtio-9p-client.c | 32 ++++++++++++++++++++------ tests/qtest/libqos/virtio-9p-client.h | 33 +++++++++++++++++++++++++-- tests/qtest/virtio-9p-test.c | 11 +++++++-- 3 files changed, 65 insertions(+), 11 deletions(-) diff --git a/tests/qtest/libqos/virtio-9p-client.c b/tests/qtest/libqos/vir= tio-9p-client.c index 29916a23b5..047c8993b6 100644 --- a/tests/qtest/libqos/virtio-9p-client.c +++ b/tests/qtest/libqos/virtio-9p-client.c @@ -557,17 +557,35 @@ void v9fs_rgetattr(P9Req *req, v9fs_attr *attr) } =20 /* size[4] Treaddir tag[2] fid[4] offset[8] count[4] */ -P9Req *v9fs_treaddir(QVirtio9P *v9p, uint32_t fid, uint64_t offset, - uint32_t count, uint16_t tag) +TReadDirRes v9fs_treaddir(TReadDirOpt opt) { P9Req *req; + uint32_t err; =20 - req =3D v9fs_req_init(v9p, 4 + 8 + 4, P9_TREADDIR, tag); - v9fs_uint32_write(req, fid); - v9fs_uint64_write(req, offset); - v9fs_uint32_write(req, count); + g_assert(opt.client); + /* expecting either Rreaddir or Rlerror, but obviously not both */ + g_assert(!opt.expectErr || !(opt.rreaddir.count || + opt.rreaddir.nentries || opt.rreaddir.entries)); + + req =3D v9fs_req_init(opt.client, 4 + 8 + 4, P9_TREADDIR, opt.tag); + v9fs_uint32_write(req, opt.fid); + v9fs_uint64_write(req, opt.offset); + v9fs_uint32_write(req, opt.count); v9fs_req_send(req); - return req; + + if (!opt.requestOnly) { + v9fs_req_wait_for_reply(req, NULL); + if (opt.expectErr) { + v9fs_rlerror(req, &err); + g_assert_cmpint(err, =3D=3D, opt.expectErr); + } else { + v9fs_rreaddir(req, opt.rreaddir.count, opt.rreaddir.nentries, + opt.rreaddir.entries); + } + req =3D NULL; /* request was freed */ + } + + return (TReadDirRes) { .req =3D req }; } =20 /* size[4] Rreaddir tag[2] count[4] data[count] */ diff --git a/tests/qtest/libqos/virtio-9p-client.h b/tests/qtest/libqos/vir= tio-9p-client.h index f7b1bfc79a..2bf649085f 100644 --- a/tests/qtest/libqos/virtio-9p-client.h +++ b/tests/qtest/libqos/virtio-9p-client.h @@ -182,6 +182,36 @@ typedef struct TGetAttrRes { P9Req *req; } TGetAttrRes; =20 +/* options for 'Treaddir' 9p request */ +typedef struct TReadDirOpt { + /* 9P client being used (mandatory) */ + QVirtio9P *client; + /* user supplied tag number being returned with response (optional) */ + uint16_t tag; + /* file ID of directory whose entries shall be retrieved (required) */ + uint32_t fid; + /* offset in entries stream, i.e. for multiple requests (optional) */ + uint64_t offset; + /* maximum bytes to be returned by server (required) */ + uint32_t count; + /* data being received from 9p server as 'Rreaddir' response (optional= ) */ + struct { + uint32_t *count; + uint32_t *nentries; + struct V9fsDirent **entries; + } rreaddir; + /* only send Treaddir request but not wait for a reply? (optional) */ + bool requestOnly; + /* do we expect an Rlerror response, if yes which error code? (optiona= l) */ + uint32_t expectErr; +} TReadDirOpt; + +/* result of 'Treaddir' 9p request */ +typedef struct TReadDirRes { + /* if requestOnly was set: request object for further processing */ + P9Req *req; +} TReadDirRes; + void v9fs_set_allocator(QGuestAllocator *t_alloc); void v9fs_memwrite(P9Req *req, const void *addr, size_t len); void v9fs_memskip(P9Req *req, size_t len); @@ -211,8 +241,7 @@ TWalkRes v9fs_twalk(TWalkOpt opt); void v9fs_rwalk(P9Req *req, uint16_t *nwqid, v9fs_qid **wqid); TGetAttrRes v9fs_tgetattr(TGetAttrOpt); void v9fs_rgetattr(P9Req *req, v9fs_attr *attr); -P9Req *v9fs_treaddir(QVirtio9P *v9p, uint32_t fid, uint64_t offset, - uint32_t count, uint16_t tag); +TReadDirRes v9fs_treaddir(TReadDirOpt); void v9fs_rreaddir(P9Req *req, uint32_t *count, uint32_t *nentries, struct V9fsDirent **entries); void v9fs_free_dirents(struct V9fsDirent *e); diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index ae1220d0cb..e5c174c218 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -20,6 +20,7 @@ #define tversion(...) v9fs_tversion((TVersionOpt) __VA_ARGS__) #define tattach(...) v9fs_tattach((TAttachOpt) __VA_ARGS__) #define tgetattr(...) v9fs_tgetattr((TGetAttrOpt) __VA_ARGS__) +#define treaddir(...) v9fs_treaddir((TReadDirOpt) __VA_ARGS__) =20 static void pci_config(void *obj, void *data, QGuestAllocator *t_alloc) { @@ -119,7 +120,10 @@ static void fs_readdir(void *obj, void *data, QGuestAl= locator *t_alloc) /* * submit count =3D msize - 11, because 11 is the header size of Rread= dir */ - req =3D v9fs_treaddir(v9p, 1, 0, P9_MAX_SIZE - 11, 0); + req =3D treaddir({ + .client =3D v9p, .fid =3D 1, .offset =3D 0, .count =3D P9_MAX_SIZE= - 11, + .requestOnly =3D true + }).req; v9fs_req_wait_for_reply(req, NULL); v9fs_rreaddir(req, &count, &nentries, &entries); =20 @@ -186,7 +190,10 @@ static void do_readdir_split(QVirtio9P *v9p, uint32_t = count) npartialentries =3D 0; partialentries =3D NULL; =20 - req =3D v9fs_treaddir(v9p, fid, offset, count, 0); + req =3D treaddir({ + .client =3D v9p, .fid =3D fid, .offset =3D offset, .count =3D = count, + .requestOnly =3D true + }).req; v9fs_req_wait_for_reply(req, NULL); v9fs_rreaddir(req, &count, &npartialentries, &partialentries); if (npartialentries > 0 && partialentries) { --=20 2.30.2