All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Schoenebeck <qemu_oss@crudebyte.com>
To: qemu-devel@nongnu.org
Cc: Greg Kurz <groug@kaod.org>
Subject: [PATCH 14/20] tests/9p: convert v9fs_tflush() to declarative arguments
Date: Tue, 4 Oct 2022 22:54:03 +0200	[thread overview]
Message-ID: <91b7b154298c500d100b05137146c2905c3acdec.1664917004.git.qemu_oss@crudebyte.com> (raw)
In-Reply-To: <cover.1664917004.git.qemu_oss@crudebyte.com>

Use declarative function arguments for function v9fs_tflush().

Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
---
 tests/qtest/libqos/virtio-9p-client.c | 23 +++++++++++++++++++----
 tests/qtest/libqos/virtio-9p-client.h | 22 +++++++++++++++++++++-
 tests/qtest/virtio-9p-test.c          |  9 +++++++--
 3 files changed, 47 insertions(+), 7 deletions(-)

diff --git a/tests/qtest/libqos/virtio-9p-client.c b/tests/qtest/libqos/virtio-9p-client.c
index 9ae347fad5..3be0ffc7da 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;
 
-    req = v9fs_req_init(v9p,  2, P9_TFLUSH, tag);
-    v9fs_uint32_write(req, oldtag);
+    g_assert(opt.client);
+
+    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 dda371c054..b22b54c720 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);
diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c
index 5ad7bebec7..5544998bac 100644
--- a/tests/qtest/virtio-9p-test.c
+++ b/tests/qtest/virtio-9p-test.c
@@ -23,6 +23,7 @@
 #define treaddir(...) v9fs_treaddir((TReadDirOpt) __VA_ARGS__)
 #define tlopen(...) v9fs_tlopen((TLOpenOpt) __VA_ARGS__)
 #define twrite(...) v9fs_twrite((TWriteOpt) __VA_ARGS__)
+#define tflush(...) v9fs_tflush((TFlushOpt) __VA_ARGS__)
 
 static void pci_config(void *obj, void *data, QGuestAllocator *t_alloc)
 {
@@ -420,7 +421,9 @@ static void fs_flush_success(void *obj, void *data, QGuestAllocator *t_alloc)
         .requestOnly = true
     }).req;
 
-    flush_req = v9fs_tflush(v9p, req->tag, 1);
+    flush_req = tflush({
+        .client = v9p, .oldtag = req->tag, .tag = 1, .requestOnly = true
+    }).req;
 
     /* The write request is supposed to be flushed: the server should just
      * mark the write request as used and reply to the flush request.
@@ -459,7 +462,9 @@ static void fs_flush_ignored(void *obj, void *data, QGuestAllocator *t_alloc)
         .requestOnly = true
     }).req;
 
-    flush_req = v9fs_tflush(v9p, req->tag, 1);
+    flush_req = tflush({
+        .client = v9p, .oldtag = req->tag, .tag = 1, .requestOnly = true
+    }).req;
 
     /* The write request is supposed to complete. The server should
      * reply to the write request and the flush request.
-- 
2.30.2



  parent reply	other threads:[~2022-10-04 21:41 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-04 20:56 [PATCH 00/20] tests/9p: introduce declarative function calls Christian Schoenebeck
2022-10-04 20:53 ` [PATCH 01/20] tests/9p: merge *walk*() functions Christian Schoenebeck
2022-10-04 20:53 ` [PATCH 02/20] tests/9p: simplify callers of twalk() Christian Schoenebeck
2022-10-04 20:53 ` [PATCH 03/20] tests/9p: merge v9fs_tversion() and do_version() Christian Schoenebeck
2022-10-04 20:53 ` [PATCH 04/20] tests/9p: merge v9fs_tattach(), do_attach(), do_attach_rqid() Christian Schoenebeck
2022-10-04 20:53 ` [PATCH 05/20] tests/9p: simplify callers of tattach() Christian Schoenebeck
2022-10-04 20:53 ` [PATCH 06/20] tests/9p: convert v9fs_tgetattr() to declarative arguments Christian Schoenebeck
2022-10-04 20:53 ` [PATCH 07/20] tests/9p: simplify callers of tgetattr() Christian Schoenebeck
2022-10-04 20:53 ` [PATCH 08/20] tests/9p: convert v9fs_treaddir() to declarative arguments Christian Schoenebeck
2022-10-04 20:53 ` [PATCH 09/20] tests/9p: simplify callers of treaddir() Christian Schoenebeck
2022-10-04 20:53 ` [PATCH 10/20] tests/9p: convert v9fs_tlopen() to declarative arguments Christian Schoenebeck
2022-10-04 20:53 ` [PATCH 11/20] tests/9p: simplify callers of tlopen() Christian Schoenebeck
2022-10-04 20:53 ` [PATCH 12/20] tests/9p: convert v9fs_twrite() to declarative arguments Christian Schoenebeck
2022-10-04 20:54 ` [PATCH 13/20] tests/9p: simplify callers of twrite() Christian Schoenebeck
2022-10-04 20:54 ` Christian Schoenebeck [this message]
2022-10-04 20:54 ` [PATCH 15/20] tests/9p: merge v9fs_tmkdir() and do_mkdir() Christian Schoenebeck
2022-10-04 20:54 ` [PATCH 16/20] tests/9p: merge v9fs_tlcreate() and do_lcreate() Christian Schoenebeck
2022-10-04 20:54 ` [PATCH 17/20] tests/9p: merge v9fs_tsymlink() and do_symlink() Christian Schoenebeck
2022-10-04 20:54 ` [PATCH 18/20] tests/9p: merge v9fs_tlink() and do_hardlink() Christian Schoenebeck
2022-10-04 20:54 ` [PATCH 19/20] tests/9p: merge v9fs_tunlinkat() and do_unlinkat() Christian Schoenebeck
2022-10-04 20:54 ` [PATCH 20/20] tests/9p: remove unnecessary g_strdup() calls Christian Schoenebeck
2022-10-12 10:00 ` [PATCH 00/20] tests/9p: introduce declarative function calls Christian Schoenebeck
2022-10-12 13:58   ` Greg Kurz
2022-10-13 13:34     ` Christian Schoenebeck
2022-10-18 11:54 ` 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=91b7b154298c500d100b05137146c2905c3acdec.1664917004.git.qemu_oss@crudebyte.com \
    --to=qemu_oss@crudebyte.com \
    --cc=groug@kaod.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.