}
static int nbd_co_send_request(BlockDriverState *bs,
- struct nbd_request *request,
+ NBDRequest *request,
QEMUIOVector *qiov)
{
NBDClientSession *s = nbd_get_client_session(bs);
}
static void nbd_co_receive_reply(NBDClientSession *s,
- struct nbd_request *request,
- struct nbd_reply *reply,
+ NBDRequest *request,
+ NBDReply *reply,
QEMUIOVector *qiov)
{
int ret;
}
static void nbd_coroutine_start(NBDClientSession *s,
- struct nbd_request *request)
+ NBDRequest *request)
{
/* Poor man semaphore. The free_sema is locked when no other request
* can be accepted, and unlocked after receiving one reply. */
}
static void nbd_coroutine_end(NBDClientSession *s,
- struct nbd_request *request)
+ NBDRequest *request)
{
int i = HANDLE_TO_INDEX(s, request->handle);
s->recv_coroutine[i] = NULL;
uint64_t bytes, QEMUIOVector *qiov, int flags)
{
NBDClientSession *client = nbd_get_client_session(bs);
- struct nbd_request request = {
+ NBDRequest request = {
.type = NBD_CMD_READ,
.from = offset,
.len = bytes,
};
- struct nbd_reply reply;
+ NBDReply reply;
ssize_t ret;
assert(bytes <= NBD_MAX_BUFFER_SIZE);
uint64_t bytes, QEMUIOVector *qiov, int flags)
{
NBDClientSession *client = nbd_get_client_session(bs);
- struct nbd_request request = {
+ NBDRequest request = {
.type = NBD_CMD_WRITE,
.from = offset,
.len = bytes,
};
- struct nbd_reply reply;
+ NBDReply reply;
ssize_t ret;
if (flags & BDRV_REQ_FUA) {
int nbd_client_co_flush(BlockDriverState *bs)
{
NBDClientSession *client = nbd_get_client_session(bs);
- struct nbd_request request = { .type = NBD_CMD_FLUSH };
- struct nbd_reply reply;
+ NBDRequest request = { .type = NBD_CMD_FLUSH };
+ NBDReply reply;
ssize_t ret;
if (!(client->nbdflags & NBD_FLAG_SEND_FLUSH)) {
int nbd_client_co_pdiscard(BlockDriverState *bs, int64_t offset, int count)
{
NBDClientSession *client = nbd_get_client_session(bs);
- struct nbd_request request = {
+ NBDRequest request = {
.type = NBD_CMD_TRIM,
.from = offset,
.len = count,
};
- struct nbd_reply reply;
+ NBDReply reply;
ssize_t ret;
if (!(client->nbdflags & NBD_FLAG_SEND_TRIM)) {
void nbd_client_close(BlockDriverState *bs)
{
NBDClientSession *client = nbd_get_client_session(bs);
- struct nbd_request request = { .type = NBD_CMD_DISC };
+ NBDRequest request = { .type = NBD_CMD_DISC };
if (client->ioc == NULL) {
return;
/* Note: these are _NOT_ the same as the network representation of an NBD
* request and reply!
*/
-struct nbd_request {
+struct NBDRequest {
uint64_t handle;
uint64_t from;
uint32_t len;
uint16_t flags;
uint16_t type;
};
+typedef struct NBDRequest NBDRequest;
-struct nbd_reply {
+struct NBDReply {
uint64_t handle;
uint32_t error;
};
+typedef struct NBDReply NBDReply;
/* Transmission (export) flags: sent from server to client during handshake,
but describe what will happen during transmission */
QIOChannel **outioc,
off_t *size, Error **errp);
int nbd_init(int fd, QIOChannelSocket *sioc, uint16_t flags, off_t size);
-ssize_t nbd_send_request(QIOChannel *ioc, struct nbd_request *request);
-ssize_t nbd_receive_reply(QIOChannel *ioc, struct nbd_reply *reply);
+ssize_t nbd_send_request(QIOChannel *ioc, NBDRequest *request);
+ssize_t nbd_receive_reply(QIOChannel *ioc, NBDReply *reply);
int nbd_client(int fd);
int nbd_disconnect(int fd);
return rc;
}
-static ssize_t nbd_receive_request(QIOChannel *ioc, struct nbd_request *request)
+static ssize_t nbd_receive_request(QIOChannel *ioc, NBDRequest *request)
{
uint8_t buf[NBD_REQUEST_SIZE];
uint32_t magic;
return 0;
}
-static ssize_t nbd_send_reply(QIOChannel *ioc, struct nbd_reply *reply)
+static ssize_t nbd_send_reply(QIOChannel *ioc, NBDReply *reply)
{
uint8_t buf[NBD_REPLY_SIZE];
ssize_t ret;
}
}
-static ssize_t nbd_co_send_reply(NBDRequestData *req, struct nbd_reply *reply,
+static ssize_t nbd_co_send_reply(NBDRequestData *req, NBDReply *reply,
int len)
{
NBDClient *client = req->client;
* (although the caller may still need to disconnect after reporting
* the error). */
static ssize_t nbd_co_receive_request(NBDRequestData *req,
- struct nbd_request *request)
+ NBDRequest *request)
{
NBDClient *client = req->client;
ssize_t rc;
NBDClient *client = opaque;
NBDExport *exp = client->exp;
NBDRequestData *req;
- struct nbd_request request;
- struct nbd_reply reply;
+ NBDRequest request;
+ NBDReply reply;
ssize_t ret;
int flags;