block/nbd-client: drop stale logout
[qemu.git] / block / nbd-client.h
blob570538f4c8847ce6ba92c9f7347d737f2dd09343
1 #ifndef NBD_CLIENT_H
2 #define NBD_CLIENT_H
4 #include "block/nbd.h"
5 #include "block/block_int.h"
6 #include "io/channel-socket.h"
8 #define MAX_NBD_REQUESTS 16
10 typedef struct {
11 Coroutine *coroutine;
12 uint64_t offset; /* original offset of the request */
13 bool receiving; /* waiting for connection_co? */
14 } NBDClientRequest;
16 typedef struct NBDClientSession {
17 QIOChannelSocket *sioc; /* The master data channel */
18 QIOChannel *ioc; /* The current I/O channel which may differ (eg TLS) */
19 NBDExportInfo info;
21 CoMutex send_mutex;
22 CoQueue free_sema;
23 Coroutine *connection_co;
24 int in_flight;
26 NBDClientRequest requests[MAX_NBD_REQUESTS];
27 NBDReply reply;
28 BlockDriverState *bs;
29 bool quit;
30 } NBDClientSession;
32 NBDClientSession *nbd_get_client_session(BlockDriverState *bs);
34 int nbd_client_init(BlockDriverState *bs,
35 SocketAddress *saddr,
36 const char *export_name,
37 QCryptoTLSCreds *tlscreds,
38 const char *hostname,
39 const char *x_dirty_bitmap,
40 Error **errp);
41 void nbd_client_close(BlockDriverState *bs);
43 int nbd_client_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes);
44 int nbd_client_co_flush(BlockDriverState *bs);
45 int nbd_client_co_pwritev(BlockDriverState *bs, uint64_t offset,
46 uint64_t bytes, QEMUIOVector *qiov, int flags);
47 int nbd_client_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset,
48 int bytes, BdrvRequestFlags flags);
49 int nbd_client_co_preadv(BlockDriverState *bs, uint64_t offset,
50 uint64_t bytes, QEMUIOVector *qiov, int flags);
52 void nbd_client_detach_aio_context(BlockDriverState *bs);
53 void nbd_client_attach_aio_context(BlockDriverState *bs,
54 AioContext *new_context);
56 int coroutine_fn nbd_client_co_block_status(BlockDriverState *bs,
57 bool want_zero,
58 int64_t offset, int64_t bytes,
59 int64_t *pnum, int64_t *map,
60 BlockDriverState **file);
62 #endif /* NBD_CLIENT_H */