2 * QTest testcase for VirtIO 9P
4 * Copyright (c) 2014 SUSE LINUX Products GmbH
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
10 #include "qemu/osdep.h"
11 #include "libqtest-single.h"
12 #include "qemu/module.h"
13 #include "hw/9pfs/9p.h"
14 #include "hw/9pfs/9p-synth.h"
15 #include "libqos/virtio-9p.h"
16 #include "libqos/qgraph.h"
18 #define QVIRTIO_9P_TIMEOUT_US (10 * 1000 * 1000)
19 static QGuestAllocator
*alloc
;
21 static void pci_config(void *obj
, void *data
, QGuestAllocator
*t_alloc
)
25 size_t tag_len
= qvirtio_config_readw(v9p
->vdev
, 0);
29 g_assert_cmpint(tag_len
, ==, strlen(MOUNT_TAG
));
31 tag
= g_malloc(tag_len
);
32 for (i
= 0; i
< tag_len
; i
++) {
33 tag
[i
] = qvirtio_config_readb(v9p
->vdev
, i
+ 2);
35 g_assert_cmpmem(tag
, tag_len
, MOUNT_TAG
, tag_len
);
39 #define P9_MAX_SIZE 4096 /* Max size of a T-message or R-message */
48 /* No r_size, it is hardcoded to P9_MAX_SIZE */
54 static void v9fs_memwrite(P9Req
*req
, const void *addr
, size_t len
)
56 qtest_memwrite(req
->qts
, req
->t_msg
+ req
->t_off
, addr
, len
);
60 static void v9fs_memskip(P9Req
*req
, size_t len
)
65 static void v9fs_memread(P9Req
*req
, void *addr
, size_t len
)
67 qtest_memread(req
->qts
, req
->r_msg
+ req
->r_off
, addr
, len
);
71 static void v9fs_uint8_read(P9Req
*req
, uint8_t *val
)
73 v9fs_memread(req
, val
, 1);
76 static void v9fs_uint16_write(P9Req
*req
, uint16_t val
)
78 uint16_t le_val
= cpu_to_le16(val
);
80 v9fs_memwrite(req
, &le_val
, 2);
83 static void v9fs_uint16_read(P9Req
*req
, uint16_t *val
)
85 v9fs_memread(req
, val
, 2);
89 static void v9fs_uint32_write(P9Req
*req
, uint32_t val
)
91 uint32_t le_val
= cpu_to_le32(val
);
93 v9fs_memwrite(req
, &le_val
, 4);
96 static void v9fs_uint64_write(P9Req
*req
, uint64_t val
)
98 uint64_t le_val
= cpu_to_le64(val
);
100 v9fs_memwrite(req
, &le_val
, 8);
103 static void v9fs_uint32_read(P9Req
*req
, uint32_t *val
)
105 v9fs_memread(req
, val
, 4);
109 static void v9fs_uint64_read(P9Req
*req
, uint64_t *val
)
111 v9fs_memread(req
, val
, 8);
115 /* len[2] string[len] */
116 static uint16_t v9fs_string_size(const char *string
)
118 size_t len
= strlen(string
);
120 g_assert_cmpint(len
, <=, UINT16_MAX
- 2);
125 static void v9fs_string_write(P9Req
*req
, const char *string
)
127 int len
= strlen(string
);
129 g_assert_cmpint(len
, <=, UINT16_MAX
);
131 v9fs_uint16_write(req
, (uint16_t) len
);
132 v9fs_memwrite(req
, string
, len
);
135 static void v9fs_string_read(P9Req
*req
, uint16_t *len
, char **string
)
139 v9fs_uint16_read(req
, &local_len
);
144 *string
= g_malloc(local_len
+ 1);
145 v9fs_memread(req
, *string
, local_len
);
146 (*string
)[local_len
] = 0;
148 v9fs_memskip(req
, local_len
);
158 static P9Req
*v9fs_req_init(QVirtio9P
*v9p
, uint32_t size
, uint8_t id
,
161 P9Req
*req
= g_new0(P9Req
, 1);
162 uint32_t total_size
= 7; /* 9P header has well-known size of 7 bytes */
165 .tag
= cpu_to_le16(tag
)
168 g_assert_cmpint(total_size
, <=, UINT32_MAX
- size
);
170 hdr
.size
= cpu_to_le32(total_size
);
172 g_assert_cmpint(total_size
, <=, P9_MAX_SIZE
);
174 req
->qts
= global_qtest
;
176 req
->t_size
= total_size
;
177 req
->t_msg
= guest_alloc(alloc
, req
->t_size
);
178 v9fs_memwrite(req
, &hdr
, 7);
183 static void v9fs_req_send(P9Req
*req
)
185 QVirtio9P
*v9p
= req
->v9p
;
187 req
->r_msg
= guest_alloc(alloc
, P9_MAX_SIZE
);
188 req
->free_head
= qvirtqueue_add(req
->qts
, v9p
->vq
, req
->t_msg
, req
->t_size
,
190 qvirtqueue_add(req
->qts
, v9p
->vq
, req
->r_msg
, P9_MAX_SIZE
, true, false);
191 qvirtqueue_kick(req
->qts
, v9p
->vdev
, v9p
->vq
, req
->free_head
);
195 static const char *rmessage_name(uint8_t id
)
198 id
== P9_RLERROR
? "RLERROR" :
199 id
== P9_RVERSION
? "RVERSION" :
200 id
== P9_RATTACH
? "RATTACH" :
201 id
== P9_RWALK
? "RWALK" :
202 id
== P9_RLOPEN
? "RLOPEN" :
203 id
== P9_RWRITE
? "RWRITE" :
204 id
== P9_RFLUSH
? "RFLUSH" :
205 id
== P9_RREADDIR
? "READDIR" :
209 static void v9fs_req_wait_for_reply(P9Req
*req
, uint32_t *len
)
211 QVirtio9P
*v9p
= req
->v9p
;
213 qvirtio_wait_used_elem(req
->qts
, v9p
->vdev
, v9p
->vq
, req
->free_head
, len
,
214 QVIRTIO_9P_TIMEOUT_US
);
217 static void v9fs_req_recv(P9Req
*req
, uint8_t id
)
221 v9fs_memread(req
, &hdr
, 7);
222 hdr
.size
= ldl_le_p(&hdr
.size
);
223 hdr
.tag
= lduw_le_p(&hdr
.tag
);
225 g_assert_cmpint(hdr
.size
, >=, 7);
226 g_assert_cmpint(hdr
.size
, <=, P9_MAX_SIZE
);
227 g_assert_cmpint(hdr
.tag
, ==, req
->tag
);
230 g_printerr("Received response %d (%s) instead of %d (%s)\n",
231 hdr
.id
, rmessage_name(hdr
.id
), id
, rmessage_name(id
));
233 if (hdr
.id
== P9_RLERROR
) {
235 v9fs_uint32_read(req
, &err
);
236 g_printerr("Rlerror has errno %d (%s)\n", err
, strerror(err
));
239 g_assert_cmpint(hdr
.id
, ==, id
);
242 static void v9fs_req_free(P9Req
*req
)
244 guest_free(alloc
, req
->t_msg
);
245 guest_free(alloc
, req
->r_msg
);
249 /* size[4] Rlerror tag[2] ecode[4] */
250 static void v9fs_rlerror(P9Req
*req
, uint32_t *err
)
252 v9fs_req_recv(req
, P9_RLERROR
);
253 v9fs_uint32_read(req
, err
);
257 /* size[4] Tversion tag[2] msize[4] version[s] */
258 static P9Req
*v9fs_tversion(QVirtio9P
*v9p
, uint32_t msize
, const char *version
,
262 uint32_t body_size
= 4;
263 uint16_t string_size
= v9fs_string_size(version
);
265 g_assert_cmpint(body_size
, <=, UINT32_MAX
- string_size
);
266 body_size
+= string_size
;
267 req
= v9fs_req_init(v9p
, body_size
, P9_TVERSION
, tag
);
269 v9fs_uint32_write(req
, msize
);
270 v9fs_string_write(req
, version
);
275 /* size[4] Rversion tag[2] msize[4] version[s] */
276 static void v9fs_rversion(P9Req
*req
, uint16_t *len
, char **version
)
280 v9fs_req_recv(req
, P9_RVERSION
);
281 v9fs_uint32_read(req
, &msize
);
283 g_assert_cmpint(msize
, ==, P9_MAX_SIZE
);
285 if (len
|| version
) {
286 v9fs_string_read(req
, len
, version
);
292 /* size[4] Tattach tag[2] fid[4] afid[4] uname[s] aname[s] n_uname[4] */
293 static P9Req
*v9fs_tattach(QVirtio9P
*v9p
, uint32_t fid
, uint32_t n_uname
,
296 const char *uname
= ""; /* ignored by QEMU */
297 const char *aname
= ""; /* ignored by QEMU */
298 P9Req
*req
= v9fs_req_init(v9p
, 4 + 4 + 2 + 2 + 4, P9_TATTACH
, tag
);
300 v9fs_uint32_write(req
, fid
);
301 v9fs_uint32_write(req
, P9_NOFID
);
302 v9fs_string_write(req
, uname
);
303 v9fs_string_write(req
, aname
);
304 v9fs_uint32_write(req
, n_uname
);
309 typedef char v9fs_qid
[13];
311 /* size[4] Rattach tag[2] qid[13] */
312 static void v9fs_rattach(P9Req
*req
, v9fs_qid
*qid
)
314 v9fs_req_recv(req
, P9_RATTACH
);
316 v9fs_memread(req
, qid
, 13);
321 /* size[4] Twalk tag[2] fid[4] newfid[4] nwname[2] nwname*(wname[s]) */
322 static P9Req
*v9fs_twalk(QVirtio9P
*v9p
, uint32_t fid
, uint32_t newfid
,
323 uint16_t nwname
, char *const wnames
[], uint16_t tag
)
327 uint32_t body_size
= 4 + 4 + 2;
329 for (i
= 0; i
< nwname
; i
++) {
330 uint16_t wname_size
= v9fs_string_size(wnames
[i
]);
332 g_assert_cmpint(body_size
, <=, UINT32_MAX
- wname_size
);
333 body_size
+= wname_size
;
335 req
= v9fs_req_init(v9p
, body_size
, P9_TWALK
, tag
);
336 v9fs_uint32_write(req
, fid
);
337 v9fs_uint32_write(req
, newfid
);
338 v9fs_uint16_write(req
, nwname
);
339 for (i
= 0; i
< nwname
; i
++) {
340 v9fs_string_write(req
, wnames
[i
]);
346 /* size[4] Rwalk tag[2] nwqid[2] nwqid*(wqid[13]) */
347 static void v9fs_rwalk(P9Req
*req
, uint16_t *nwqid
, v9fs_qid
**wqid
)
349 uint16_t local_nwqid
;
351 v9fs_req_recv(req
, P9_RWALK
);
352 v9fs_uint16_read(req
, &local_nwqid
);
354 *nwqid
= local_nwqid
;
357 *wqid
= g_malloc(local_nwqid
* 13);
358 v9fs_memread(req
, *wqid
, local_nwqid
* 13);
363 /* size[4] Treaddir tag[2] fid[4] offset[8] count[4] */
364 static P9Req
*v9fs_treaddir(QVirtio9P
*v9p
, uint32_t fid
, uint64_t offset
,
365 uint32_t count
, uint16_t tag
)
369 req
= v9fs_req_init(v9p
, 4 + 8 + 4, P9_TREADDIR
, tag
);
370 v9fs_uint32_write(req
, fid
);
371 v9fs_uint64_write(req
, offset
);
372 v9fs_uint32_write(req
, count
);
382 struct V9fsDirent
*next
;
385 /* size[4] Rreaddir tag[2] count[4] data[count] */
386 static void v9fs_rreaddir(P9Req
*req
, uint32_t *count
, uint32_t *nentries
,
387 struct V9fsDirent
**entries
)
389 uint32_t local_count
;
390 struct V9fsDirent
*e
= NULL
;
394 v9fs_req_recv(req
, P9_RREADDIR
);
395 v9fs_uint32_read(req
, &local_count
);
398 *count
= local_count
;
401 for (int32_t togo
= (int32_t)local_count
;
402 togo
>= 13 + 8 + 1 + 2;
403 togo
-= 13 + 8 + 1 + 2 + slen
, ++n
)
406 e
= g_malloc(sizeof(struct V9fsDirent
));
411 e
= e
->next
= g_malloc(sizeof(struct V9fsDirent
));
414 /* qid[13] offset[8] type[1] name[s] */
415 v9fs_memread(req
, &e
->qid
, 13);
416 v9fs_uint64_read(req
, &e
->offset
);
417 v9fs_uint8_read(req
, &e
->type
);
418 v9fs_string_read(req
, &slen
, &e
->name
);
428 static void v9fs_free_dirents(struct V9fsDirent
*e
)
430 struct V9fsDirent
*next
= NULL
;
432 for (; e
; e
= next
) {
439 /* size[4] Tlopen tag[2] fid[4] flags[4] */
440 static P9Req
*v9fs_tlopen(QVirtio9P
*v9p
, uint32_t fid
, uint32_t flags
,
445 req
= v9fs_req_init(v9p
, 4 + 4, P9_TLOPEN
, tag
);
446 v9fs_uint32_write(req
, fid
);
447 v9fs_uint32_write(req
, flags
);
452 /* size[4] Rlopen tag[2] qid[13] iounit[4] */
453 static void v9fs_rlopen(P9Req
*req
, v9fs_qid
*qid
, uint32_t *iounit
)
455 v9fs_req_recv(req
, P9_RLOPEN
);
457 v9fs_memread(req
, qid
, 13);
459 v9fs_memskip(req
, 13);
462 v9fs_uint32_read(req
, iounit
);
467 /* size[4] Twrite tag[2] fid[4] offset[8] count[4] data[count] */
468 static P9Req
*v9fs_twrite(QVirtio9P
*v9p
, uint32_t fid
, uint64_t offset
,
469 uint32_t count
, const void *data
, uint16_t tag
)
472 uint32_t body_size
= 4 + 8 + 4;
474 g_assert_cmpint(body_size
, <=, UINT32_MAX
- count
);
476 req
= v9fs_req_init(v9p
, body_size
, P9_TWRITE
, tag
);
477 v9fs_uint32_write(req
, fid
);
478 v9fs_uint64_write(req
, offset
);
479 v9fs_uint32_write(req
, count
);
480 v9fs_memwrite(req
, data
, count
);
485 /* size[4] Rwrite tag[2] count[4] */
486 static void v9fs_rwrite(P9Req
*req
, uint32_t *count
)
488 v9fs_req_recv(req
, P9_RWRITE
);
490 v9fs_uint32_read(req
, count
);
495 /* size[4] Tflush tag[2] oldtag[2] */
496 static P9Req
*v9fs_tflush(QVirtio9P
*v9p
, uint16_t oldtag
, uint16_t tag
)
500 req
= v9fs_req_init(v9p
, 2, P9_TFLUSH
, tag
);
501 v9fs_uint32_write(req
, oldtag
);
506 /* size[4] Rflush tag[2] */
507 static void v9fs_rflush(P9Req
*req
)
509 v9fs_req_recv(req
, P9_RFLUSH
);
513 static void fs_version(void *obj
, void *data
, QGuestAllocator
*t_alloc
)
515 QVirtio9P
*v9p
= obj
;
517 const char *version
= "9P2000.L";
519 char *server_version
;
522 req
= v9fs_tversion(v9p
, P9_MAX_SIZE
, version
, P9_NOTAG
);
523 v9fs_req_wait_for_reply(req
, NULL
);
524 v9fs_rversion(req
, &server_len
, &server_version
);
526 g_assert_cmpmem(server_version
, server_len
, version
, strlen(version
));
528 g_free(server_version
);
531 static void fs_attach(void *obj
, void *data
, QGuestAllocator
*t_alloc
)
533 QVirtio9P
*v9p
= obj
;
537 fs_version(v9p
, NULL
, t_alloc
);
538 req
= v9fs_tattach(v9p
, 0, getuid(), 0);
539 v9fs_req_wait_for_reply(req
, NULL
);
540 v9fs_rattach(req
, NULL
);
543 static void fs_walk(void *obj
, void *data
, QGuestAllocator
*t_alloc
)
545 QVirtio9P
*v9p
= obj
;
547 char *wnames
[P9_MAXWELEM
];
553 for (i
= 0; i
< P9_MAXWELEM
; i
++) {
554 wnames
[i
] = g_strdup_printf(QTEST_V9FS_SYNTH_WALK_FILE
, i
);
557 fs_attach(v9p
, NULL
, t_alloc
);
558 req
= v9fs_twalk(v9p
, 0, 1, P9_MAXWELEM
, wnames
, 0);
559 v9fs_req_wait_for_reply(req
, NULL
);
560 v9fs_rwalk(req
, &nwqid
, &wqid
);
562 g_assert_cmpint(nwqid
, ==, P9_MAXWELEM
);
564 for (i
= 0; i
< P9_MAXWELEM
; i
++) {
571 static bool fs_dirents_contain_name(struct V9fsDirent
*e
, const char* name
)
573 for (; e
; e
= e
->next
) {
574 if (!strcmp(e
->name
, name
)) {
581 static void fs_readdir(void *obj
, void *data
, QGuestAllocator
*t_alloc
)
583 QVirtio9P
*v9p
= obj
;
585 char *const wnames
[] = { g_strdup(QTEST_V9FS_SYNTH_READDIR_DIR
) };
588 uint32_t count
, nentries
;
589 struct V9fsDirent
*entries
= NULL
;
592 fs_attach(v9p
, NULL
, t_alloc
);
593 req
= v9fs_twalk(v9p
, 0, 1, 1, wnames
, 0);
594 v9fs_req_wait_for_reply(req
, NULL
);
595 v9fs_rwalk(req
, &nqid
, NULL
);
596 g_assert_cmpint(nqid
, ==, 1);
598 req
= v9fs_tlopen(v9p
, 1, O_DIRECTORY
, 0);
599 v9fs_req_wait_for_reply(req
, NULL
);
600 v9fs_rlopen(req
, &qid
, NULL
);
603 * submit count = msize - 11, because 11 is the header size of Rreaddir
605 req
= v9fs_treaddir(v9p
, 1, 0, P9_MAX_SIZE
- 11, 0);
606 v9fs_req_wait_for_reply(req
, NULL
);
607 v9fs_rreaddir(req
, &count
, &nentries
, &entries
);
610 * Assuming msize (P9_MAX_SIZE) is large enough so we can retrieve all
611 * dir entries with only one readdir request.
615 QTEST_V9FS_SYNTH_READDIR_NFILES
+ 2 /* "." and ".." */
619 * Check all file names exist in returned entries, ignore their order
622 g_assert_cmpint(fs_dirents_contain_name(entries
, "."), ==, true);
623 g_assert_cmpint(fs_dirents_contain_name(entries
, ".."), ==, true);
624 for (int i
= 0; i
< QTEST_V9FS_SYNTH_READDIR_NFILES
; ++i
) {
625 char *name
= g_strdup_printf(QTEST_V9FS_SYNTH_READDIR_FILE
, i
);
626 g_assert_cmpint(fs_dirents_contain_name(entries
, name
), ==, true);
630 v9fs_free_dirents(entries
);
634 static void fs_walk_no_slash(void *obj
, void *data
, QGuestAllocator
*t_alloc
)
636 QVirtio9P
*v9p
= obj
;
638 char *const wnames
[] = { g_strdup(" /") };
642 fs_attach(v9p
, NULL
, t_alloc
);
643 req
= v9fs_twalk(v9p
, 0, 1, 1, wnames
, 0);
644 v9fs_req_wait_for_reply(req
, NULL
);
645 v9fs_rlerror(req
, &err
);
647 g_assert_cmpint(err
, ==, ENOENT
);
652 static void fs_walk_dotdot(void *obj
, void *data
, QGuestAllocator
*t_alloc
)
654 QVirtio9P
*v9p
= obj
;
656 char *const wnames
[] = { g_strdup("..") };
657 v9fs_qid root_qid
, *wqid
;
660 fs_version(v9p
, NULL
, t_alloc
);
661 req
= v9fs_tattach(v9p
, 0, getuid(), 0);
662 v9fs_req_wait_for_reply(req
, NULL
);
663 v9fs_rattach(req
, &root_qid
);
665 req
= v9fs_twalk(v9p
, 0, 1, 1, wnames
, 0);
666 v9fs_req_wait_for_reply(req
, NULL
);
667 v9fs_rwalk(req
, NULL
, &wqid
); /* We now we'll get one qid */
669 g_assert_cmpmem(&root_qid
, 13, wqid
[0], 13);
675 static void fs_lopen(void *obj
, void *data
, QGuestAllocator
*t_alloc
)
677 QVirtio9P
*v9p
= obj
;
679 char *const wnames
[] = { g_strdup(QTEST_V9FS_SYNTH_LOPEN_FILE
) };
682 fs_attach(v9p
, NULL
, t_alloc
);
683 req
= v9fs_twalk(v9p
, 0, 1, 1, wnames
, 0);
684 v9fs_req_wait_for_reply(req
, NULL
);
685 v9fs_rwalk(req
, NULL
, NULL
);
687 req
= v9fs_tlopen(v9p
, 1, O_WRONLY
, 0);
688 v9fs_req_wait_for_reply(req
, NULL
);
689 v9fs_rlopen(req
, NULL
, NULL
);
694 static void fs_write(void *obj
, void *data
, QGuestAllocator
*t_alloc
)
696 QVirtio9P
*v9p
= obj
;
698 static const uint32_t write_count
= P9_MAX_SIZE
/ 2;
699 char *const wnames
[] = { g_strdup(QTEST_V9FS_SYNTH_WRITE_FILE
) };
700 char *buf
= g_malloc0(write_count
);
704 fs_attach(v9p
, NULL
, t_alloc
);
705 req
= v9fs_twalk(v9p
, 0, 1, 1, wnames
, 0);
706 v9fs_req_wait_for_reply(req
, NULL
);
707 v9fs_rwalk(req
, NULL
, NULL
);
709 req
= v9fs_tlopen(v9p
, 1, O_WRONLY
, 0);
710 v9fs_req_wait_for_reply(req
, NULL
);
711 v9fs_rlopen(req
, NULL
, NULL
);
713 req
= v9fs_twrite(v9p
, 1, 0, write_count
, buf
, 0);
714 v9fs_req_wait_for_reply(req
, NULL
);
715 v9fs_rwrite(req
, &count
);
716 g_assert_cmpint(count
, ==, write_count
);
722 static void fs_flush_success(void *obj
, void *data
, QGuestAllocator
*t_alloc
)
724 QVirtio9P
*v9p
= obj
;
726 char *const wnames
[] = { g_strdup(QTEST_V9FS_SYNTH_FLUSH_FILE
) };
727 P9Req
*req
, *flush_req
;
729 uint8_t should_block
;
731 fs_attach(v9p
, NULL
, t_alloc
);
732 req
= v9fs_twalk(v9p
, 0, 1, 1, wnames
, 0);
733 v9fs_req_wait_for_reply(req
, NULL
);
734 v9fs_rwalk(req
, NULL
, NULL
);
736 req
= v9fs_tlopen(v9p
, 1, O_WRONLY
, 0);
737 v9fs_req_wait_for_reply(req
, NULL
);
738 v9fs_rlopen(req
, NULL
, NULL
);
740 /* This will cause the 9p server to try to write data to the backend,
741 * until the write request gets cancelled.
744 req
= v9fs_twrite(v9p
, 1, 0, sizeof(should_block
), &should_block
, 0);
746 flush_req
= v9fs_tflush(v9p
, req
->tag
, 1);
748 /* The write request is supposed to be flushed: the server should just
749 * mark the write request as used and reply to the flush request.
751 v9fs_req_wait_for_reply(req
, &reply_len
);
752 g_assert_cmpint(reply_len
, ==, 0);
754 v9fs_rflush(flush_req
);
759 static void fs_flush_ignored(void *obj
, void *data
, QGuestAllocator
*t_alloc
)
761 QVirtio9P
*v9p
= obj
;
763 char *const wnames
[] = { g_strdup(QTEST_V9FS_SYNTH_FLUSH_FILE
) };
764 P9Req
*req
, *flush_req
;
766 uint8_t should_block
;
768 fs_attach(v9p
, NULL
, t_alloc
);
769 req
= v9fs_twalk(v9p
, 0, 1, 1, wnames
, 0);
770 v9fs_req_wait_for_reply(req
, NULL
);
771 v9fs_rwalk(req
, NULL
, NULL
);
773 req
= v9fs_tlopen(v9p
, 1, O_WRONLY
, 0);
774 v9fs_req_wait_for_reply(req
, NULL
);
775 v9fs_rlopen(req
, NULL
, NULL
);
777 /* This will cause the write request to complete right away, before it
778 * could be actually cancelled.
781 req
= v9fs_twrite(v9p
, 1, 0, sizeof(should_block
), &should_block
, 0);
783 flush_req
= v9fs_tflush(v9p
, req
->tag
, 1);
785 /* The write request is supposed to complete. The server should
786 * reply to the write request and the flush request.
788 v9fs_req_wait_for_reply(req
, NULL
);
789 v9fs_rwrite(req
, &count
);
790 g_assert_cmpint(count
, ==, sizeof(should_block
));
791 v9fs_rflush(flush_req
);
796 static void register_virtio_9p_test(void)
798 qos_add_test("config", "virtio-9p", pci_config
, NULL
);
799 qos_add_test("fs/version/basic", "virtio-9p", fs_version
, NULL
);
800 qos_add_test("fs/attach/basic", "virtio-9p", fs_attach
, NULL
);
801 qos_add_test("fs/walk/basic", "virtio-9p", fs_walk
, NULL
);
802 qos_add_test("fs/walk/no_slash", "virtio-9p", fs_walk_no_slash
,
804 qos_add_test("fs/walk/dotdot_from_root", "virtio-9p",
805 fs_walk_dotdot
, NULL
);
806 qos_add_test("fs/lopen/basic", "virtio-9p", fs_lopen
, NULL
);
807 qos_add_test("fs/write/basic", "virtio-9p", fs_write
, NULL
);
808 qos_add_test("fs/flush/success", "virtio-9p", fs_flush_success
,
810 qos_add_test("fs/flush/ignored", "virtio-9p", fs_flush_ignored
,
812 qos_add_test("fs/readdir/basic", "virtio-9p", fs_readdir
, NULL
);
815 libqos_init(register_virtio_9p_test
);