]> Git Repo - qemu.git/blob - block/nbd-client.h
target-ppc : Add new processor type 440x5wDFPU
[qemu.git] / block / nbd-client.h
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;
23     size_t blocksize;
24
25     CoMutex send_mutex;
26     CoMutex free_sema;
27     Coroutine *send_coroutine;
28     int in_flight;
29
30     Coroutine *recv_coroutine[MAX_NBD_REQUESTS];
31     struct nbd_reply reply;
32
33     bool is_unix;
34
35     BlockDriverState *bs;
36 } NbdClientSession;
37
38 int nbd_client_session_init(NbdClientSession *client, BlockDriverState *bs,
39                             int sock, const char *export_name);
40 void nbd_client_session_close(NbdClientSession *client);
41
42 int nbd_client_session_co_discard(NbdClientSession *client, int64_t sector_num,
43                                   int nb_sectors);
44 int nbd_client_session_co_flush(NbdClientSession *client);
45 int nbd_client_session_co_writev(NbdClientSession *client, int64_t sector_num,
46                                  int nb_sectors, QEMUIOVector *qiov);
47 int nbd_client_session_co_readv(NbdClientSession *client, int64_t sector_num,
48                                 int nb_sectors, QEMUIOVector *qiov);
49
50 void nbd_client_session_detach_aio_context(NbdClientSession *client);
51 void nbd_client_session_attach_aio_context(NbdClientSession *client,
52                                            AioContext *new_context);
53
54 #endif /* NBD_CLIENT_H */
This page took 0.026906 seconds and 4 git commands to generate.