aboutsummaryrefslogtreecommitdiff
path: root/tests/qtest/libqos/virtio-9p-client.c
diff options
context:
space:
mode:
authorChristian Schoenebeck <qemu_oss@crudebyte.com>2022-10-04 22:53:52 +0200
committerChristian Schoenebeck <qemu_oss@crudebyte.com>2022-10-24 12:24:32 +0200
commit3878ce4cc2f1cb9e802076c827834c34d3788b78 (patch)
tree2f0a9a449de6665238788818755b1f4ecbca759b /tests/qtest/libqos/virtio-9p-client.c
parenta9a53769318503c4d8884e642e00603ea6885cb1 (diff)
downloadqemu-3878ce4cc2f1cb9e802076c827834c34d3788b78.zip
qemu-3878ce4cc2f1cb9e802076c827834c34d3788b78.tar.gz
qemu-3878ce4cc2f1cb9e802076c827834c34d3788b78.tar.bz2
tests/9p: convert v9fs_tlopen() to declarative arguments
Use declarative function arguments for function v9fs_tlopen(). Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com> Message-Id: <765ab515353c56f88f0a163631f626a44e9565d6.1664917004.git.qemu_oss@crudebyte.com>
Diffstat (limited to 'tests/qtest/libqos/virtio-9p-client.c')
-rw-r--r--tests/qtest/libqos/virtio-9p-client.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/tests/qtest/libqos/virtio-9p-client.c b/tests/qtest/libqos/virtio-9p-client.c
index 047c899..15fde54 100644
--- a/tests/qtest/libqos/virtio-9p-client.c
+++ b/tests/qtest/libqos/virtio-9p-client.c
@@ -643,16 +643,32 @@ void v9fs_free_dirents(struct V9fsDirent *e)
}
/* size[4] Tlopen tag[2] fid[4] flags[4] */
-P9Req *v9fs_tlopen(QVirtio9P *v9p, uint32_t fid, uint32_t flags,
- uint16_t tag)
+TLOpenRes v9fs_tlopen(TLOpenOpt opt)
{
P9Req *req;
+ uint32_t err;
- req = v9fs_req_init(v9p, 4 + 4, P9_TLOPEN, tag);
- v9fs_uint32_write(req, fid);
- v9fs_uint32_write(req, flags);
+ g_assert(opt.client);
+ /* expecting either Rlopen or Rlerror, but obviously not both */
+ g_assert(!opt.expectErr || !(opt.rlopen.qid || opt.rlopen.iounit));
+
+ req = v9fs_req_init(opt.client, 4 + 4, P9_TLOPEN, opt.tag);
+ v9fs_uint32_write(req, opt.fid);
+ v9fs_uint32_write(req, opt.flags);
v9fs_req_send(req);
- return req;
+
+ if (!opt.requestOnly) {
+ v9fs_req_wait_for_reply(req, NULL);
+ if (opt.expectErr) {
+ v9fs_rlerror(req, &err);
+ g_assert_cmpint(err, ==, opt.expectErr);
+ } else {
+ v9fs_rlopen(req, opt.rlopen.qid, opt.rlopen.iounit);
+ }
+ req = NULL; /* request was freed */
+ }
+
+ return (TLOpenRes) { .req = req };
}
/* size[4] Rlopen tag[2] qid[13] iounit[4] */