mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 01:03:55 -06:00
tests: virtio-9p: add FLUSH operation test
The idea is to send a victim request that will possibly block in the server and to send a flush request to cancel the victim request. This patch adds two test to verifiy that: - the server does not reply to a victim request that was actually cancelled - the server replies to the flush request after replying to the victim request if it could not cancel it 9p request cancellation reference: http://man.cat-v.org/plan_9/5/flush Signed-off-by: Greg Kurz <groug@kaod.org> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> (groug, change the test to only write a single byte to avoid any alignment or endianess consideration)
This commit is contained in:
parent
be3a678160
commit
357e2f7f4e
4 changed files with 132 additions and 13 deletions
|
@ -521,6 +521,20 @@ static ssize_t v9fs_synth_qtest_write(void *buf, int len, off_t offset,
|
|||
return 1;
|
||||
}
|
||||
|
||||
static ssize_t v9fs_synth_qtest_flush_write(void *buf, int len, off_t offset,
|
||||
void *arg)
|
||||
{
|
||||
bool should_block = !!*(uint8_t *)buf;
|
||||
|
||||
if (should_block) {
|
||||
/* This will cause the server to call us again until we're cancelled */
|
||||
errno = EINTR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int synth_init(FsContext *ctx, Error **errp)
|
||||
{
|
||||
QLIST_INIT(&synth_root.child);
|
||||
|
@ -557,6 +571,12 @@ static int synth_init(FsContext *ctx, Error **errp)
|
|||
ret = qemu_v9fs_synth_add_file(NULL, 0, QTEST_V9FS_SYNTH_WRITE_FILE,
|
||||
NULL, v9fs_synth_qtest_write, ctx);
|
||||
assert(!ret);
|
||||
|
||||
/* File for FLUSH test */
|
||||
ret = qemu_v9fs_synth_add_file(NULL, 0, QTEST_V9FS_SYNTH_FLUSH_FILE,
|
||||
NULL, v9fs_synth_qtest_flush_write,
|
||||
ctx);
|
||||
assert(!ret);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue