aboutsummaryrefslogtreecommitdiff
path: root/tests/qtest/libqos
diff options
context:
space:
mode:
authorChristian Schoenebeck <qemu_oss@crudebyte.com>2022-10-04 22:54:03 +0200
committerChristian Schoenebeck <qemu_oss@crudebyte.com>2022-10-24 12:24:32 +0200
commitd89146fd16775aa734b1e67b8fdee0301ad80cf5 (patch)
tree280fc94db43d39878c2b6934c58a67c2c55488c6 /tests/qtest/libqos
parentbb286ff8e85dcc222c93c9f3a164034561d1f585 (diff)
downloadqemu-d89146fd16775aa734b1e67b8fdee0301ad80cf5.zip
qemu-d89146fd16775aa734b1e67b8fdee0301ad80cf5.tar.gz
qemu-d89146fd16775aa734b1e67b8fdee0301ad80cf5.tar.bz2
tests/9p: convert v9fs_tflush() to declarative arguments
Use declarative function arguments for function v9fs_tflush(). Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com> Message-Id: <91b7b154298c500d100b05137146c2905c3acdec.1664917004.git.qemu_oss@crudebyte.com>
Diffstat (limited to 'tests/qtest/libqos')
-rw-r--r--tests/qtest/libqos/virtio-9p-client.c23
-rw-r--r--tests/qtest/libqos/virtio-9p-client.h22
2 files changed, 40 insertions, 5 deletions
diff --git a/tests/qtest/libqos/virtio-9p-client.c b/tests/qtest/libqos/virtio-9p-client.c
index 9ae347f..3be0ffc 100644
--- a/tests/qtest/libqos/virtio-9p-client.c
+++ b/tests/qtest/libqos/virtio-9p-client.c
@@ -733,14 +733,29 @@ void v9fs_rwrite(P9Req *req, uint32_t *count)
}
/* size[4] Tflush tag[2] oldtag[2] */
-P9Req *v9fs_tflush(QVirtio9P *v9p, uint16_t oldtag, uint16_t tag)
+TFlushRes v9fs_tflush(TFlushOpt opt)
{
P9Req *req;
+ uint32_t err;
+
+ g_assert(opt.client);
- req = v9fs_req_init(v9p, 2, P9_TFLUSH, tag);
- v9fs_uint32_write(req, oldtag);
+ req = v9fs_req_init(opt.client, 2, P9_TFLUSH, opt.tag);
+ v9fs_uint32_write(req, opt.oldtag);
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_rflush(req);
+ }
+ req = NULL; /* request was freed */
+ }
+
+ return (TFlushRes) { .req = req };
}
/* size[4] Rflush tag[2] */
diff --git a/tests/qtest/libqos/virtio-9p-client.h b/tests/qtest/libqos/virtio-9p-client.h
index dda371c..b22b54c 100644
--- a/tests/qtest/libqos/virtio-9p-client.h
+++ b/tests/qtest/libqos/virtio-9p-client.h
@@ -267,6 +267,26 @@ typedef struct TWriteRes {
uint32_t count;
} TWriteRes;
+/* options for 'Tflush' 9p request */
+typedef struct TFlushOpt {
+ /* 9P client being used (mandatory) */
+ QVirtio9P *client;
+ /* user supplied tag number being returned with response (optional) */
+ uint16_t tag;
+ /* message to flush (required) */
+ uint16_t oldtag;
+ /* only send Tflush request but not wait for a reply? (optional) */
+ bool requestOnly;
+ /* do we expect an Rlerror response, if yes which error code? (optional) */
+ uint32_t expectErr;
+} TFlushOpt;
+
+/* result of 'Tflush' 9p request */
+typedef struct TFlushRes {
+ /* if requestOnly was set: request object for further processing */
+ P9Req *req;
+} TFlushRes;
+
void v9fs_set_allocator(QGuestAllocator *t_alloc);
void v9fs_memwrite(P9Req *req, const void *addr, size_t len);
void v9fs_memskip(P9Req *req, size_t len);
@@ -304,7 +324,7 @@ TLOpenRes v9fs_tlopen(TLOpenOpt);
void v9fs_rlopen(P9Req *req, v9fs_qid *qid, uint32_t *iounit);
TWriteRes v9fs_twrite(TWriteOpt);
void v9fs_rwrite(P9Req *req, uint32_t *count);
-P9Req *v9fs_tflush(QVirtio9P *v9p, uint16_t oldtag, uint16_t tag);
+TFlushRes v9fs_tflush(TFlushOpt);
void v9fs_rflush(P9Req *req);
P9Req *v9fs_tmkdir(QVirtio9P *v9p, uint32_t dfid, const char *name,
uint32_t mode, uint32_t gid, uint16_t tag);