vmstate_register_with_alias_id: Take an Error **
[qemu.git] / block / nbd-client.h
blobf8d600684939a42a9a4836237ea198536df1ce39
1 #ifndef NBD_CLIENT_H
2 #define NBD_CLIENT_H
4 #include "qemu-common.h"
5 #include "block/nbd.h"
6 #include "block/block_int.h"
7 #include "io/channel-socket.h"
9 /* #define DEBUG_NBD */
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
18 #define MAX_NBD_REQUESTS 16
20 typedef struct NBDClientSession {
21 QIOChannelSocket *sioc; /* The master data channel */
22 QIOChannel *ioc; /* The current I/O channel which may differ (eg TLS) */
23 uint16_t nbdflags;
24 off_t size;
26 CoMutex send_mutex;
27 CoQueue free_sema;
28 Coroutine *send_coroutine;
29 int in_flight;
31 Coroutine *recv_coroutine[MAX_NBD_REQUESTS];
32 NBDReply reply;
34 bool is_unix;
35 } NBDClientSession;
37 NBDClientSession *nbd_get_client_session(BlockDriverState *bs);
39 int nbd_client_init(BlockDriverState *bs,
40 QIOChannelSocket *sock,
41 const char *export_name,
42 QCryptoTLSCreds *tlscreds,
43 const char *hostname,
44 Error **errp);
45 void nbd_client_close(BlockDriverState *bs);
47 int nbd_client_co_pdiscard(BlockDriverState *bs, int64_t offset, int count);
48 int nbd_client_co_flush(BlockDriverState *bs);
49 int nbd_client_co_pwritev(BlockDriverState *bs, uint64_t offset,
50 uint64_t bytes, QEMUIOVector *qiov, int flags);
51 int nbd_client_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset,
52 int count, BdrvRequestFlags flags);
53 int nbd_client_co_preadv(BlockDriverState *bs, uint64_t offset,
54 uint64_t bytes, QEMUIOVector *qiov, int flags);
56 void nbd_client_detach_aio_context(BlockDriverState *bs);
57 void nbd_client_attach_aio_context(BlockDriverState *bs,
58 AioContext *new_context);
60 #endif /* NBD_CLIENT_H */