diff --git a/block/nbd-client.c b/block/nbd-client.c index e6fe603ef3..3e5f9f5b77 100644 --- a/block/nbd-client.c +++ b/block/nbd-client.c @@ -116,7 +116,7 @@ static void nbd_restart_write(void *opaque) } static int nbd_co_send_request(BlockDriverState *bs, - struct nbd_request *request, + NBDRequest *request, QEMUIOVector *qiov) { NBDClientSession *s = nbd_get_client_session(bs); @@ -168,8 +168,8 @@ static int nbd_co_send_request(BlockDriverState *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; @@ -196,7 +196,7 @@ static void nbd_co_receive_reply(NBDClientSession *s, } 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. */ @@ -210,7 +210,7 @@ static void nbd_coroutine_start(NBDClientSession *s, } 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; @@ -223,12 +223,12 @@ int nbd_client_co_preadv(BlockDriverState *bs, uint64_t offset, 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); @@ -249,12 +249,12 @@ int nbd_client_co_pwritev(BlockDriverState *bs, uint64_t offset, 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) { @@ -278,8 +278,8 @@ int nbd_client_co_pwritev(BlockDriverState *bs, uint64_t offset, 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)) { @@ -303,12 +303,12 @@ int nbd_client_co_flush(BlockDriverState *bs) 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)) { @@ -344,7 +344,7 @@ void nbd_client_attach_aio_context(BlockDriverState *bs, 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; diff --git a/block/nbd-client.h b/block/nbd-client.h index d86dd22e35..51be419405 100644 --- a/block/nbd-client.h +++ b/block/nbd-client.h @@ -29,7 +29,7 @@ typedef struct NBDClientSession { int in_flight; Coroutine *recv_coroutine[MAX_NBD_REQUESTS]; - struct nbd_reply reply; + NBDReply reply; bool is_unix; } NBDClientSession; diff --git a/include/block/nbd.h b/include/block/nbd.h index 5fe2670fdb..a33581b6a9 100644 --- a/include/block/nbd.h +++ b/include/block/nbd.h @@ -29,18 +29,20 @@ /* 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 */ @@ -101,8 +103,8 @@ int nbd_receive_negotiate(QIOChannel *ioc, const char *name, uint16_t *flags, 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); diff --git a/nbd/client.c b/nbd/client.c index 4620e8dcba..fe24d31ec6 100644 --- a/nbd/client.c +++ b/nbd/client.c @@ -708,7 +708,7 @@ int nbd_disconnect(int fd) } #endif -ssize_t nbd_send_request(QIOChannel *ioc, struct nbd_request *request) +ssize_t nbd_send_request(QIOChannel *ioc, NBDRequest *request) { uint8_t buf[NBD_REQUEST_SIZE]; ssize_t ret; @@ -738,7 +738,7 @@ ssize_t nbd_send_request(QIOChannel *ioc, struct nbd_request *request) return 0; } -ssize_t nbd_receive_reply(QIOChannel *ioc, struct nbd_reply *reply) +ssize_t nbd_receive_reply(QIOChannel *ioc, NBDReply *reply) { uint8_t buf[NBD_REPLY_SIZE]; uint32_t magic; diff --git a/nbd/server.c b/nbd/server.c index 09d949f0c1..badc2d1fe6 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -635,7 +635,7 @@ fail: 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; @@ -678,7 +678,7 @@ static ssize_t nbd_receive_request(QIOChannel *ioc, struct nbd_request *request) 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; @@ -976,7 +976,7 @@ void nbd_export_close_all(void) } } -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; @@ -1013,7 +1013,7 @@ static ssize_t nbd_co_send_reply(NBDRequestData *req, struct nbd_reply *reply, * (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; @@ -1107,8 +1107,8 @@ static void nbd_trip(void *opaque) 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;