5 #include "block/block_int.h"
6 #include "io/channel-socket.h"
8 /* #define DEBUG_NBD */
10 #if defined(DEBUG_NBD)
11 #define logout(fmt, ...) \
12 fprintf(stderr, "nbd\t%-24s" fmt, __func__, ##__VA_ARGS__)
14 #define logout(fmt, ...) ((void)0)
17 #define MAX_NBD_REQUESTS 16
21 uint64_t offset
; /* original offset of the request */
22 bool receiving
; /* waiting for connection_co? */
25 typedef struct NBDClientSession
{
26 QIOChannelSocket
*sioc
; /* The master data channel */
27 QIOChannel
*ioc
; /* The current I/O channel which may differ (eg TLS) */
32 Coroutine
*connection_co
;
35 NBDClientRequest requests
[MAX_NBD_REQUESTS
];
41 NBDClientSession
*nbd_get_client_session(BlockDriverState
*bs
);
43 int nbd_client_init(BlockDriverState
*bs
,
45 const char *export_name
,
46 QCryptoTLSCreds
*tlscreds
,
48 const char *x_dirty_bitmap
,
50 void nbd_client_close(BlockDriverState
*bs
);
52 int nbd_client_co_pdiscard(BlockDriverState
*bs
, int64_t offset
, int bytes
);
53 int nbd_client_co_flush(BlockDriverState
*bs
);
54 int nbd_client_co_pwritev(BlockDriverState
*bs
, uint64_t offset
,
55 uint64_t bytes
, QEMUIOVector
*qiov
, int flags
);
56 int nbd_client_co_pwrite_zeroes(BlockDriverState
*bs
, int64_t offset
,
57 int bytes
, BdrvRequestFlags flags
);
58 int nbd_client_co_preadv(BlockDriverState
*bs
, uint64_t offset
,
59 uint64_t bytes
, QEMUIOVector
*qiov
, int flags
);
61 void nbd_client_detach_aio_context(BlockDriverState
*bs
);
62 void nbd_client_attach_aio_context(BlockDriverState
*bs
,
63 AioContext
*new_context
);
65 int coroutine_fn
nbd_client_co_block_status(BlockDriverState
*bs
,
67 int64_t offset
, int64_t bytes
,
68 int64_t *pnum
, int64_t *map
,
69 BlockDriverState
**file
);
71 #endif /* NBD_CLIENT_H */