From nobody Tue Feb 10 03:16:14 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=1666610380; cv=none; d=zohomail.com; s=zohoarc; b=BtMq64Gax0daWITKV9UGF91/11Qu4Rj6pXuCEl15dtShYK/WMKtPIrDLhALFsyYAjNii7bMq+2sOF4oc66tFPVrAHyfly8l1T63P2zMd+KB8dBV/bgjW+/mGlVo0NjQ3bqpOPNraKPuJqkfrjYHteFDGMqUVggXB1axKeFZ4QR8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666610380; 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=fqOvxrtxl0kAozVZf8lzZQlTXEjT9vupeLsdMhmgBW8=; b=a9I3qgw5qarJoSD3tgpFz1lbfUi1uIuY+CVVbnuQc4X1QFraYpqMuOG3C7bEKaFi8vkSHMBkWwS5paDZ8dH0OQCOUqOhh9dfOeMNYBoyethRKFTguQJtt9HidMjr2VacOacpX+n0WfCxi2LBlGNArulvxukieT/Utm2oRAYvaFk= 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 1666610380310388.5648232397343; Mon, 24 Oct 2022 04:19:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1omvNn-0001Ec-JO; Mon, 24 Oct 2022 07:12:39 -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 <43e0d9fb358b01539d0de9494208e80ff84b5456@lizzy.crudebyte.com>) id 1omvNi-0001Cs-Au for qemu-devel@nongnu.org; Mon, 24 Oct 2022 07:12:37 -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 <43e0d9fb358b01539d0de9494208e80ff84b5456@lizzy.crudebyte.com>) id 1omvNX-0007lX-6P for qemu-devel@nongnu.org; Mon, 24 Oct 2022 07:12:34 -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=fqOvxrtxl0kAozVZf8lzZQlTXEjT9vupeLsdMhmgBW8=; b=Jpmvw XV0IOfnqLeLszvCVFKfv+NF4yJaBfhe5Wh1H+wFWC4LImaSP53nD1Z+hB/NAB7DmhWDTu53xO7dtj xw6XEPEgVw2FdZbgxak6+5ZjJuetEo4kS4xfinM42KIdl5olrQBXWXTmiJiIU/z0feInHP0DBNwO2 qXNmdLcCp7NI6exwJZQ465OKlIywC/lANK6CqX7AiiM/NbOGnRBGGtLIpj3IWsUCpovtQF9fZaJLg 2CwVp4Mz3a9Z3l5a1fRSgvlfmFp+bqvqRoNOjQPTOQ1r2RXVRJlpJUlURYS3TWaFy25BDyGUS1dPW myiIBefD0i+/uiyCYsEbn469HIgrA==; Message-Id: <43e0d9fb358b01539d0de9494208e80ff84b5456.1666608862.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Mon, 24 Oct 2022 12:54:23 +0200 Subject: [PULL 22/23] tests/9p: merge v9fs_tunlinkat() and do_unlinkat() 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=43e0d9fb358b01539d0de9494208e80ff84b5456@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham 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: 1666610382219100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" As with previous patches, unify those 2 functions into a single function v9fs_tunlinkat() by using a declarative function arguments approach. Signed-off-by: Christian Schoenebeck Message-Id: <1dea593edd464908d92501933c068388c01f1744.1664917004.git.qemu_o= ss@crudebyte.com> --- tests/qtest/libqos/virtio-9p-client.c | 37 +++++++++++++++++++++------ tests/qtest/libqos/virtio-9p-client.h | 29 +++++++++++++++++++-- tests/qtest/virtio-9p-test.c | 26 ++++++------------- 3 files changed, 64 insertions(+), 28 deletions(-) diff --git a/tests/qtest/libqos/virtio-9p-client.c b/tests/qtest/libqos/vir= tio-9p-client.c index a2770719b9..e017e030ec 100644 --- a/tests/qtest/libqos/virtio-9p-client.c +++ b/tests/qtest/libqos/virtio-9p-client.c @@ -1004,23 +1004,44 @@ void v9fs_rlink(P9Req *req) } =20 /* size[4] Tunlinkat tag[2] dirfd[4] name[s] flags[4] */ -P9Req *v9fs_tunlinkat(QVirtio9P *v9p, uint32_t dirfd, const char *name, - uint32_t flags, uint16_t tag) +TunlinkatRes v9fs_tunlinkat(TunlinkatOpt opt) { P9Req *req; + uint32_t err; + + g_assert(opt.client); + /* expecting either hi-level atPath or low-level dirfd, but not both */ + g_assert(!opt.atPath || !opt.dirfd); + + if (opt.atPath) { + opt.dirfd =3D v9fs_twalk((TWalkOpt) { .client =3D opt.client, + .path =3D opt.atPath }).newfid; + } =20 uint32_t body_size =3D 4 + 4; - uint16_t string_size =3D v9fs_string_size(name); + uint16_t string_size =3D v9fs_string_size(opt.name); =20 g_assert_cmpint(body_size, <=3D, UINT32_MAX - string_size); body_size +=3D string_size; =20 - req =3D v9fs_req_init(v9p, body_size, P9_TUNLINKAT, tag); - v9fs_uint32_write(req, dirfd); - v9fs_string_write(req, name); - v9fs_uint32_write(req, flags); + req =3D v9fs_req_init(opt.client, body_size, P9_TUNLINKAT, opt.tag); + v9fs_uint32_write(req, opt.dirfd); + v9fs_string_write(req, opt.name); + v9fs_uint32_write(req, opt.flags); 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_runlinkat(req); + } + req =3D NULL; /* request was freed */ + } + + return (TunlinkatRes) { .req =3D req }; } =20 /* size[4] Runlinkat tag[2] */ diff --git a/tests/qtest/libqos/virtio-9p-client.h b/tests/qtest/libqos/vir= tio-9p-client.h index 49ffd0fc51..78228eb97d 100644 --- a/tests/qtest/libqos/virtio-9p-client.h +++ b/tests/qtest/libqos/virtio-9p-client.h @@ -415,6 +415,32 @@ typedef struct TlinkRes { P9Req *req; } TlinkRes; =20 +/* options for 'Tunlinkat' 9p request */ +typedef struct TunlinkatOpt { + /* 9P client being used (mandatory) */ + QVirtio9P *client; + /* user supplied tag number being returned with response (optional) */ + uint16_t tag; + /* low-level variant of directory where name shall be unlinked */ + uint32_t dirfd; + /* high-level variant of directory where name shall be unlinked */ + const char *atPath; + /* name of directory entry to be unlinked (required) */ + const char *name; + /* Linux unlinkat(2) flags */ + uint32_t flags; + /* only send Tunlinkat 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; +} TunlinkatOpt; + +/* result of 'Tunlinkat' 9p request */ +typedef struct TunlinkatRes { + /* if requestOnly was set: request object for further processing */ + P9Req *req; +} TunlinkatRes; + 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); @@ -462,8 +488,7 @@ TsymlinkRes v9fs_tsymlink(TsymlinkOpt); void v9fs_rsymlink(P9Req *req, v9fs_qid *qid); TlinkRes v9fs_tlink(TlinkOpt); void v9fs_rlink(P9Req *req); -P9Req *v9fs_tunlinkat(QVirtio9P *v9p, uint32_t dirfd, const char *name, - uint32_t flags, uint16_t tag); +TunlinkatRes v9fs_tunlinkat(TunlinkatOpt); void v9fs_runlinkat(P9Req *req); =20 #endif diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 185eaf8b1e..65e69491e5 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -28,6 +28,7 @@ #define tlcreate(...) v9fs_tlcreate((TlcreateOpt) __VA_ARGS__) #define tsymlink(...) v9fs_tsymlink((TsymlinkOpt) __VA_ARGS__) #define tlink(...) v9fs_tlink((TlinkOpt) __VA_ARGS__) +#define tunlinkat(...) v9fs_tunlinkat((TunlinkatOpt) __VA_ARGS__) =20 static void pci_config(void *obj, void *data, QGuestAllocator *t_alloc) { @@ -481,20 +482,6 @@ static void fs_flush_ignored(void *obj, void *data, QG= uestAllocator *t_alloc) g_free(wnames[0]); } =20 -static void do_unlinkat(QVirtio9P *v9p, const char *atpath, const char *rp= ath, - uint32_t flags) -{ - g_autofree char *name =3D g_strdup(rpath); - uint32_t fid; - P9Req *req; - - fid =3D twalk({ .client =3D v9p, .path =3D atpath }).newfid; - - req =3D v9fs_tunlinkat(v9p, fid, name, flags, 0); - v9fs_req_wait_for_reply(req, NULL); - v9fs_runlinkat(req); -} - static void fs_readdir_split_128(void *obj, void *data, QGuestAllocator *t_alloc) { @@ -556,7 +543,10 @@ static void fs_unlinkat_dir(void *obj, void *data, QGu= estAllocator *t_alloc) /* ... and is actually a directory */ g_assert((st.st_mode & S_IFMT) =3D=3D S_IFDIR); =20 - do_unlinkat(v9p, "/", "02", P9_DOTL_AT_REMOVEDIR); + tunlinkat({ + .client =3D v9p, .atPath =3D "/", .name =3D "02", + .flags =3D P9_DOTL_AT_REMOVEDIR + }); /* directory should be gone now */ g_assert(stat(new_dir, &st) !=3D 0); } @@ -594,7 +584,7 @@ static void fs_unlinkat_file(void *obj, void *data, QGu= estAllocator *t_alloc) /* ... and is a regular file */ g_assert((st.st_mode & S_IFMT) =3D=3D S_IFREG); =20 - do_unlinkat(v9p, "04", "doa_file", 0); + tunlinkat({ .client =3D v9p, .atPath =3D "04", .name =3D "doa_file" }); /* file should be gone now */ g_assert(stat(new_file, &st) !=3D 0); } @@ -643,7 +633,7 @@ static void fs_unlinkat_symlink(void *obj, void *data, }); g_assert(stat(symlink_file, &st) =3D=3D 0); =20 - do_unlinkat(v9p, "06", "symlink_file", 0); + tunlinkat({ .client =3D v9p, .atPath =3D "06", .name =3D "symlink_file= " }); /* symlink should be gone now */ g_assert(stat(symlink_file, &st) !=3D 0); } @@ -696,7 +686,7 @@ static void fs_unlinkat_hardlink(void *obj, void *data, }); g_assert(stat(hardlink_file, &st_link) =3D=3D 0); =20 - do_unlinkat(v9p, "08", "hardlink_file", 0); + tunlinkat({ .client =3D v9p, .atPath =3D "08", .name =3D "hardlink_fil= e" }); /* symlink should be gone now */ g_assert(stat(hardlink_file, &st_link) !=3D 0); /* and old file should still exist */ --=20 2.30.2