From: Christian Schoenebeck <qemu_oss@crudebyte.com>
To: qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>
Cc: Greg Kurz <groug@kaod.org>
Subject: Re: [PULL 7/9] tests/9p: add 'Tsetattr' request to test client
Date: Thu, 10 Jul 2025 16:11:44 +0200 [thread overview]
Message-ID: <1956976.W3UK9cqU4Q@silver> (raw)
In-Reply-To: <CAFEAcA8Sc7t25KNzwnEAi=n8SNCAYDsFbs8P8hUKwWRxWzx_QQ@mail.gmail.com>
On Thursday, July 10, 2025 3:30:22 PM CEST Peter Maydell wrote:
> On Mon, 5 May 2025 at 10:54, Christian Schoenebeck
> <qemu_oss@crudebyte.com> wrote:
> >
> > Add and implement functions to 9pfs test client for sending a 9p2000.L
> > 'Tsetattr' request and receiving its 'Rsetattr' response counterpart.
> >
> > Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> > Signed-off-by: Greg Kurz <groug@kaod.org>
> > Message-Id: <20250312152933.383967-6-groug@kaod.org>
> > ---
> > tests/qtest/libqos/virtio-9p-client.c | 49 +++++++++++++++++++++++++++
> > tests/qtest/libqos/virtio-9p-client.h | 34 +++++++++++++++++++
> > tests/qtest/virtio-9p-test.c | 1 +
> > 3 files changed, 84 insertions(+)
> >
> > diff --git a/tests/qtest/libqos/virtio-9p-client.c b/tests/qtest/libqos/virtio-9p-client.c
> > index 98b77db51d..6ab4501c6e 100644
> > --- a/tests/qtest/libqos/virtio-9p-client.c
> > +++ b/tests/qtest/libqos/virtio-9p-client.c
> > @@ -557,6 +557,55 @@ void v9fs_rgetattr(P9Req *req, v9fs_attr *attr)
> > v9fs_req_free(req);
> > }
> >
> > +/*
> > + * size[4] Tsetattr tag[2] fid[4] valid[4] mode[4] uid[4] gid[4] size[8]
> > + * atime_sec[8] atime_nsec[8] mtime_sec[8] mtime_nsec[8]
> > + */
> > +TSetAttrRes v9fs_tsetattr(TSetAttrOpt opt)
> > +{
> > + P9Req *req;
> > + uint32_t err;
>
>
> Hi -- Coverity warns (CID 1609751) that this function
> passes by value an argument which is a 184 byte struct.
> Is this intentional?
Hi Peter!
Yes, that was intentional. It follows the same coding pattern of the 9p test
cases to hack named function arguments into C:
someFunc({ .argC = 3, .argH = "foo", .argX = 1 });
That saves a lot of code and makes callers better readable, because some test
case just needs to pass a value for argument A and C, another test might need
to pass arguments H, X and Y, and so on.
Before we had numerous function variations for the same thing, just with
different argument permutations. Now it's only one function per purpose.
> Can we instead pass a pointer to the
> struct?
>
> This is only a test program and 184 bytes is not super
> enormous, so if this would be painful to avoid we can mark
> the coverity report as a false positive.
Well, it would be possible to change this to a pointer, patch below in any
case. Personally I would just mark this as a false positive though. It's not a
bug and the resulting binary would probably be identical. No hard opinion
though.
/Christian
diff --git a/tests/qtest/libqos/virtio-9p-client.c b/tests/qtest/libqos/virtio-9p-client.c
index 6ab4501c6e..f0b009645d 100644
--- a/tests/qtest/libqos/virtio-9p-client.c
+++ b/tests/qtest/libqos/virtio-9p-client.c
@@ -561,35 +561,35 @@ void v9fs_rgetattr(P9Req *req, v9fs_attr *attr)
* size[4] Tsetattr tag[2] fid[4] valid[4] mode[4] uid[4] gid[4] size[8]
* atime_sec[8] atime_nsec[8] mtime_sec[8] mtime_nsec[8]
*/
-TSetAttrRes v9fs_tsetattr(TSetAttrOpt opt)
+TSetAttrRes v9fs_tsetattr(TSetAttrOpt *opt)
{
P9Req *req;
uint32_t err;
- g_assert(opt.client);
+ g_assert(opt->client);
req = v9fs_req_init(
- opt.client, 4/*fid*/ + 4/*valid*/ + 4/*mode*/ + 4/*uid*/ + 4/*gid*/ +
+ opt->client, 4/*fid*/ + 4/*valid*/ + 4/*mode*/ + 4/*uid*/ + 4/*gid*/ +
8/*size*/ + 8/*atime_sec*/ + 8/*atime_nsec*/ + 8/*mtime_sec*/ +
- 8/*mtime_nsec*/, P9_TSETATTR, opt.tag
+ 8/*mtime_nsec*/, P9_TSETATTR, opt->tag
);
- v9fs_uint32_write(req, opt.fid);
- v9fs_uint32_write(req, (uint32_t) opt.attr.valid);
- v9fs_uint32_write(req, opt.attr.mode);
- v9fs_uint32_write(req, opt.attr.uid);
- v9fs_uint32_write(req, opt.attr.gid);
- v9fs_uint64_write(req, opt.attr.size);
- v9fs_uint64_write(req, opt.attr.atime_sec);
- v9fs_uint64_write(req, opt.attr.atime_nsec);
- v9fs_uint64_write(req, opt.attr.mtime_sec);
- v9fs_uint64_write(req, opt.attr.mtime_nsec);
+ v9fs_uint32_write(req, opt->fid);
+ v9fs_uint32_write(req, (uint32_t) opt->attr.valid);
+ v9fs_uint32_write(req, opt->attr.mode);
+ v9fs_uint32_write(req, opt->attr.uid);
+ v9fs_uint32_write(req, opt->attr.gid);
+ v9fs_uint64_write(req, opt->attr.size);
+ v9fs_uint64_write(req, opt->attr.atime_sec);
+ v9fs_uint64_write(req, opt->attr.atime_nsec);
+ v9fs_uint64_write(req, opt->attr.mtime_sec);
+ v9fs_uint64_write(req, opt->attr.mtime_nsec);
v9fs_req_send(req);
- if (!opt.requestOnly) {
+ if (!opt->requestOnly) {
v9fs_req_wait_for_reply(req, NULL);
- if (opt.expectErr) {
+ if (opt->expectErr) {
v9fs_rlerror(req, &err);
- g_assert_cmpint(err, ==, opt.expectErr);
+ g_assert_cmpint(err, ==, opt->expectErr);
} else {
v9fs_rsetattr(req);
}
diff --git a/tests/qtest/libqos/virtio-9p-client.h b/tests/qtest/libqos/virtio-9p-client.h
index e3221a3104..4b55d7a56d 100644
--- a/tests/qtest/libqos/virtio-9p-client.h
+++ b/tests/qtest/libqos/virtio-9p-client.h
@@ -502,7 +502,7 @@ TWalkRes v9fs_twalk(TWalkOpt opt);
void v9fs_rwalk(P9Req *req, uint16_t *nwqid, v9fs_qid **wqid);
TGetAttrRes v9fs_tgetattr(TGetAttrOpt);
void v9fs_rgetattr(P9Req *req, v9fs_attr *attr);
-TSetAttrRes v9fs_tsetattr(TSetAttrOpt opt);
+TSetAttrRes v9fs_tsetattr(TSetAttrOpt *opt);
void v9fs_rsetattr(P9Req *req);
TReadDirRes v9fs_treaddir(TReadDirOpt);
void v9fs_rreaddir(P9Req *req, uint32_t *count, uint32_t *nentries,
diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c
index ac38ccf595..4397c0738f 100644
--- a/tests/qtest/virtio-9p-test.c
+++ b/tests/qtest/virtio-9p-test.c
@@ -20,7 +20,7 @@
#define tversion(...) v9fs_tversion((TVersionOpt) __VA_ARGS__)
#define tattach(...) v9fs_tattach((TAttachOpt) __VA_ARGS__)
#define tgetattr(...) v9fs_tgetattr((TGetAttrOpt) __VA_ARGS__)
-#define tsetattr(...) v9fs_tsetattr((TSetAttrOpt) __VA_ARGS__)
+#define tsetattr(...) v9fs_tsetattr(&((TSetAttrOpt) __VA_ARGS__))
#define treaddir(...) v9fs_treaddir((TReadDirOpt) __VA_ARGS__)
#define tlopen(...) v9fs_tlopen((TLOpenOpt) __VA_ARGS__)
#define twrite(...) v9fs_twrite((TWriteOpt) __VA_ARGS__)
next prev parent reply other threads:[~2025-07-10 14:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-05 9:50 [PULL 0/9] 9p queue 2025-05-05 Christian Schoenebeck
2025-05-05 9:50 ` [PULL 9/9] 9pfs: fix 'total_open_fd' decrementation Christian Schoenebeck
2025-05-05 9:50 ` [PULL 8/9] tests/9p: Test `Tsetattr` can truncate unlinked file Christian Schoenebeck
2025-05-05 9:50 ` [PULL 6/9] 9pfs: Introduce futimens file op Christian Schoenebeck
2025-05-05 9:50 ` [PULL 1/9] 9pfs: fix concurrent v9fs_reclaim_fd() calls Christian Schoenebeck
2025-05-05 9:50 ` [PULL 3/9] 9pfs: local : Introduce local_fid_fd() helper Christian Schoenebeck
2025-05-05 9:50 ` [PULL 7/9] tests/9p: add 'Tsetattr' request to test client Christian Schoenebeck
2025-07-10 13:30 ` Peter Maydell
2025-07-10 14:11 ` Christian Schoenebeck [this message]
2025-07-10 14:17 ` Peter Maydell
2025-05-05 9:50 ` [PULL 2/9] 9pfs: fix FD leak and reduce latency of v9fs_reclaim_fd() Christian Schoenebeck
2025-05-05 9:50 ` [PULL 4/9] 9pfs: Don't use file descriptors in core code Christian Schoenebeck
2025-05-05 9:50 ` [PULL 5/9] 9pfs: Introduce ftruncate file op Christian Schoenebeck
2025-05-06 13:58 ` [PULL 0/9] 9p queue 2025-05-05 Stefan Hajnoczi
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=1956976.W3UK9cqU4Q@silver \
--to=qemu_oss@crudebyte.com \
--cc=groug@kaod.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/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).