From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlE0l-0000u5-1n for qemu-devel@nongnu.org; Fri, 16 May 2014 05:01:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WlE0d-0005Ux-Dt for qemu-devel@nongnu.org; Fri, 16 May 2014 05:01:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43825) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlE0c-0005Ud-VN for qemu-devel@nongnu.org; Fri, 16 May 2014 05:00:55 -0400 From: Markus Armbruster Date: Fri, 16 May 2014 11:00:20 +0200 Message-Id: <1400230826-18009-14-git-send-email-armbru@redhat.com> In-Reply-To: <1400230826-18009-1-git-send-email-armbru@redhat.com> References: <1400230826-18009-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH v2 13/19] block/sheepdog: Propagate errors through get_sheep_fd() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, MORITA Kazutaka , stefanha@redhat.com Cc: MORITA Kazutaka Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- block/sheepdog.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/block/sheepdog.c b/block/sheepdog.c index ff0aa89..b932d68 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -668,7 +668,7 @@ static void coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req, enum AIOCBState aiocb_type); static void coroutine_fn resend_aioreq(BDRVSheepdogState *s, AIOReq *aio_req); static int reload_inode(BDRVSheepdogState *s, uint32_t snapid, const char *tag); -static int get_sheep_fd(BDRVSheepdogState *s); +static int get_sheep_fd(BDRVSheepdogState *s, Error **errp); static void co_write_request(void *opaque); static AIOReq *find_pending_req(BDRVSheepdogState *s, uint64_t oid) @@ -705,6 +705,7 @@ static void coroutine_fn send_pending_req(BDRVSheepdogState *s, uint64_t oid) static coroutine_fn void reconnect_to_sdog(void *opaque) { + Error *local_err = NULL; BDRVSheepdogState *s = opaque; AIOReq *aio_req, *next; @@ -719,9 +720,11 @@ static coroutine_fn void reconnect_to_sdog(void *opaque) /* Try to reconnect the sheepdog server every one second. */ while (s->fd < 0) { - s->fd = get_sheep_fd(s); + s->fd = get_sheep_fd(s, &local_err); if (s->fd < 0) { DPRINTF("Wait for connection to be established\n"); + qerror_report_err(local_err); + error_free(local_err); co_aio_sleep_ns(bdrv_get_aio_context(s->bs), QEMU_CLOCK_REALTIME, 1000000000ULL); } @@ -910,15 +913,12 @@ static void co_write_request(void *opaque) * We cannot use this descriptor for other operations because * the block driver may be on waiting response from the server. */ -static int get_sheep_fd(BDRVSheepdogState *s) +static int get_sheep_fd(BDRVSheepdogState *s, Error **errp) { - Error *local_err = NULL; int fd; - fd = connect_to_sdog(s, &local_err); + fd = connect_to_sdog(s, errp); if (fd < 0) { - qerror_report_err(local_err); - error_free(local_err); return fd; } @@ -1415,8 +1415,10 @@ static int sd_open(BlockDriverState *bs, QDict *options, int flags, if (ret < 0) { goto out; } - s->fd = get_sheep_fd(s); + s->fd = get_sheep_fd(s, &local_err); if (s->fd < 0) { + qerror_report_err(local_err); + error_free(local_err); ret = s->fd; goto out; } -- 1.8.1.4