From nobody Tue May 21 00:26:14 2024 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=1647339893; cv=none; d=zohomail.com; s=zohoarc; b=bkaYcn3K9Q4gnhi0fNH9BVq6rVEBQnLrCPPs8nCz6hYpF2NYw4L48zRE8xblxqINTj+qDjALsDGck8PYqON29+tjVoESG8rs742RgDBMTfSSBEtBKN+ZvK/GAtOygwFppSbPxMnDemOOsqVnKLdSdbiqhwjbvxDYol0uPYtflIE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647339893; 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=QcPvQB5Np+omQPMUL4Wk5kc4YffCR5KElek87QyXqz8=; b=isVtCtmYIVo+0V/rOqhZbA3ANCdBgVcA36uOdHKkHUeJ4/NzDpVm0jrgAudihcQxE2PtNWfOk4mhQ+wl1Tk/xtI529t9JJIVWaz7DjeDCkEziZ+k4DB1bjEML3b2h1/qcuYocAMvoMCV5pJ9JB1WWk27xA6CqAxL7HTHQVvq7IM= 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 1647339893483335.08963148520047; Tue, 15 Mar 2022 03:24:53 -0700 (PDT) Received: from localhost ([::1]:46868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nU4MG-0000vy-Fx for importer@patchew.org; Tue, 15 Mar 2022 06:24:52 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47078) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <1f5aa50ace3ba3861ea31e8888367518282065a6@lizzy.crudebyte.com>) id 1nU4KG-0006WR-Lh for qemu-devel@nongnu.org; Tue, 15 Mar 2022 06:22:48 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:51837) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <1f5aa50ace3ba3861ea31e8888367518282065a6@lizzy.crudebyte.com>) id 1nU4KF-0004FW-3c for qemu-devel@nongnu.org; Tue, 15 Mar 2022 06:22:48 -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=QcPvQB5Np+omQPMUL4Wk5kc4YffCR5KElek87QyXqz8=; b=jkqFg wv0dpnskaUK6Wh7HD4HmT2usJ/0c1ftpnn0xa/V+6UoTg8y81/mHSJdvgnMUkgqhyqoNgykarR6Vm NdM2F5YQe/baYom/xbRS4cGHdG4xGDKv/2asO7vkN/AWMukzBeFoNDNLON40X+IFL90Ufs0boVWP3 ymREP2QCzkc7pE1cepVrI4w9PppypTICW31w1OzKuWrESmu3sgj4wR7kxSuLLLkV7ElYMLb5aRN8E 6cpqLrTTo7lcdMJtsjxdz7DRrWFygORz2yobMh2ComIltlK3uUmFZhs7URG2x9kvDEZGXIpIFqQCa 8GwIr7CQGV3vDQSl3iNWMv67+XpgA==; Message-Id: <1f5aa50ace3ba3861ea31e8888367518282065a6.1647339025.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 15 Mar 2022 11:08:30 +0100 Subject: [PATCH v4 1/7] tests/9pfs: walk to non-existent dir To: qemu-devel@nongnu.org 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=1f5aa50ace3ba3861ea31e8888367518282065a6@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, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1647339895785100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Expect ENOENT Rlerror response when trying to walk to a non-existent directory. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz Based-on: --- tests/qtest/virtio-9p-test.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 01ca076afe..22bdd74bc1 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -606,6 +606,25 @@ static uint32_t do_walk(QVirtio9P *v9p, const char *pa= th) return fid; } =20 +/* utility function: walk to requested dir and expect passed error respons= e */ +static void do_walk_expect_error(QVirtio9P *v9p, const char *path, uint32_= t err) +{ + char **wnames; + P9Req *req; + uint32_t _err; + const uint32_t fid =3D genfid(); + + int nwnames =3D split(path, "/", &wnames); + + req =3D v9fs_twalk(v9p, 0, fid, nwnames, wnames, 0); + v9fs_req_wait_for_reply(req, NULL); + v9fs_rlerror(req, &_err); + + g_assert_cmpint(_err, =3D=3D, err); + + split_free(&wnames); +} + static void fs_version(void *obj, void *data, QGuestAllocator *t_alloc) { alloc =3D t_alloc; @@ -974,6 +993,15 @@ static void fs_walk_no_slash(void *obj, void *data, QG= uestAllocator *t_alloc) g_free(wnames[0]); } =20 +static void fs_walk_nonexistent(void *obj, void *data, QGuestAllocator *t_= alloc) +{ + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; + + do_attach(v9p); + do_walk_expect_error(v9p, "non-existent", ENOENT); +} + static void fs_walk_dotdot(void *obj, void *data, QGuestAllocator *t_alloc) { QVirtio9P *v9p =3D obj; @@ -1409,6 +1437,8 @@ static void register_virtio_9p_test(void) &opts); qos_add_test("synth/walk/dotdot_from_root", "virtio-9p", fs_walk_dotdot, &opts); + qos_add_test("synth/walk/non_existent", "virtio-9p", fs_walk_nonexiste= nt, + &opts); qos_add_test("synth/lopen/basic", "virtio-9p", fs_lopen, &opts); qos_add_test("synth/write/basic", "virtio-9p", fs_write, &opts); qos_add_test("synth/flush/success", "virtio-9p", fs_flush_success, --=20 2.30.2 From nobody Tue May 21 00:26:14 2024 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=1647340139; cv=none; d=zohomail.com; s=zohoarc; b=eVt7ZCDP1n+LxLzNjUx1TkMGXLagS0Y3ubVSRC/4irsCCjhO+c8WVujtOwklAr6mk+6tarddE3Y8SQFxYpGe/yPwwXLvT3HckhHIoESTBKE4p2lWAtW9Zgh+Q2Rsnqm20EPqJM99AQK0ZItLOSL0C/6qZXtG2xkXh7WV71uCGtk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647340139; 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=TJAeDlUJJUlZd5EXAz9aRvXtuj5klvD+5R2Ki1HIheQ=; b=ZxTOwZB7MwkvEOWt394jf0Jb/+KwASnAbrW2cQdYVgKhD5WpdH1dw74Qsv93CxAzf0V1TXBZTeS1TSy3vmT2sYaGK5aiYflE/5KdexXu5+6d/TuIRytSzWqWVim4iwhmY9JdTwfUIrkQinfG37gLBPT5nUt4FXNh59phCoS72BI= 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 1647340139796615.5661929238552; Tue, 15 Mar 2022 03:28:59 -0700 (PDT) Received: from localhost ([::1]:52046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nU4QE-0004XK-5k for importer@patchew.org; Tue, 15 Mar 2022 06:28:58 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47118) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nU4KQ-0006nW-4E for qemu-devel@nongnu.org; Tue, 15 Mar 2022 06:22:58 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:33655) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nU4KM-0004G5-3W for qemu-devel@nongnu.org; Tue, 15 Mar 2022 06:22:57 -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=TJAeDlUJJUlZd5EXAz9aRvXtuj5klvD+5R2Ki1HIheQ=; b=fWar6 UsbcqwBmv2P2J0eL3CDrV9nk4lrsuHiHtT7MYMixD1suM0BN9yfl3BliXPwzrPQy7mRuyz484Yg6U Yvdkob7aotMdQu96I4k+0j6AaZmPeIwzhqJ+WbjIqny1erNDrKtNNirf63HBEfenW/mUSH6XTUNZJ RBCNEjj/F76OFwCrsp/3jjhBhcGnbIThWM/GFzjeKJLcjySWWR7/Rz6B0XpWx/KoQlFUfCGLk52rW rijvEYQobpgioC2Ko8IcnFp8wzXcPQ7CdFutey04iTNzFjXSP/95p2gjReEVVL/WtSubpV8fMk6Bp Ddym51FTCZcQP/IYJw7tEnYIbgU4Q==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 15 Mar 2022 11:08:33 +0100 Subject: [PATCH v4 2/7] tests/9pfs: Twalk with nwname=0 To: qemu-devel@nongnu.org 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=b5ead2775000203607801f09bcefc04c493d8bfa@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, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1647340142160100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Send Twalk request with nwname=3D0. In this case no QIDs should be returned by 9p server; this is equivalent to walking to dot. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- tests/qtest/virtio-9p-test.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 22bdd74bc1..6c00da03f4 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -1002,6 +1002,27 @@ static void fs_walk_nonexistent(void *obj, void *dat= a, QGuestAllocator *t_alloc) do_walk_expect_error(v9p, "non-existent", ENOENT); } =20 +static void fs_walk_none(void *obj, void *data, QGuestAllocator *t_alloc) +{ + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; + v9fs_qid root_qid; + g_autofree v9fs_qid *wqid =3D NULL; + P9Req *req; + + do_version(v9p); + req =3D v9fs_tattach(v9p, 0, getuid(), 0); + v9fs_req_wait_for_reply(req, NULL); + v9fs_rattach(req, &root_qid); + + req =3D v9fs_twalk(v9p, 0, 1, 0, NULL, 0); + v9fs_req_wait_for_reply(req, NULL); + v9fs_rwalk(req, NULL, &wqid); + + /* special case: no QID is returned if nwname=3D0 was sent */ + g_assert(wqid =3D=3D NULL); +} + static void fs_walk_dotdot(void *obj, void *data, QGuestAllocator *t_alloc) { QVirtio9P *v9p =3D obj; @@ -1435,6 +1456,7 @@ static void register_virtio_9p_test(void) qos_add_test("synth/walk/basic", "virtio-9p", fs_walk, &opts); qos_add_test("synth/walk/no_slash", "virtio-9p", fs_walk_no_slash, &opts); + qos_add_test("synth/walk/none", "virtio-9p", fs_walk_none, &opts); qos_add_test("synth/walk/dotdot_from_root", "virtio-9p", fs_walk_dotdot, &opts); qos_add_test("synth/walk/non_existent", "virtio-9p", fs_walk_nonexiste= nt, --=20 2.30.2 From nobody Tue May 21 00:26:14 2024 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=1647340229; cv=none; d=zohomail.com; s=zohoarc; b=YVQkWGyFzH2e6jcDVJw5xjfPVO/r8T6r3OiBA+CNcNg8qpnTVsJL/N/vprnnPeEcn27HLRl7AZsK13lK1N3QIQi8X1kvLo3MGqu+BfNzvtxuRysEuyxCVAY5xrVK6aKTCalp3mBNaHSl/M9z6FWVqV2PlsF37XVbV3Kiqa9AsUI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647340229; 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=GQkHOSaKS6+6Wsk7lghzVN6F9aWBoWHorE82nJWkimU=; b=bbNfJ+EvZJpDes4/rmJ0j5K3mYl5abT5Q4Rb1qh5PkJrkA6Z8qWLGJAx1id9OguBXMIMluwcmvZE91nMItxWXXdnYSu/RCZYc9/mha6Eo3vA2g/uivH6o4rw76Dz2a/Fqgs9FLVHx9tveZ7mNDBMtPyy9iIdbG/TKec/bIqoSLI= 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 1647340229029527.8508448649154; Tue, 15 Mar 2022 03:30:29 -0700 (PDT) Received: from localhost ([::1]:55450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nU4Rf-0006qF-NO for importer@patchew.org; Tue, 15 Mar 2022 06:30:27 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47148) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <5bbe9c6931b4600a9a23742f5ff2d38c1188237d@lizzy.crudebyte.com>) id 1nU4KT-0006xm-9S for qemu-devel@nongnu.org; Tue, 15 Mar 2022 06:23:01 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:35777) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <5bbe9c6931b4600a9a23742f5ff2d38c1188237d@lizzy.crudebyte.com>) id 1nU4KR-0004HH-NV for qemu-devel@nongnu.org; Tue, 15 Mar 2022 06:23:01 -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=GQkHOSaKS6+6Wsk7lghzVN6F9aWBoWHorE82nJWkimU=; b=i+Y5U dHSRhP88nkHxyg6KQoXLk7qRUi+NytatvcdwnVyWhhDdv7+c/fQ3zjX4B1uAHTXEzgPdH2WSSi68T Bj1pyZsF6WNNhcaCnOjQfZkWAAdvGZ88WcBI0/+9De1S4/8cxYtNnQJr1RoCGYkSrRUdPyNkQVjuy dO1mL8EG5Qxo+L3QQLEUZ7CjTDa8cYtSZk1Um4H0NWD0PUw98XtzqzksY6VNoFDyA81SS85WlzRD9 pC1iMc07jxPgBMKFR2yuuY9SrmEAEW3vFgxawHpll1NnP0MxhN1p/8mKY8dGH1Wq78J4DgI3MPQ98 MGiQYOwp+VafQ+OExvVYXj7J8p8xA==; Message-Id: <5bbe9c6931b4600a9a23742f5ff2d38c1188237d.1647339025.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 15 Mar 2022 11:08:35 +0100 Subject: [PATCH v4 3/7] tests/9pfs: compare QIDs in fs_walk_none() test To: qemu-devel@nongnu.org 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=5bbe9c6931b4600a9a23742f5ff2d38c1188237d@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, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1647340230505100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Extend previously added fs_walk_none() test by comparing the QID of the root fid with the QID of the cloned fid. They should be equal. Signed-off-by: Christian Schoenebeck --- tests/qtest/virtio-9p-test.c | 87 ++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 6c00da03f4..a1160f4659 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -371,8 +371,15 @@ static P9Req *v9fs_tattach(QVirtio9P *v9p, uint32_t fi= d, uint32_t n_uname, return req; } =20 +/* type[1] version[4] path[8] */ typedef char v9fs_qid[13]; =20 +static inline bool is_same_qid(v9fs_qid a, v9fs_qid b) +{ + /* don't compare QID version for checking for file ID equalness */ + return a[0] =3D=3D b[0] && memcmp(&a[5], &b[5], 8) =3D=3D 0; +} + /* size[4] Rattach tag[2] qid[13] */ static void v9fs_rattach(P9Req *req, v9fs_qid *qid) { @@ -425,6 +432,79 @@ static void v9fs_rwalk(P9Req *req, uint16_t *nwqid, v9= fs_qid **wqid) v9fs_req_free(req); } =20 +/* size[4] Tgetattr tag[2] fid[4] request_mask[8] */ +static P9Req *v9fs_tgetattr(QVirtio9P *v9p, uint32_t fid, uint64_t request= _mask, + uint16_t tag) +{ + P9Req *req; + + req =3D v9fs_req_init(v9p, 4 + 8, P9_TGETATTR, tag); + v9fs_uint32_write(req, fid); + v9fs_uint64_write(req, request_mask); + v9fs_req_send(req); + return req; +} + +typedef struct v9fs_attr { + uint64_t valid; + v9fs_qid qid; + uint32_t mode; + uint32_t uid; + uint32_t gid; + uint64_t nlink; + uint64_t rdev; + uint64_t size; + uint64_t blksize; + uint64_t blocks; + uint64_t atime_sec; + uint64_t atime_nsec; + uint64_t mtime_sec; + uint64_t mtime_nsec; + uint64_t ctime_sec; + uint64_t ctime_nsec; + uint64_t btime_sec; + uint64_t btime_nsec; + uint64_t gen; + uint64_t data_version; +} v9fs_attr; + +#define P9_GETATTR_BASIC 0x000007ffULL /* Mask for fields up to BLOCKS = */ + +/* + * size[4] Rgetattr tag[2] valid[8] qid[13] mode[4] uid[4] gid[4] nlink[8] + * rdev[8] size[8] blksize[8] blocks[8] + * atime_sec[8] atime_nsec[8] mtime_sec[8] mtime_nsec[8] + * ctime_sec[8] ctime_nsec[8] btime_sec[8] btime_nsec[8] + * gen[8] data_version[8] + */ +static void v9fs_rgetattr(P9Req *req, v9fs_attr *attr) +{ + v9fs_req_recv(req, P9_RGETATTR); + + v9fs_uint64_read(req, &attr->valid); + v9fs_memread(req, &attr->qid, 13); + v9fs_uint32_read(req, &attr->mode); + v9fs_uint32_read(req, &attr->uid); + v9fs_uint32_read(req, &attr->gid); + v9fs_uint64_read(req, &attr->nlink); + v9fs_uint64_read(req, &attr->rdev); + v9fs_uint64_read(req, &attr->size); + v9fs_uint64_read(req, &attr->blksize); + v9fs_uint64_read(req, &attr->blocks); + v9fs_uint64_read(req, &attr->atime_sec); + v9fs_uint64_read(req, &attr->atime_nsec); + v9fs_uint64_read(req, &attr->mtime_sec); + v9fs_uint64_read(req, &attr->mtime_nsec); + v9fs_uint64_read(req, &attr->ctime_sec); + v9fs_uint64_read(req, &attr->ctime_nsec); + v9fs_uint64_read(req, &attr->btime_sec); + v9fs_uint64_read(req, &attr->btime_nsec); + v9fs_uint64_read(req, &attr->gen); + v9fs_uint64_read(req, &attr->data_version); + + v9fs_req_free(req); +} + /* size[4] Treaddir tag[2] fid[4] offset[8] count[4] */ static P9Req *v9fs_treaddir(QVirtio9P *v9p, uint32_t fid, uint64_t offset, uint32_t count, uint16_t tag) @@ -1009,6 +1089,7 @@ static void fs_walk_none(void *obj, void *data, QGues= tAllocator *t_alloc) v9fs_qid root_qid; g_autofree v9fs_qid *wqid =3D NULL; P9Req *req; + struct v9fs_attr attr; =20 do_version(v9p); req =3D v9fs_tattach(v9p, 0, getuid(), 0); @@ -1021,6 +1102,12 @@ static void fs_walk_none(void *obj, void *data, QGue= stAllocator *t_alloc) =20 /* special case: no QID is returned if nwname=3D0 was sent */ g_assert(wqid =3D=3D NULL); + + req =3D v9fs_tgetattr(v9p, 1, P9_GETATTR_BASIC, 0); + v9fs_req_wait_for_reply(req, NULL); + v9fs_rgetattr(req, &attr); + + g_assert(is_same_qid(root_qid, attr.qid)); } =20 static void fs_walk_dotdot(void *obj, void *data, QGuestAllocator *t_alloc) --=20 2.30.2 From nobody Tue May 21 00:26:14 2024 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=1647340428; cv=none; d=zohomail.com; s=zohoarc; b=Ar7+gsf70AfQnq16JiTgC/g2F177tyQZrSsGcXXxU7H8bNEi4EqFPIwrLaiBiLTPuhYzMTJzDU0vii5+2sCv1VMF49Sjw1dlhiT1nGtkLImerGHjk2kitUItVD4VuqX15pPje3sZRDMi9zaimWYanqpjsU8Qe67dNpQ/d8c77h8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647340428; 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=My4K+eiCxAHtELn1btGGEyng+75fSZVgSXg21Pv6JpQ=; b=JDNIsMaGdsI/MOcST/mZuRYwvg/JQHRyzcGEcR/eAehIjHP8ATxfxJrWVPJno5h4N6Iq7b/3T+pG4C7WflbpS2wnaFQC7PhN5v9trnoS25ShucsOuLwsKShVfiF88s4J7ipyN5NUHravzZuykMR3mh2ziJgg2zXWbTgJW/1O8PI= 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 1647340428498172.05898020113875; Tue, 15 Mar 2022 03:33:48 -0700 (PDT) Received: from localhost ([::1]:60646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nU4Ut-00021j-0b for importer@patchew.org; Tue, 15 Mar 2022 06:33:47 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nU4Ka-0007NY-CG for qemu-devel@nongnu.org; Tue, 15 Mar 2022 06:23:08 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:53723) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nU4KY-0004Hn-Ox for qemu-devel@nongnu.org; Tue, 15 Mar 2022 06:23:08 -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=My4K+eiCxAHtELn1btGGEyng+75fSZVgSXg21Pv6JpQ=; b=KbMoV jE8x+To7MnIVNmVdU4kuBSYI7DMyqjpf7xQd/SUs6itTujCZ4k8fLXaUlZ+47gmKhL48xqDh+Fexn RZfO6qkYFJrJCO+//aKAbNm1Cc5xFiwBvxa1oZEd1DdgcrV0wYrVSzQCu6lnb8cipQBgp8cQ0epnh PnmvUxZfydfAIjgZGTFo3hyXHMZ/a+IKn0D2c2knp2b8n7m/Easl5iXgMTbx77HxQjaR5QPOzjZ2J F5rMk//8ER+XtwI/Pq8bVN92n2rUw9Kd1JU+yxGo50t2BIom3EJsjPuACyY05fvPvMLADld1bqsdq PisgvubpbL2+a36jvHmd9UIqM07ig==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 15 Mar 2022 11:08:37 +0100 Subject: [PATCH v4 4/7] 9pfs: refactor 'name_idx' -> 'nwalked' in v9fs_walk() To: qemu-devel@nongnu.org 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=d506308e7e343023c4db95d0e6053dd2627ed3c1@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, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1647340430185100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The local variable 'name_idx' is used in two loops in function v9fs_walk(). Let the first loop use its own variable 'nwalked' instead, which we will use in subsequent patch as the number of (requested) path components successfully walked by background I/O thread. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- hw/9pfs/9p.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index a6d6b3f835..298f4e6548 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1764,7 +1764,7 @@ static bool same_stat_id(const struct stat *a, const = struct stat *b) =20 static void coroutine_fn v9fs_walk(void *opaque) { - int name_idx; + int name_idx, nwalked; g_autofree V9fsQID *qids =3D NULL; int i, err =3D 0; V9fsPath dpath, path; @@ -1842,17 +1842,17 @@ static void coroutine_fn v9fs_walk(void *opaque) break; } stbuf =3D fidst; - for (name_idx =3D 0; name_idx < nwnames; name_idx++) { + for (nwalked =3D 0; nwalked < nwnames; nwalked++) { if (v9fs_request_cancelled(pdu)) { err =3D -EINTR; break; } if (!same_stat_id(&pdu->s->root_st, &stbuf) || - strcmp("..", wnames[name_idx].data)) + strcmp("..", wnames[nwalked].data)) { err =3D s->ops->name_to_path(&s->ctx, &dpath, - wnames[name_idx].data, - &pathes[name_idx]); + wnames[nwalked].data, + &pathes[nwalked]); if (err < 0) { err =3D -errno; break; @@ -1861,13 +1861,13 @@ static void coroutine_fn v9fs_walk(void *opaque) err =3D -EINTR; break; } - err =3D s->ops->lstat(&s->ctx, &pathes[name_idx], &stbuf); + err =3D s->ops->lstat(&s->ctx, &pathes[nwalked], &stbuf); if (err < 0) { err =3D -errno; break; } - stbufs[name_idx] =3D stbuf; - v9fs_path_copy(&dpath, &pathes[name_idx]); + stbufs[nwalked] =3D stbuf; + v9fs_path_copy(&dpath, &pathes[nwalked]); } } }); --=20 2.30.2 From nobody Tue May 21 00:26:14 2024 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=1647340221; cv=none; d=zohomail.com; s=zohoarc; b=Jf/+aQA3WAj14RhAq6tE5QhBfpEIzVva1D+Q5jfCfJrNCH25+PC1b5c4wBTMyGgZg64rU1ZMvoSvwcr9xbqtvE+PKL0zXohzP3p9ZL82yIoUYYc/afpj4nfqYEOdXs04kmiuUavJoMbBhCc1Afds2XncaJNt35fyQ4SLPQ0VuPk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647340221; 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=a0crYNaDR8bFaHuaYpqJ8FipN3b+gvU/VTrR86DztiI=; b=jDinJ3jDSiCubGppnPUtLWsilSirysrs2Pz9pcji2wlAlmxqUwiEHUIHNUQbjx+1cIh8uCjBqF8U+kY5+BO03zwlEVot1mKHCNtg2sdSt3h7s+1sMxmkxgEVno+XERyNsWcH/esRG/4CyRVM/9jU5I2We0RQmtBT2MwVPUWL3EI= 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 1647340221573132.99628152380262; Tue, 15 Mar 2022 03:30:21 -0700 (PDT) Received: from localhost ([::1]:55080 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nU4RZ-0006Zq-Eb for importer@patchew.org; Tue, 15 Mar 2022 06:30:21 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47216) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nU4Ki-0007aZ-06 for qemu-devel@nongnu.org; Tue, 15 Mar 2022 06:23:16 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:57679) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nU4Kg-0004I5-5x for qemu-devel@nongnu.org; Tue, 15 Mar 2022 06:23:15 -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=a0crYNaDR8bFaHuaYpqJ8FipN3b+gvU/VTrR86DztiI=; b=gyYgM 79e+232gGLMbvffVQMTXYCYTCfVEHar+mupQtlrdAlqBhDE6NDPsFx2Su9iLvlDsc4e+hHdg9mHI2 ptpvJWDiG18a7sjaThTsshWccxuTNk3RgphobOFYSET146uB3LxKiI7EyYzGJqMUeqsGA8aQnP37Y 6bX/y0BXHFcMXwPxhcvd+hKuarCpqW1em4/nRVU7jLlas9+3oFg+n2xzIoEZhrHPVywG4iaK9L9aJ x8O6ikt/CJySOLFUGnL9GH60npJ8MOiXYmRWm2P6HgtAvRZaBkfyCY/K9L4YoelNDhtPa1Ki69CZW Hngz5URD8SW5Ct+STMOIRyjbpqEKA==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 15 Mar 2022 11:08:39 +0100 Subject: [PATCH v4 5/7] 9pfs: fix 'Twalk' to only send error if no component walked To: qemu-devel@nongnu.org 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=bc73e24258a75dc29458024c7936c8a036c3eac5@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, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1647340229663100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Current implementation of 'Twalk' request handling always sends an 'Rerror' response if any error occured. The 9p2000 protocol spec says though: " If the first element cannot be walked for any reason, Rerror is returned. Otherwise, the walk will return an Rwalk message containing nwqid qids corresponding, in order, to the files that are visited by the nwqid successful elementwise walks; nwqid is therefore either nwname or the ind= ex of the first elementwise walk that failed. " http://ericvh.github.io/9p-rfc/rfc9p2000.html#anchor33 For that reason we are no longer leaving from an error path in function v9fs_walk(), unless really no path component could be walked successfully or if the request has been interrupted. Local variable 'nwalked' counts and reflects the number of path components successfully processed by background I/O thread, whereas local variable 'name_idx' subsequently counts and reflects the number of path components eventually accepted successfully by 9p server controller portion. New local variable 'any_err' is an aggregate variable reflecting whether any error occurred at all, while already existing variable 'err' only reflects the last error. Despite QIDs being delivered to client in a more relaxed way now, it is important to note though that fid still must remain unaffected if any error occurred. Signed-off-by: Christian Schoenebeck --- hw/9pfs/9p.c | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 298f4e6548..e770972a71 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1766,7 +1766,7 @@ static void coroutine_fn v9fs_walk(void *opaque) { int name_idx, nwalked; g_autofree V9fsQID *qids =3D NULL; - int i, err =3D 0; + int i, err =3D 0, any_err =3D 0; V9fsPath dpath, path; P9ARRAY_REF(V9fsPath) pathes =3D NULL; uint16_t nwnames; @@ -1832,19 +1832,20 @@ static void coroutine_fn v9fs_walk(void *opaque) * driver code altogether inside the following block. */ v9fs_co_run_in_worker({ + nwalked =3D 0; if (v9fs_request_cancelled(pdu)) { - err =3D -EINTR; + any_err |=3D err =3D -EINTR; break; } err =3D s->ops->lstat(&s->ctx, &dpath, &fidst); if (err < 0) { - err =3D -errno; + any_err |=3D err =3D -errno; break; } stbuf =3D fidst; - for (nwalked =3D 0; nwalked < nwnames; nwalked++) { + for (; nwalked < nwnames; nwalked++) { if (v9fs_request_cancelled(pdu)) { - err =3D -EINTR; + any_err |=3D err =3D -EINTR; break; } if (!same_stat_id(&pdu->s->root_st, &stbuf) || @@ -1854,16 +1855,16 @@ static void coroutine_fn v9fs_walk(void *opaque) wnames[nwalked].data, &pathes[nwalked]); if (err < 0) { - err =3D -errno; + any_err |=3D err =3D -errno; break; } if (v9fs_request_cancelled(pdu)) { - err =3D -EINTR; + any_err |=3D err =3D -EINTR; break; } err =3D s->ops->lstat(&s->ctx, &pathes[nwalked], &stbuf); if (err < 0) { - err =3D -errno; + any_err |=3D err =3D -errno; break; } stbufs[nwalked] =3D stbuf; @@ -1874,12 +1875,12 @@ static void coroutine_fn v9fs_walk(void *opaque) /* * Handle all the rest of this Twalk request on main thread ... */ - if (err < 0) { + if ((err < 0 && !nwalked) || err =3D=3D -EINTR) { goto out; } =20 - err =3D stat_to_qid(pdu, &fidst, &qid); - if (err < 0) { + any_err |=3D err =3D stat_to_qid(pdu, &fidst, &qid); + if (err < 0 && !nwalked) { goto out; } stbuf =3D fidst; @@ -1888,20 +1889,29 @@ static void coroutine_fn v9fs_walk(void *opaque) v9fs_path_copy(&dpath, &fidp->path); v9fs_path_copy(&path, &fidp->path); =20 - for (name_idx =3D 0; name_idx < nwnames; name_idx++) { + for (name_idx =3D 0; name_idx < nwalked; name_idx++) { if (!same_stat_id(&pdu->s->root_st, &stbuf) || strcmp("..", wnames[name_idx].data)) { stbuf =3D stbufs[name_idx]; - err =3D stat_to_qid(pdu, &stbuf, &qid); + any_err |=3D err =3D stat_to_qid(pdu, &stbuf, &qid); if (err < 0) { - goto out; + break; } v9fs_path_copy(&path, &pathes[name_idx]); v9fs_path_copy(&dpath, &path); } memcpy(&qids[name_idx], &qid, sizeof(qid)); } + if (any_err < 0) { + if (!name_idx) { + /* don't send any QIDs, send Rlerror instead */ + goto out; + } else { + /* send QIDs (not Rlerror), but fid MUST remain unaffected */ + goto send_qids; + } + } if (fid =3D=3D newfid) { if (fidp->fid_type !=3D P9_FID_NONE) { err =3D -EINVAL; @@ -1919,8 +1929,9 @@ static void coroutine_fn v9fs_walk(void *opaque) newfidp->uid =3D fidp->uid; v9fs_path_copy(&newfidp->path, &path); } - err =3D v9fs_walk_marshal(pdu, nwnames, qids); - trace_v9fs_walk_return(pdu->tag, pdu->id, nwnames, qids); +send_qids: + err =3D v9fs_walk_marshal(pdu, name_idx, qids); + trace_v9fs_walk_return(pdu->tag, pdu->id, name_idx, qids); out: put_fid(pdu, fidp); if (newfidp) { --=20 2.30.2 From nobody Tue May 21 00:26:14 2024 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=1647340508; cv=none; d=zohomail.com; s=zohoarc; b=lppI/OJmCEdx+Hjc4rxJkj1LWxXIwCaIepcRB2pLkSofMfe2vnoKsAvftqOQFDuBkbkjczClmm/UInwnCeDHB/BtRWepGBLQ4Zrq5DHcQTMJXHwz5TeTrdsRTQKsN6l3EMDq+M2tZt6FrJvPjxG3W4/HErY2eAqFLVmm9DfC1lA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647340508; 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=3NJWCrxaT7h/hOfZtG+/U/Q+vEuCGTA0s6O09Ns4aiU=; b=NUPTOFKDyJizp1WBXQ/E2+rM7R/y6Kk2P4WfKMAvfIEdAAH9U3jFdsuEYLGBh58mUD7eCh2Ah3Lb+OogjhuQnW16UmfVZ/5LUsyr08wtoksWjqF/ikWvEgwsh5S+SaWOkx6GmLWif2YB6elKddge2SsPV6zcw4Qx30nLNToPTCc= 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 1647340508161756.5323856793527; Tue, 15 Mar 2022 03:35:08 -0700 (PDT) Received: from localhost ([::1]:35846 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nU4WB-0004Nk-5F for importer@patchew.org; Tue, 15 Mar 2022 06:35:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <61bde2f44b87e24b70ec098dfb81765665b2dfcb@lizzy.crudebyte.com>) id 1nU4Ko-0007qK-Hk for qemu-devel@nongnu.org; Tue, 15 Mar 2022 06:23:26 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:52897) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <61bde2f44b87e24b70ec098dfb81765665b2dfcb@lizzy.crudebyte.com>) id 1nU4Km-0004JZ-Ug for qemu-devel@nongnu.org; Tue, 15 Mar 2022 06:23:22 -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=3NJWCrxaT7h/hOfZtG+/U/Q+vEuCGTA0s6O09Ns4aiU=; b=lks0C prvFkldeMkke/36uNGEDY5WsnrYAwR511vjU806pMRQXViNhXewUusenYh+kOTrISKsQ0S2dRn+X1 YSyCbwzeVGHktGub9VIpodxvtC9DCEtHiJkzGSXG1wzv4Axu/A8qdl+x3BJ48lmKpw67AgFmHi9iH ytfUkyprN5LWweuaQWIGpZaRu7uz+NLOU9tJJ2r9TjLaQxm8jtnPANY0SYafj0iW+GzYwv2f1LIM+ ExFINVa9OBc2wKGOZddckgQqFfN54+IFdFwynvCvv4DkBohvAFyeWK/5eqfROX64chtGOPGVgJWxj JhbK+WPlwke6dszKBF/NLLCTxpZCA==; Message-Id: <61bde2f44b87e24b70ec098dfb81765665b2dfcb.1647339025.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 15 Mar 2022 11:08:41 +0100 Subject: [PATCH v4 6/7] tests/9pfs: guard recent 'Twalk' behaviour fix To: qemu-devel@nongnu.org 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=61bde2f44b87e24b70ec098dfb81765665b2dfcb@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, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1647340508650100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Previous 9p patch fixed 'Twalk' request handling, which was previously not behaving as specified by the 9p2000 protocol spec. This patch adds a new te= st case which guards the new 'Twalk' behaviour in question. More specifically: it sends a 'Twalk' request where the 1st path component is valid, whereas the 2nd path component transmitted to server does not exist. The expected behaviour is that 9p server would respond by sending a 'Rwalk' response with exactly 1 QID (instead of 'Rlerror' response). Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- tests/qtest/virtio-9p-test.c | 42 +++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index a1160f4659..f6e78d388e 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -669,8 +669,12 @@ static void do_version(QVirtio9P *v9p) g_assert_cmpmem(server_version, server_len, version, strlen(version)); } =20 -/* utility function: walk to requested dir and return fid for that dir */ -static uint32_t do_walk(QVirtio9P *v9p, const char *path) +/* + * utility function: walk to requested dir and return fid for that dir and + * the QIDs of server response + */ +static uint32_t do_walk_rqids(QVirtio9P *v9p, const char *path, uint16_t *= nwqid, + v9fs_qid **wqid) { char **wnames; P9Req *req; @@ -680,12 +684,18 @@ static uint32_t do_walk(QVirtio9P *v9p, const char *p= ath) =20 req =3D v9fs_twalk(v9p, 0, fid, nwnames, wnames, 0); v9fs_req_wait_for_reply(req, NULL); - v9fs_rwalk(req, NULL, NULL); + v9fs_rwalk(req, nwqid, wqid); =20 split_free(&wnames); return fid; } =20 +/* utility function: walk to requested dir and return fid for that dir */ +static uint32_t do_walk(QVirtio9P *v9p, const char *path) +{ + return do_walk_rqids(v9p, path, NULL, NULL); +} + /* utility function: walk to requested dir and expect passed error respons= e */ static void do_walk_expect_error(QVirtio9P *v9p, const char *path, uint32_= t err) { @@ -1079,9 +1089,33 @@ static void fs_walk_nonexistent(void *obj, void *dat= a, QGuestAllocator *t_alloc) alloc =3D t_alloc; =20 do_attach(v9p); + /* + * The 9p2000 protocol spec says: "If the first element cannot be walk= ed + * for any reason, Rerror is returned." + */ do_walk_expect_error(v9p, "non-existent", ENOENT); } =20 +static void fs_walk_2nd_nonexistent(void *obj, void *data, + QGuestAllocator *t_alloc) +{ + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; + uint16_t nwqid; + g_autofree v9fs_qid *wqid =3D NULL; + g_autofree char *path =3D g_strdup_printf( + QTEST_V9FS_SYNTH_WALK_FILE "/non-existent", 0 + ); + + do_attach(v9p); + do_walk_rqids(v9p, path, &nwqid, &wqid); + /* + * The 9p2000 protocol spec says: "nwqid is therefore either nwname or= the + * index of the first elementwise walk that failed." + */ + assert(nwqid =3D=3D 1); +} + static void fs_walk_none(void *obj, void *data, QGuestAllocator *t_alloc) { QVirtio9P *v9p =3D obj; @@ -1548,6 +1582,8 @@ static void register_virtio_9p_test(void) fs_walk_dotdot, &opts); qos_add_test("synth/walk/non_existent", "virtio-9p", fs_walk_nonexiste= nt, &opts); + qos_add_test("synth/walk/2nd_non_existent", "virtio-9p", + fs_walk_2nd_nonexistent, &opts); qos_add_test("synth/lopen/basic", "virtio-9p", fs_lopen, &opts); qos_add_test("synth/write/basic", "virtio-9p", fs_write, &opts); qos_add_test("synth/flush/success", "virtio-9p", fs_flush_success, --=20 2.30.2 From nobody Tue May 21 00:26:14 2024 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=1647340505; cv=none; d=zohomail.com; s=zohoarc; b=CxQMjjq9EmSYF+6NGulmQv9BU7jUdIRm7WoTNBaCEHQlBl+gii7A6hRWwukHBYen+oMWvCQ+auUgBnqFwc8yOaArd5/f2zsafU9zyW7ZqafrLrcBfmRGwiLA5M/7yCFePOjdIWV1zcH1ExFUsjEXBIhCkvNcwpL+kA5XcuYFRak= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647340505; 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=unZHmT3zWZNnuD5uSrtK7589kM7s18wLKGi/v3vo7LE=; b=VGNh7vBe+LvgUgomabBmICXKEs9vuRwG1xZmTk6HyAIjt4qwfviGIh8d/XKlGoMtpvKAeDobfgRXY9EEE99We9Gw2fsbcBE0IluuGRhvFEy1dSc6U8wcQb6tGD4UaKYfONjXvlimEScvUrmhNByikqsLGzsLOD8PvkpNHT95jKY= 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 1647340505567444.8507712152182; Tue, 15 Mar 2022 03:35:05 -0700 (PDT) Received: from localhost ([::1]:35540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nU4W8-0004BX-80 for importer@patchew.org; Tue, 15 Mar 2022 06:35:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <6f0813cafdbf683cdac8b1492dd4ef8699c5b1d9@lizzy.crudebyte.com>) id 1nU4Kv-0007sb-Tp for qemu-devel@nongnu.org; Tue, 15 Mar 2022 06:23:29 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:34903) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <6f0813cafdbf683cdac8b1492dd4ef8699c5b1d9@lizzy.crudebyte.com>) id 1nU4Kt-0004K2-UD for qemu-devel@nongnu.org; Tue, 15 Mar 2022 06:23:29 -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=unZHmT3zWZNnuD5uSrtK7589kM7s18wLKGi/v3vo7LE=; b=YYhHA TmTXCdh0Ach2IScfLk84hTkadFGHaTF0/YAhrl5mZAiiFcfXz5WvqRyAwuyycENeEDuy2tUqMO3eE bSPsldkBWvMpgm1wDCV4PsczuW7Og6QuOuQJMnupYJMk/2tiXG12qnU65tyCQ+5Kn939w03emu8yV chPSzqviBeYKpzrMMG45FzIo+v2vc7oad4mcnRf6uv4Q5yT5vKMY6+ic0G/GKIpluARFRHksc4YN5 8HcHe09PvHSu6XHwL79yRv1y8wCHYQA+jRiOCzEpXOrjTTSPPwz8+AUwlTI1H3Ll0Wgc70qPzfXg3 v/GJD6ng9vrsuu0wjXvc1qv8ku3yw==; Message-Id: <6f0813cafdbf683cdac8b1492dd4ef8699c5b1d9.1647339025.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 15 Mar 2022 11:08:47 +0100 Subject: [PATCH v4 7/7] tests/9pfs: check fid being unaffected in fs_walk_2nd_nonexistent To: qemu-devel@nongnu.org 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=6f0813cafdbf683cdac8b1492dd4ef8699c5b1d9@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, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1647340506492100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Extend previously added test case by checking that fid was unaffected by 'Twalk' request (i.e. when 2nd path component of request being invalid). Do that by subsequently sending a 'Tgetattr' request with the fid previously used for 'Twalk'; that 'Tgetattr' request should return an 'Rlerror' response by 9p server with error code ENOENT as that fid is basically invalid. And as we are at it, also check that the QID returned by 'Twalk' is not identical to the root node's QID. Signed-off-by: Christian Schoenebeck --- tests/qtest/virtio-9p-test.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index f6e78d388e..2784ee4b2d 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -721,14 +721,19 @@ static void fs_version(void *obj, void *data, QGuestA= llocator *t_alloc) do_version(obj); } =20 -static void do_attach(QVirtio9P *v9p) +static void do_attach_rqid(QVirtio9P *v9p, v9fs_qid *qid) { P9Req *req; =20 do_version(v9p); req =3D v9fs_tattach(v9p, 0, getuid(), 0); v9fs_req_wait_for_reply(req, NULL); - v9fs_rattach(req, NULL); + v9fs_rattach(req, qid); +} + +static void do_attach(QVirtio9P *v9p) +{ + do_attach_rqid(v9p, NULL); } =20 static void fs_attach(void *obj, void *data, QGuestAllocator *t_alloc) @@ -1101,19 +1106,32 @@ static void fs_walk_2nd_nonexistent(void *obj, void= *data, { QVirtio9P *v9p =3D obj; alloc =3D t_alloc; + v9fs_qid root_qid; uint16_t nwqid; + uint32_t fid, err; + P9Req *req; g_autofree v9fs_qid *wqid =3D NULL; g_autofree char *path =3D g_strdup_printf( QTEST_V9FS_SYNTH_WALK_FILE "/non-existent", 0 ); =20 - do_attach(v9p); - do_walk_rqids(v9p, path, &nwqid, &wqid); + do_attach_rqid(v9p, &root_qid); + fid =3D do_walk_rqids(v9p, path, &nwqid, &wqid); /* * The 9p2000 protocol spec says: "nwqid is therefore either nwname or= the * index of the first elementwise walk that failed." */ assert(nwqid =3D=3D 1); + + /* returned QID wqid[0] is file ID of 1st subdir */ + g_assert(wqid && wqid[0] && !is_same_qid(root_qid, wqid[0])); + + /* expect fid being unaffected by walk above */ + req =3D v9fs_tgetattr(v9p, fid, P9_GETATTR_BASIC, 0); + v9fs_req_wait_for_reply(req, NULL); + v9fs_rlerror(req, &err); + + g_assert_cmpint(err, =3D=3D, ENOENT); } =20 static void fs_walk_none(void *obj, void *data, QGuestAllocator *t_alloc) --=20 2.30.2