]> git.proxmox.com Git - mirror_qemu.git/blame - block/nbd-client.h
util: remove the obsolete non-blocking connect
[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
40f4a218
SH
20typedef struct {
21 Coroutine *coroutine;
22 bool receiving; /* waiting for read_reply_co? */
23} NBDClientRequest;
24
10676b81 25typedef struct NBDClientSession {
064097d9
DB
26 QIOChannelSocket *sioc; /* The master data channel */
27 QIOChannel *ioc; /* The current I/O channel which may differ (eg TLS) */
004a89fc 28 NBDExportInfo info;
2302c1ca
MAL
29
30 CoMutex send_mutex;
9bc9732f 31 CoQueue free_sema;
ff82911c 32 Coroutine *read_reply_co;
2302c1ca
MAL
33 int in_flight;
34
40f4a218 35 NBDClientRequest requests[MAX_NBD_REQUESTS];
ed2dd912 36 NBDReply reply;
72b6ffc7 37 bool quit;
10676b81 38} NBDClientSession;
2302c1ca 39
10676b81 40NBDClientSession *nbd_get_client_session(BlockDriverState *bs);
f53a829b 41
064097d9
DB
42int nbd_client_init(BlockDriverState *bs,
43 QIOChannelSocket *sock,
44 const char *export_name,
75822a12
DB
45 QCryptoTLSCreds *tlscreds,
46 const char *hostname,
f53a829b
HR
47 Error **errp);
48void nbd_client_close(BlockDriverState *bs);
49
f5a5ca79 50int nbd_client_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes);
f53a829b 51int nbd_client_co_flush(BlockDriverState *bs);
70c4fb26
EB
52int nbd_client_co_pwritev(BlockDriverState *bs, uint64_t offset,
53 uint64_t bytes, QEMUIOVector *qiov, int flags);
fa778fff 54int nbd_client_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset,
f5a5ca79 55 int bytes, BdrvRequestFlags flags);
70c4fb26
EB
56int nbd_client_co_preadv(BlockDriverState *bs, uint64_t offset,
57 uint64_t bytes, QEMUIOVector *qiov, int flags);
f53a829b
HR
58
59void nbd_client_detach_aio_context(BlockDriverState *bs);
60void nbd_client_attach_aio_context(BlockDriverState *bs,
61 AioContext *new_context);
69447cd8 62
2302c1ca 63#endif /* NBD_CLIENT_H */