ui: convert common input code to keycodemapdb
[qemu/ar7.git] / block / nbd-client.h
blobb435754b82dd0abe1bcc76559df83ec416fcb5aa
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 {
21 Coroutine *coroutine;
22 bool receiving; /* waiting for read_reply_co? */
23 } NBDClientRequest;
25 typedef struct NBDClientSession {
26 QIOChannelSocket *sioc; /* The master data channel */
27 QIOChannel *ioc; /* The current I/O channel which may differ (eg TLS) */
28 NBDExportInfo info;
30 CoMutex send_mutex;
31 CoQueue free_sema;
32 Coroutine *read_reply_co;
33 int in_flight;
35 NBDClientRequest requests[MAX_NBD_REQUESTS];
36 NBDReply reply;
37 bool quit;
38 } NBDClientSession;
40 NBDClientSession *nbd_get_client_session(BlockDriverState *bs);
42 int nbd_client_init(BlockDriverState *bs,
43 QIOChannelSocket *sock,
44 const char *export_name,
45 QCryptoTLSCreds *tlscreds,
46 const char *hostname,
47 Error **errp);
48 void nbd_client_close(BlockDriverState *bs);
50 int nbd_client_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes);
51 int nbd_client_co_flush(BlockDriverState *bs);
52 int nbd_client_co_pwritev(BlockDriverState *bs, uint64_t offset,
53 uint64_t bytes, QEMUIOVector *qiov, int flags);
54 int nbd_client_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset,
55 int bytes, BdrvRequestFlags flags);
56 int nbd_client_co_preadv(BlockDriverState *bs, uint64_t offset,
57 uint64_t bytes, QEMUIOVector *qiov, int flags);
59 void nbd_client_detach_aio_context(BlockDriverState *bs);
60 void nbd_client_attach_aio_context(BlockDriverState *bs,
61 AioContext *new_context);
63 #endif /* NBD_CLIENT_H */