qemu-patch-raspberry4/hw/9pfs/9p-synth.h
Greg Kurz 2893ddd598 tests: virtio-9p: use the synth backend
The purpose of virtio-9p-test is to test the virtio-9p device, especially
the 9p server state machine. We don't really care what fsdev backend we're
using. Moreover, if we want to be able to test the flush request or a
device reset with in-flights I/O, it is close to impossible to achieve
with a physical backend because we cannot ask it reliably to put an I/O
on hold at a specific point in time.

Fortunately, we can do that with the synthetic backend, which allows to
register callbacks on read/write accesses to a specific file. This will
be used by a later patch to test the 9P flush request.

The walk request test is converted to using the synth backend.

Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2018-02-01 21:21:27 +01:00

57 lines
1.4 KiB
C

/*
* 9p
*
* Copyright IBM, Corp. 2011
*
* Authors:
* Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
*
* This work is licensed under the terms of the GNU GPL, version 2. See
* the COPYING file in the top-level directory.
*
*/
#ifndef QEMU_9P_SYNTH_H
#define QEMU_9P_SYNTH_H
typedef struct V9fsSynthNode V9fsSynthNode;
typedef ssize_t (*v9fs_synth_read)(void *buf, int len, off_t offset,
void *arg);
typedef ssize_t (*v9fs_synth_write)(void *buf, int len, off_t offset,
void *arg);
typedef struct V9fsSynthNodeAttr {
int mode;
int inode;
int nlink;
v9fs_synth_read read;
v9fs_synth_write write;
} V9fsSynthNodeAttr;
struct V9fsSynthNode {
QLIST_HEAD(, V9fsSynthNode) child;
QLIST_ENTRY(V9fsSynthNode) sibling;
char name[NAME_MAX];
V9fsSynthNodeAttr *attr;
V9fsSynthNodeAttr actual_attr;
void *private;
int open_count;
};
typedef struct V9fsSynthOpenState {
off_t offset;
V9fsSynthNode *node;
struct dirent dent;
} V9fsSynthOpenState;
int qemu_v9fs_synth_mkdir(V9fsSynthNode *parent, int mode,
const char *name, V9fsSynthNode **result);
int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode,
const char *name, v9fs_synth_read read,
v9fs_synth_write write, void *arg);
/* qtest stuff */
#define QTEST_V9FS_SYNTH_WALK_FILE "WALK%d"
#endif