4 #include "qemu-common.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__)
15 #define logout(fmt, ...) ((void)0)
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) */
28 Coroutine
*send_coroutine
;
31 Coroutine
*recv_coroutine
[MAX_NBD_REQUESTS
];
32 struct nbd_reply reply
;
37 NbdClientSession
*nbd_get_client_session(BlockDriverState
*bs
);
39 int nbd_client_init(BlockDriverState
*bs
,
40 QIOChannelSocket
*sock
,
41 const char *export_name
,
42 QCryptoTLSCreds
*tlscreds
,
45 void nbd_client_close(BlockDriverState
*bs
);
47 int nbd_client_co_discard(BlockDriverState
*bs
, int64_t sector_num
,
49 int nbd_client_co_flush(BlockDriverState
*bs
);
50 int nbd_client_co_writev(BlockDriverState
*bs
, int64_t sector_num
,
51 int nb_sectors
, QEMUIOVector
*qiov
);
52 int nbd_client_co_readv(BlockDriverState
*bs
, int64_t sector_num
,
53 int nb_sectors
, QEMUIOVector
*qiov
);
55 void nbd_client_detach_aio_context(BlockDriverState
*bs
);
56 void nbd_client_attach_aio_context(BlockDriverState
*bs
,
57 AioContext
*new_context
);
59 #endif /* NBD_CLIENT_H */