]>
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" | |
7 | ||
8 | /* #define DEBUG_NBD */ | |
9 | ||
10 | #if defined(DEBUG_NBD) | |
11 | #define logout(fmt, ...) \ | |
12 | fprintf(stderr, "nbd\t%-24s" fmt, __func__, ##__VA_ARGS__) | |
13 | #else | |
14 | #define logout(fmt, ...) ((void)0) | |
15 | #endif | |
16 | ||
17 | #define MAX_NBD_REQUESTS 16 | |
18 | ||
19 | typedef struct NbdClientSession { | |
20 | int sock; | |
21 | uint32_t nbdflags; | |
22 | off_t size; | |
2302c1ca MAL |
23 | |
24 | CoMutex send_mutex; | |
25 | CoMutex free_sema; | |
26 | Coroutine *send_coroutine; | |
27 | int in_flight; | |
28 | ||
29 | Coroutine *recv_coroutine[MAX_NBD_REQUESTS]; | |
30 | struct nbd_reply reply; | |
31 | ||
2302c1ca | 32 | bool is_unix; |
2302c1ca MAL |
33 | } NbdClientSession; |
34 | ||
f53a829b HR |
35 | NbdClientSession *nbd_get_client_session(BlockDriverState *bs); |
36 | ||
37 | int nbd_client_init(BlockDriverState *bs, int sock, const char *export_name, | |
38 | Error **errp); | |
39 | void nbd_client_close(BlockDriverState *bs); | |
40 | ||
41 | int nbd_client_co_discard(BlockDriverState *bs, int64_t sector_num, | |
42 | int nb_sectors); | |
43 | int nbd_client_co_flush(BlockDriverState *bs); | |
44 | int nbd_client_co_writev(BlockDriverState *bs, int64_t sector_num, | |
45 | int nb_sectors, QEMUIOVector *qiov); | |
46 | int nbd_client_co_readv(BlockDriverState *bs, int64_t sector_num, | |
47 | int nb_sectors, QEMUIOVector *qiov); | |
48 | ||
49 | void nbd_client_detach_aio_context(BlockDriverState *bs); | |
50 | void nbd_client_attach_aio_context(BlockDriverState *bs, | |
51 | AioContext *new_context); | |
69447cd8 | 52 | |
2302c1ca | 53 | #endif /* NBD_CLIENT_H */ |