mirror of https://github.com/xemu-project/xemu.git
sheepdog: fix confused return values
These functions mix up -1 and -errno in return values and would might cause trouble error handling in the call chain. This patch let them return -errno and add some comments. Cc: qemu-devel@nongnu.org Cc: Markus Armbruster <armbru@redhat.com> Cc: Kevin Wolf <kwolf@redhat.com> Cc: Stefan Hajnoczi <stefanha@redhat.com> Reported-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Liu Yuan <liuyuan@cmss.chinamobile.com> Message-id: 1424231875-7131-1-git-send-email-namei.unix@gmail.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
e0c59cc760
commit
833a7cc36e
|
@ -545,6 +545,7 @@ static SheepdogAIOCB *sd_aio_setup(BlockDriverState *bs, QEMUIOVector *qiov,
|
||||||
return acb;
|
return acb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return -EIO in case of error, file descriptor on success */
|
||||||
static int connect_to_sdog(BDRVSheepdogState *s, Error **errp)
|
static int connect_to_sdog(BDRVSheepdogState *s, Error **errp)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
@ -564,11 +565,14 @@ static int connect_to_sdog(BDRVSheepdogState *s, Error **errp)
|
||||||
|
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
qemu_set_nonblock(fd);
|
qemu_set_nonblock(fd);
|
||||||
|
} else {
|
||||||
|
fd = -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return 0 on success and -errno in case of error */
|
||||||
static coroutine_fn int send_co_req(int sockfd, SheepdogReq *hdr, void *data,
|
static coroutine_fn int send_co_req(int sockfd, SheepdogReq *hdr, void *data,
|
||||||
unsigned int *wlen)
|
unsigned int *wlen)
|
||||||
{
|
{
|
||||||
|
@ -577,11 +581,13 @@ static coroutine_fn int send_co_req(int sockfd, SheepdogReq *hdr, void *data,
|
||||||
ret = qemu_co_send(sockfd, hdr, sizeof(*hdr));
|
ret = qemu_co_send(sockfd, hdr, sizeof(*hdr));
|
||||||
if (ret != sizeof(*hdr)) {
|
if (ret != sizeof(*hdr)) {
|
||||||
error_report("failed to send a req, %s", strerror(errno));
|
error_report("failed to send a req, %s", strerror(errno));
|
||||||
|
ret = -socket_error();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = qemu_co_send(sockfd, data, *wlen);
|
ret = qemu_co_send(sockfd, data, *wlen);
|
||||||
if (ret != *wlen) {
|
if (ret != *wlen) {
|
||||||
|
ret = -socket_error();
|
||||||
error_report("failed to send a req, %s", strerror(errno));
|
error_report("failed to send a req, %s", strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -656,6 +662,11 @@ out:
|
||||||
srco->finished = true;
|
srco->finished = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Send the request to the sheep in a synchronous manner.
|
||||||
|
*
|
||||||
|
* Return 0 on success, -errno in case of error.
|
||||||
|
*/
|
||||||
static int do_req(int sockfd, AioContext *aio_context, SheepdogReq *hdr,
|
static int do_req(int sockfd, AioContext *aio_context, SheepdogReq *hdr,
|
||||||
void *data, unsigned int *wlen, unsigned int *rlen)
|
void *data, unsigned int *wlen, unsigned int *rlen)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue