]>
Commit | Line | Data |
---|---|---|
2302c1ca MAL |
1 | #ifndef NBD_CLIENT_H |
2 | #define NBD_CLIENT_H | |
3 | ||
4 | #include "qemu-common.h" | |
5 | #include "block/nbd.h" | |
6 | #include "block/block_int.h" | |
064097d9 | 7 | #include "io/channel-socket.h" |
2302c1ca MAL |
8 | |
9 | /* #define DEBUG_NBD */ | |
10 | ||
11 | #if defined(DEBUG_NBD) | |
12 | #define logout(fmt, ...) \ | |
13 | fprintf(stderr, "nbd\t%-24s" fmt, __func__, ##__VA_ARGS__) | |
14 | #else | |
15 | #define logout(fmt, ...) ((void)0) | |
16 | #endif | |
17 | ||
18 | #define MAX_NBD_REQUESTS 16 | |
19 | ||
20 | typedef struct NbdClientSession { | |
064097d9 DB |
21 | QIOChannelSocket *sioc; /* The master data channel */ |
22 | QIOChannel *ioc; /* The current I/O channel which may differ (eg TLS) */ | |
2302c1ca MAL |
23 | uint32_t nbdflags; |
24 | off_t size; | |
2302c1ca MAL |
25 | |
26 | CoMutex send_mutex; | |
27 | CoMutex free_sema; | |
28 | Coroutine *send_coroutine; | |
29 | int in_flight; | |
30 | ||
31 | Coroutine *recv_coroutine[MAX_NBD_REQUESTS]; | |
32 | struct nbd_reply reply; | |
33 | ||
2302c1ca | 34 | bool is_unix; |
2302c1ca MAL |
35 | } NbdClientSession; |
36 | ||
f53a829b HR |
37 | NbdClientSession *nbd_get_client_session(BlockDriverState *bs); |
38 | ||
064097d9 DB |
39 | int nbd_client_init(BlockDriverState *bs, |
40 | QIOChannelSocket *sock, | |
41 | const char *export_name, | |
f53a829b HR |
42 | Error **errp); |
43 | void nbd_client_close(BlockDriverState *bs); | |
44 | ||
45 | int nbd_client_co_discard(BlockDriverState *bs, int64_t sector_num, | |
46 | int nb_sectors); | |
47 | int nbd_client_co_flush(BlockDriverState *bs); | |
48 | int nbd_client_co_writev(BlockDriverState *bs, int64_t sector_num, | |
49 | int nb_sectors, QEMUIOVector *qiov); | |
50 | int nbd_client_co_readv(BlockDriverState *bs, int64_t sector_num, | |
51 | int nb_sectors, QEMUIOVector *qiov); | |
52 | ||
53 | void nbd_client_detach_aio_context(BlockDriverState *bs); | |
54 | void nbd_client_attach_aio_context(BlockDriverState *bs, | |
55 | AioContext *new_context); | |
69447cd8 | 56 | |
2302c1ca | 57 | #endif /* NBD_CLIENT_H */ |