net/eth: fix incorrect check of iov_to_buf() return value
[qemu/ar7.git] / block / nbd-client.h
blobdf80771357c386a289099799fd1b2df83c040c35
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 NBDExportInfo info;
25 CoMutex send_mutex;
26 CoQueue free_sema;
27 Coroutine *read_reply_co;
28 int in_flight;
30 Coroutine *recv_coroutine[MAX_NBD_REQUESTS];
31 NBDReply reply;
32 } NBDClientSession;
34 NBDClientSession *nbd_get_client_session(BlockDriverState *bs);
36 int nbd_client_init(BlockDriverState *bs,
37 QIOChannelSocket *sock,
38 const char *export_name,
39 QCryptoTLSCreds *tlscreds,
40 const char *hostname,
41 Error **errp);
42 void nbd_client_close(BlockDriverState *bs);
44 int nbd_client_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes);
45 int nbd_client_co_flush(BlockDriverState *bs);
46 int nbd_client_co_pwritev(BlockDriverState *bs, uint64_t offset,
47 uint64_t bytes, QEMUIOVector *qiov, int flags);
48 int nbd_client_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset,
49 int bytes, BdrvRequestFlags flags);
50 int nbd_client_co_preadv(BlockDriverState *bs, uint64_t offset,
51 uint64_t bytes, QEMUIOVector *qiov, int flags);
53 void nbd_client_detach_aio_context(BlockDriverState *bs);
54 void nbd_client_attach_aio_context(BlockDriverState *bs,
55 AioContext *new_context);
57 #endif /* NBD_CLIENT_H */