tests: fw_cfg: add 'reboot-timeout' test case
[qemu/ar7.git] / block / nbd-client.h
blob09e03013d2373baff7e7a45b9c079e0af9e9b4f6
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 uint64_t offset; /* original offset of the request */
23 bool receiving; /* waiting for connection_co? */
24 } NBDClientRequest;
26 typedef struct NBDClientSession {
27 QIOChannelSocket *sioc; /* The master data channel */
28 QIOChannel *ioc; /* The current I/O channel which may differ (eg TLS) */
29 NBDExportInfo info;
31 CoMutex send_mutex;
32 CoQueue free_sema;
33 Coroutine *connection_co;
34 int in_flight;
36 NBDClientRequest requests[MAX_NBD_REQUESTS];
37 NBDReply reply;
38 BlockDriverState *bs;
39 bool quit;
40 } NBDClientSession;
42 NBDClientSession *nbd_get_client_session(BlockDriverState *bs);
44 int nbd_client_init(BlockDriverState *bs,
45 SocketAddress *saddr,
46 const char *export_name,
47 QCryptoTLSCreds *tlscreds,
48 const char *hostname,
49 const char *x_dirty_bitmap,
50 Error **errp);
51 void nbd_client_close(BlockDriverState *bs);
53 int nbd_client_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes);
54 int nbd_client_co_flush(BlockDriverState *bs);
55 int nbd_client_co_pwritev(BlockDriverState *bs, uint64_t offset,
56 uint64_t bytes, QEMUIOVector *qiov, int flags);
57 int nbd_client_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset,
58 int bytes, BdrvRequestFlags flags);
59 int nbd_client_co_preadv(BlockDriverState *bs, uint64_t offset,
60 uint64_t bytes, QEMUIOVector *qiov, int flags);
62 void nbd_client_detach_aio_context(BlockDriverState *bs);
63 void nbd_client_attach_aio_context(BlockDriverState *bs,
64 AioContext *new_context);
66 int coroutine_fn nbd_client_co_block_status(BlockDriverState *bs,
67 bool want_zero,
68 int64_t offset, int64_t bytes,
69 int64_t *pnum, int64_t *map,
70 BlockDriverState **file);
72 #endif /* NBD_CLIENT_H */