qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kurz <groug@kaod.org>
To: Christian Schoenebeck <qemu_oss@crudebyte.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH v4 7/7] tests/9pfs: check fid being unaffected in fs_walk_2nd_nonexistent
Date: Wed, 15 Jun 2022 17:57:53 +0200	[thread overview]
Message-ID: <20220615175753.1a43e4b0@bahia> (raw)
In-Reply-To: <6f0813cafdbf683cdac8b1492dd4ef8699c5b1d9.1647339025.git.qemu_oss@crudebyte.com>

On Tue, 15 Mar 2022 11:08:47 +0100
Christian Schoenebeck <qemu_oss@crudebyte.com> wrote:

> 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 <qemu_oss@crudebyte.com>
> ---

Reviewed-by: Greg Kurz <groug@kaod.org>

>  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, 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,32 @@ static void fs_walk_2nd_nonexistent(void *obj, void *data,
>  {
>      QVirtio9P *v9p = obj;
>      alloc = t_alloc;
> +    v9fs_qid root_qid;
>      uint16_t nwqid;
> +    uint32_t fid, err;
> +    P9Req *req;
>      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);
> +    do_attach_rqid(v9p, &root_qid);
> +    fid = 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);
> +
> +    /* 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 = v9fs_tgetattr(v9p, fid, P9_GETATTR_BASIC, 0);
> +    v9fs_req_wait_for_reply(req, NULL);
> +    v9fs_rlerror(req, &err);
> +
> +    g_assert_cmpint(err, ==, ENOENT);
>  }
>  
>  static void fs_walk_none(void *obj, void *data, QGuestAllocator *t_alloc)



  reply	other threads:[~2022-06-15 16:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-15 10:10 [PATCH v4 0/7] 9pfs: fix 'Twalk' protocol violation Christian Schoenebeck
2022-03-15 10:08 ` [PATCH v4 1/7] tests/9pfs: walk to non-existent dir Christian Schoenebeck
2022-03-15 10:08 ` [PATCH v4 2/7] tests/9pfs: Twalk with nwname=0 Christian Schoenebeck
2022-03-15 10:08 ` [PATCH v4 3/7] tests/9pfs: compare QIDs in fs_walk_none() test Christian Schoenebeck
2022-06-15 15:08   ` Greg Kurz
2022-03-15 10:08 ` [PATCH v4 4/7] 9pfs: refactor 'name_idx' -> 'nwalked' in v9fs_walk() Christian Schoenebeck
2022-03-15 10:08 ` [PATCH v4 5/7] 9pfs: fix 'Twalk' to only send error if no component walked Christian Schoenebeck
2022-06-15 15:52   ` Greg Kurz
2022-06-15 16:36     ` Christian Schoenebeck
2022-06-16 10:17       ` Greg Kurz
2022-03-15 10:08 ` [PATCH v4 6/7] tests/9pfs: guard recent 'Twalk' behaviour fix Christian Schoenebeck
2022-03-15 10:08 ` [PATCH v4 7/7] tests/9pfs: check fid being unaffected in fs_walk_2nd_nonexistent Christian Schoenebeck
2022-06-15 15:57   ` Greg Kurz [this message]
2022-03-29 10:21 ` [PATCH v4 0/7] 9pfs: fix 'Twalk' protocol violation Christian Schoenebeck
2022-03-29 10:59   ` Greg Kurz
2022-06-16 10:53 ` Christian Schoenebeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220615175753.1a43e4b0@bahia \
    --to=groug@kaod.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu_oss@crudebyte.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).