]> git.proxmox.com Git - mirror_qemu.git/blame - block/nbd-client.h
Merge remote-tracking branch 'remotes/berrange/tags/pull-qio-2017-04-04-1' into staging
[mirror_qemu.git] / block / nbd-client.h
CommitLineData
2302c1ca
MAL
1#ifndef NBD_CLIENT_H
2#define NBD_CLIENT_H
3
4#include "qemu-common.h"
5#include "block/nbd.h"
6#include "block/block_int.h"
064097d9 7#include "io/channel-socket.h"
2302c1ca
MAL
8
9/* #define DEBUG_NBD */
10
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
17
18#define MAX_NBD_REQUESTS 16
19
10676b81 20typedef struct NBDClientSession {
064097d9
DB
21 QIOChannelSocket *sioc; /* The master data channel */
22 QIOChannel *ioc; /* The current I/O channel which may differ (eg TLS) */
7423f417 23 uint16_t nbdflags;
2302c1ca 24 off_t size;
2302c1ca
MAL
25
26 CoMutex send_mutex;
9bc9732f 27 CoQueue free_sema;
ff82911c 28 Coroutine *read_reply_co;
2302c1ca
MAL
29 int in_flight;
30
31 Coroutine *recv_coroutine[MAX_NBD_REQUESTS];
ed2dd912 32 NBDReply reply;
10676b81 33} NBDClientSession;
2302c1ca 34
10676b81 35NBDClientSession *nbd_get_client_session(BlockDriverState *bs);
f53a829b 36
064097d9
DB
37int nbd_client_init(BlockDriverState *bs,
38 QIOChannelSocket *sock,
39 const char *export_name,
75822a12
DB
40 QCryptoTLSCreds *tlscreds,
41 const char *hostname,
f53a829b
HR
42 Error **errp);
43void nbd_client_close(BlockDriverState *bs);
44
447e57c3 45int nbd_client_co_pdiscard(BlockDriverState *bs, int64_t offset, int count);
f53a829b 46int nbd_client_co_flush(BlockDriverState *bs);
70c4fb26
EB
47int nbd_client_co_pwritev(BlockDriverState *bs, uint64_t offset,
48 uint64_t bytes, QEMUIOVector *qiov, int flags);
fa778fff
EB
49int nbd_client_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset,
50 int count, BdrvRequestFlags flags);
70c4fb26
EB
51int nbd_client_co_preadv(BlockDriverState *bs, uint64_t offset,
52 uint64_t bytes, QEMUIOVector *qiov, int flags);
f53a829b
HR
53
54void nbd_client_detach_aio_context(BlockDriverState *bs);
55void nbd_client_attach_aio_context(BlockDriverState *bs,
56 AioContext *new_context);
69447cd8 57
2302c1ca 58#endif /* NBD_CLIENT_H */