From patchwork Sat Mar 12 11:06:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12778808 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4308AC433EF for ; Sat, 12 Mar 2022 12:07:59 +0000 (UTC) Received: from localhost ([::1]:46436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nT0XO-0000cY-E1 for qemu-devel@archiver.kernel.org; Sat, 12 Mar 2022 07:07:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34644) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nT0Vj-0007Xi-Sf for qemu-devel@nongnu.org; Sat, 12 Mar 2022 07:06:15 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:44045) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nT0Vi-0004m3-Bs for qemu-devel@nongnu.org; Sat, 12 Mar 2022 07:06:15 -0500 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=9WTeueT/DgDLw9J91KuUL3y+mEvtLvanX/LDVRueNLY=; b=DJtuR aN3vSR9IQCjtGJoeDZV6GnQWDtiNbSGMygUo1Op8njtCkj4vxrdKzJ9wofoBI/xdsz7+xo8CWpCdv 87JXkEf2X45c2H4vzKzoeYriEVY2iqbGiqXYbGVy0GOz6dkblPVAPTDcvicsGLlqRCwP6IUWLvClX yMJ6nqnS3JgE0yMIYAHwVwM8QNS9I3vaYTsG1x6xcWdZalYXydQtUA4dKNJJ7/XvmdoVrUbfiAMIl UR6aVQXeWEYHT/XIOc248M2iVkMB7n3Ewy8qAsZH4Co1RDg1V8CNGYi6ZNCyHJjJrZpBKp+RXfqGG YAAW5cRDGd1zOPOB3yHA9w168I3JA==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Sat, 12 Mar 2022 12:06:35 +0100 Subject: [PATCH v2 1/7] tests/9pfs: walk to non-existent dir To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: none client-ip=91.194.90.13; envelope-from=f368bd48488fa6bd6fab27ffab732e4a7dadda2c@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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Expect ENOENT Rlerror response when trying to walk to a non-existent directory. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- 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 *path) return fid; } +/* utility function: walk to requested dir and expect passed error response */ +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 = genfid(); + + int nwnames = split(path, "/", &wnames); + + req = v9fs_twalk(v9p, 0, fid, nwnames, wnames, 0); + v9fs_req_wait_for_reply(req, NULL); + v9fs_rlerror(req, &_err); + + g_assert_cmpint(_err, ==, err); + + split_free(&wnames); +} + static void fs_version(void *obj, void *data, QGuestAllocator *t_alloc) { alloc = t_alloc; @@ -974,6 +993,15 @@ static void fs_walk_no_slash(void *obj, void *data, QGuestAllocator *t_alloc) g_free(wnames[0]); } +static void fs_walk_nonexistent(void *obj, void *data, QGuestAllocator *t_alloc) +{ + QVirtio9P *v9p = obj; + alloc = 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 = 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_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, From patchwork Sat Mar 12 11:06:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12778814 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 798C6C433F5 for ; Sat, 12 Mar 2022 12:16:05 +0000 (UTC) Received: from localhost ([::1]:34082 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nT0fE-00048G-EM for qemu-devel@archiver.kernel.org; Sat, 12 Mar 2022 07:16:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35594) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nT0ao-0006Fl-I6 for qemu-devel@nongnu.org; Sat, 12 Mar 2022 07:11:34 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:35833) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nT0an-00065Y-4G for qemu-devel@nongnu.org; Sat, 12 Mar 2022 07:11:30 -0500 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=dfeEm iXa4OD0kZSWXjKSDCjUqwjrpRTfUEhnyuxT8xP/52am/eDZpUYrC6ob56ss2mSgvgUengfUD0h3q0 W9o8DGgqlZtjdi3gKLhCnyPpXYU7EaXwF8xKUfqwOnz0Mf17E7rjEK6/bHsXGTmK5p0oZAJlvC9ED CFjmjfu6mhJ9WdYur6pr6UBryoINGcfgfIAVysQb/Zs8lZyUiWWPhP9MUSl5ZP/Je6cwnd8fTpaSx AujteIbZwqG9iAoVLq9CH4Z8b54pxfVw1P/EiO6XMqL6RP+trkVwgLUDnSirzbHS9/VXhe6RGfGTW iFi3XcBuwltDh1NliJZhzHhmSqnkA==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Sat, 12 Mar 2022 12:06:39 +0100 Subject: [PATCH v2 2/7] tests/9pfs: Twalk with nwname=0 To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: none client-ip=91.194.90.13; envelope-from=f0d56d86f4d16f6aa712307eeee6964a33f16839@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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Send Twalk request with nwname=0. 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 *data, QGuestAllocator *t_alloc) do_walk_expect_error(v9p, "non-existent", ENOENT); } +static void fs_walk_none(void *obj, void *data, QGuestAllocator *t_alloc) +{ + QVirtio9P *v9p = obj; + alloc = t_alloc; + v9fs_qid root_qid; + g_autofree v9fs_qid *wqid = NULL; + P9Req *req; + + do_version(v9p); + req = v9fs_tattach(v9p, 0, getuid(), 0); + v9fs_req_wait_for_reply(req, NULL); + v9fs_rattach(req, &root_qid); + + req = 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=0 was sent */ + g_assert(wqid == NULL); +} + static void fs_walk_dotdot(void *obj, void *data, QGuestAllocator *t_alloc) { QVirtio9P *v9p = 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_nonexistent, From patchwork Sat Mar 12 11:06:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12778813 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 93FF5C433F5 for ; Sat, 12 Mar 2022 12:14:19 +0000 (UTC) Received: from localhost ([::1]:59006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nT0dW-0001hB-Kh for qemu-devel@archiver.kernel.org; Sat, 12 Mar 2022 07:14:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35740) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <23d3a2a2ab403dc04161eb5eb7f60ee6efa55200@lizzy.crudebyte.com>) id 1nT0bp-0007tm-0i for qemu-devel@nongnu.org; Sat, 12 Mar 2022 07:12:33 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:57779) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <23d3a2a2ab403dc04161eb5eb7f60ee6efa55200@lizzy.crudebyte.com>) id 1nT0bn-0006HG-Dy for qemu-devel@nongnu.org; Sat, 12 Mar 2022 07:12:32 -0500 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=nXcgv UDCRvTLrnassa0D0MbiWkbzRJPMEswzeBT7NqxRNrrgRB9bCAvlH+K6NxG6swMwpS8JRxQq9XdLfq IfTCQlnC+DBkbw8tVsWzvZ+rYqi/JLtO7QfsXlSjdNEo47/OO3/je05DlvvRI52lGyyi6f9FmQxIS z9+h8L3rM4n0lhC0TyesRfW+39YOuV2bfe9/1dfkv+HgwtflG/vBDwl5J/rsk538TcZSZkUmkLXe8 iE9k7in+mujQyn/+AXjCrg+2f4bm/qEM7MTB22PGO3Dc4LhQCXoq4SqdaNezpnIf1QeoM8ITgyJqv WjqLZXhenDGd3vVs9y0W+eCXY8Bmg==; Message-Id: <23d3a2a2ab403dc04161eb5eb7f60ee6efa55200.1647083430.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sat, 12 Mar 2022 12:06:42 +0100 Subject: [PATCH v2 3/7] tests/9pfs: compare QIDs in fs_walk_none() test To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: none client-ip=91.194.90.13; envelope-from=23d3a2a2ab403dc04161eb5eb7f60ee6efa55200@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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 fid, uint32_t n_uname, return req; } +/* type[1] version[4] path[8] */ typedef char v9fs_qid[13]; +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] == b[0] && memcmp(&a[5], &b[5], 8) == 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, v9fs_qid **wqid) v9fs_req_free(req); } +/* 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 = 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, QGuestAllocator *t_alloc) v9fs_qid root_qid; g_autofree v9fs_qid *wqid = NULL; P9Req *req; + struct v9fs_attr attr; do_version(v9p); req = v9fs_tattach(v9p, 0, getuid(), 0); @@ -1021,6 +1102,12 @@ static void fs_walk_none(void *obj, void *data, QGuestAllocator *t_alloc) /* special case: no QID is returned if nwname=0 was sent */ g_assert(wqid == NULL); + + req = 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)); } static void fs_walk_dotdot(void *obj, void *data, QGuestAllocator *t_alloc) From patchwork Sat Mar 12 11:06:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12778811 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A01AAC433F5 for ; Sat, 12 Mar 2022 12:12:47 +0000 (UTC) Received: from localhost ([::1]:55708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nT0c2-0007jG-Qc for qemu-devel@archiver.kernel.org; Sat, 12 Mar 2022 07:12:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35392) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nT0Zo-0004hT-8U for qemu-devel@nongnu.org; Sat, 12 Mar 2022 07:10:28 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:51461) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nT0Zm-0005XM-Rg for qemu-devel@nongnu.org; Sat, 12 Mar 2022 07:10:27 -0500 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=G/hpJ h+rWP+bIjeby02goE3PfCb9lN4ahahV9oxB87fN/sdtFIS9xv7+KQRZGRQbqH5eB1qdJ63TD+QXFW JWvKdFLIcHcIGKUksDfXjiO2DsqApkNGGX2ZofU2QBBGyTUl8PY+yrXgeyIOfs2rI5JwauRf4heBN QBZuGCjyPnT5R8ZShS64PGhMmW15Ooap+cN4reBsXByAzcBcOy6rY4cNOwIlF9uZ+uLH+t6/7sHp8 p6/zoEFOjmJKzg0QxHAtevufg/S42ovNoPc7fYXad152jOZkWJWiMvx1yAftHiitdUNHbzMrPqUvv d5cU7MyUcOyjjdxfAtiitZjs43GMg==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Sat, 12 Mar 2022 12:06:45 +0100 Subject: [PATCH v2 4/7] 9pfs: refactor 'name_idx' -> 'nwalked' in v9fs_walk() To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: none client-ip=91.194.90.13; envelope-from=eebd764c82b49f50d83b5d64ecc28ac802fbea3b@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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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) static void coroutine_fn v9fs_walk(void *opaque) { - int name_idx; + int name_idx, nwalked; g_autofree V9fsQID *qids = NULL; int i, err = 0; V9fsPath dpath, path; @@ -1842,17 +1842,17 @@ static void coroutine_fn v9fs_walk(void *opaque) break; } stbuf = fidst; - for (name_idx = 0; name_idx < nwnames; name_idx++) { + for (nwalked = 0; nwalked < nwnames; nwalked++) { if (v9fs_request_cancelled(pdu)) { err = -EINTR; break; } if (!same_stat_id(&pdu->s->root_st, &stbuf) || - strcmp("..", wnames[name_idx].data)) + strcmp("..", wnames[nwalked].data)) { err = s->ops->name_to_path(&s->ctx, &dpath, - wnames[name_idx].data, - &pathes[name_idx]); + wnames[nwalked].data, + &pathes[nwalked]); if (err < 0) { err = -errno; break; @@ -1861,13 +1861,13 @@ static void coroutine_fn v9fs_walk(void *opaque) err = -EINTR; break; } - err = s->ops->lstat(&s->ctx, &pathes[name_idx], &stbuf); + err = s->ops->lstat(&s->ctx, &pathes[nwalked], &stbuf); if (err < 0) { err = -errno; break; } - stbufs[name_idx] = stbuf; - v9fs_path_copy(&dpath, &pathes[name_idx]); + stbufs[nwalked] = stbuf; + v9fs_path_copy(&dpath, &pathes[nwalked]); } } }); From patchwork Sat Mar 12 11:06:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12778810 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 50784C433EF for ; Sat, 12 Mar 2022 12:11:20 +0000 (UTC) Received: from localhost ([::1]:51946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nT0ad-0004XZ-Ei for qemu-devel@archiver.kernel.org; Sat, 12 Mar 2022 07:11:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34794) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <59571e9379c3729ad287a5c7fce8ef4876e7fed5@lizzy.crudebyte.com>) id 1nT0Wk-0008FS-RM for qemu-devel@nongnu.org; Sat, 12 Mar 2022 07:07:19 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:33789) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <59571e9379c3729ad287a5c7fce8ef4876e7fed5@lizzy.crudebyte.com>) id 1nT0Wi-0004xt-QT for qemu-devel@nongnu.org; Sat, 12 Mar 2022 07:07:18 -0500 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=z5zfah+2g+HGkJfPbXo34H4jpmLgNrYncozy2OvyVn4=; b=Kxvud vwWDwLrdzojeJVAzFaghJfriXyoF4peorx6Vzso0W14quoGJOR5aH6NkqKVGZNNeEZfUzprrdw40S PfhAONOOMO0+NdTFSHbvMP66ne2bqxH82FiqZP8Z96RcUSW6oNYgsZhkWT+zLfYbUY46hgFJsmOMZ LMTpUtdEZUY60fq5YOqDdh9iToWORHJWIL+CVzbJ+diJmqb/95gcPCbtZCuTMTK/zjjzoEm8cqb4t eY5/WL+kgQYtYSOYPjwhSDDNtrGVGRHs0PrU9tu3WxQ7jtbLgB1g2w25DPZJtvNeXOq0WKHh/jvun u2OrDxXwN6i3/U7Vy3iWjmzcUDxXQ==; Message-Id: <59571e9379c3729ad287a5c7fce8ef4876e7fed5.1647083430.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sat, 12 Mar 2022 12:06:47 +0100 Subject: [PATCH v2 5/7] 9pfs: fix 'Twalk' to only send error if no component walked To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: none client-ip=91.194.90.13; envelope-from=59571e9379c3729ad287a5c7fce8ef4876e7fed5@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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 index 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 | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 298f4e6548..e8d838f6fd 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 = NULL; - int i, err = 0; + int i, err = 0, any_err = 0; V9fsPath dpath, path; P9ARRAY_REF(V9fsPath) pathes = NULL; uint16_t nwnames; @@ -1832,6 +1832,7 @@ static void coroutine_fn v9fs_walk(void *opaque) * driver code altogether inside the following block. */ v9fs_co_run_in_worker({ + nwalked = 0; if (v9fs_request_cancelled(pdu)) { err = -EINTR; break; @@ -1842,7 +1843,7 @@ static void coroutine_fn v9fs_walk(void *opaque) break; } stbuf = fidst; - for (nwalked = 0; nwalked < nwnames; nwalked++) { + for (; nwalked < nwnames; nwalked++) { if (v9fs_request_cancelled(pdu)) { err = -EINTR; break; @@ -1874,12 +1875,13 @@ 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 == -EINTR) { goto out; } + any_err |= err; err = stat_to_qid(pdu, &fidst, &qid); - if (err < 0) { + if (err < 0 && !nwalked) { goto out; } stbuf = fidst; @@ -1888,20 +1890,30 @@ static void coroutine_fn v9fs_walk(void *opaque) v9fs_path_copy(&dpath, &fidp->path); v9fs_path_copy(&path, &fidp->path); - for (name_idx = 0; name_idx < nwnames; name_idx++) { + for (name_idx = 0; name_idx < nwalked; name_idx++) { if (!same_stat_id(&pdu->s->root_st, &stbuf) || strcmp("..", wnames[name_idx].data)) { stbuf = stbufs[name_idx]; err = 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)); } + any_err |= err; + 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 == newfid) { if (fidp->fid_type != P9_FID_NONE) { err = -EINVAL; @@ -1919,8 +1931,9 @@ static void coroutine_fn v9fs_walk(void *opaque) newfidp->uid = fidp->uid; v9fs_path_copy(&newfidp->path, &path); } - err = v9fs_walk_marshal(pdu, nwnames, qids); - trace_v9fs_walk_return(pdu->tag, pdu->id, nwnames, qids); +send_qids: + err = 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) { From patchwork Sat Mar 12 11:06:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12778812 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C3AD2C433EF for ; Sat, 12 Mar 2022 12:14:18 +0000 (UTC) Received: from localhost ([::1]:58934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nT0dV-0001dl-Mf for qemu-devel@archiver.kernel.org; Sat, 12 Mar 2022 07:14:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35192) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <1615696fe78186877ed5713166fe9f00546850c0@lizzy.crudebyte.com>) id 1nT0Yn-00030j-6y for qemu-devel@nongnu.org; Sat, 12 Mar 2022 07:09:30 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:52621) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <1615696fe78186877ed5713166fe9f00546850c0@lizzy.crudebyte.com>) id 1nT0Yk-0005Lx-N1 for qemu-devel@nongnu.org; Sat, 12 Mar 2022 07:09:24 -0500 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=MNQE3 grh6j+M8UEiMfNDrA8aXhYNsIFSt9nLLf9lIsL3c54WkSaxNiU3mD9uu/kJgdsDmw0D4rCMdxgOpN 3O/un+khE4XRwD0FZJYjhLBGEF05+fetc3/QeSKyxFdiyLLFPU1IEF8k4FoQqGRjPFQVD93QFtFdN A3JdClhwnUYsu5N3TUELhmUm8X/mzDwQFIZrdo/VtKUSSd+hL2Iy7BGz7IF5bCSKcYfU7hclDxglk svwGHHLQ5Gk1PMa2JhbjlWn76336nqNQ506FMh/9NoMqbhHIKhXTA0nfaa6cOCv2Xp38gLYEKin4b qqKVtenURTCKTppIz2iFEpYcma3qA==; Message-Id: <1615696fe78186877ed5713166fe9f00546850c0.1647083430.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sat, 12 Mar 2022 12:06:51 +0100 Subject: [PATCH v2 6/7] tests/9pfs: guard recent 'Twalk' behaviour fix To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: none client-ip=91.194.90.13; envelope-from=1615696fe78186877ed5713166fe9f00546850c0@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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Previous 9p patch fixed 'Twalk' request handling, which was previously not behaving as specified by the 9p2000 protocol spec. This patch adds a new test 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)); } -/* 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 *path) req = 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); split_free(&wnames); return fid; } +/* 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 response */ 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 *data, QGuestAllocator *t_alloc) alloc = t_alloc; do_attach(v9p); + /* + * The 9p2000 protocol spec says: "If the first element cannot be walked + * for any reason, Rerror is returned." + */ do_walk_expect_error(v9p, "non-existent", ENOENT); } +static void fs_walk_2nd_nonexistent(void *obj, void *data, + QGuestAllocator *t_alloc) +{ + QVirtio9P *v9p = obj; + alloc = t_alloc; + uint16_t nwqid; + g_autofree v9fs_qid *wqid = NULL; + g_autofree char *path = 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 == 1); +} + static void fs_walk_none(void *obj, void *data, QGuestAllocator *t_alloc) { QVirtio9P *v9p = 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_nonexistent, &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, From patchwork Sat Mar 12 11:06:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12778807 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D0F11C433EF for ; Sat, 12 Mar 2022 12:07:36 +0000 (UTC) Received: from localhost ([::1]:45264 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nT0X1-0008F5-ET for qemu-devel@archiver.kernel.org; Sat, 12 Mar 2022 07:07:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34394) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nT0Uj-00072W-KX for qemu-devel@nongnu.org; Sat, 12 Mar 2022 07:05:13 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:54283) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nT0Uh-0004S7-B1 for qemu-devel@nongnu.org; Sat, 12 Mar 2022 07:05:12 -0500 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=x3Nu1Z3JuP7T0P/LxDLf02GMaWDKq4stT/+XUKicrug=; b=cZ902 JDJG6QLo669+jXZtlmOGa3Mcmq4EI2ezXpQPlRlxvm97EJMdj/LEcuQWnPTOPMTRzejO8zOKw92DL rSVllcCfTwHTTAaXdgQjndYYcXP6bVM++tGBJtB5dokMjiSIhc1gOwkDHDxCFBFxStIM3T04cW9Hz X/R8qVIwqwQxwY+ujEe+gViHvLxoprU7x/rh9pjHS06DyxIApyDPwS8/s5X1MUMLICXkpFaksiTIh v0SKyPoutLEcXOhICLYXoylRJ0S7NzFo8EcZaV6XNpSUOi0mHDKJoJgCum2FhvnVXZuupN141ziQ0 zSoyljL6/B8PwvjJf6bkKR/LO5qVg==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Sat, 12 Mar 2022 12:06:58 +0100 Subject: [PATCH v2 7/7] tests/9pfs: check fid being unaffected in fs_walk_2nd_nonexistent To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: none client-ip=91.194.90.13; envelope-from=a06e4e9e80212440ed0d1fa4bd2c63d059ce620d@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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Extend previously added test case by checking that fid is unaffected by 'Twalk' request (i.e. when 2nd path component of request being invalid). Do that by comparing the QID of root fid with QID of walked fid; they should be identical. Signed-off-by: Christian Schoenebeck --- tests/qtest/virtio-9p-test.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index f6e78d388e..b9c6819d01 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, QGuestAllocator *t_alloc) do_version(obj); } -static void do_attach(QVirtio9P *v9p) +static void do_attach_rqid(QVirtio9P *v9p, v9fs_qid *qid) { P9Req *req; do_version(v9p); req = 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); } static void fs_attach(void *obj, void *data, QGuestAllocator *t_alloc) @@ -1101,19 +1106,22 @@ static void fs_walk_2nd_nonexistent(void *obj, void *data, { QVirtio9P *v9p = obj; alloc = t_alloc; + v9fs_qid root_qid; uint16_t nwqid; g_autofree v9fs_qid *wqid = NULL; g_autofree char *path = g_strdup_printf( QTEST_V9FS_SYNTH_WALK_FILE "/non-existent", 0 ); - do_attach(v9p); + do_attach_rqid(v9p, &root_qid); 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 == 1); + /* expect fid being unaffected by walk */ + g_assert(wqid && wqid[0] && is_same_qid(root_qid, wqid[0])); } static void fs_walk_none(void *obj, void *data, QGuestAllocator *t_alloc)