block/sheepdog: Propagate errors through get_sheep_fd()

Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Markus Armbruster 2014-05-16 11:00:20 +02:00 committed by Stefan Hajnoczi
parent dfb12bf86e
commit 356b4ca2bb

View File

@ -668,7 +668,7 @@ static void coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req,
enum AIOCBState aiocb_type); enum AIOCBState aiocb_type);
static void coroutine_fn resend_aioreq(BDRVSheepdogState *s, AIOReq *aio_req); 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 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 void co_write_request(void *opaque);
static AIOReq *find_pending_req(BDRVSheepdogState *s, uint64_t oid) 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) static coroutine_fn void reconnect_to_sdog(void *opaque)
{ {
Error *local_err = NULL;
BDRVSheepdogState *s = opaque; BDRVSheepdogState *s = opaque;
AIOReq *aio_req, *next; 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. */ /* Try to reconnect the sheepdog server every one second. */
while (s->fd < 0) { while (s->fd < 0) {
s->fd = get_sheep_fd(s); s->fd = get_sheep_fd(s, &local_err);
if (s->fd < 0) { if (s->fd < 0) {
DPRINTF("Wait for connection to be established\n"); 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, co_aio_sleep_ns(bdrv_get_aio_context(s->bs), QEMU_CLOCK_REALTIME,
1000000000ULL); 1000000000ULL);
} }
@ -910,15 +913,12 @@ static void co_write_request(void *opaque)
* We cannot use this descriptor for other operations because * We cannot use this descriptor for other operations because
* the block driver may be on waiting response from the server. * 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; int fd;
fd = connect_to_sdog(s, &local_err); fd = connect_to_sdog(s, errp);
if (fd < 0) { if (fd < 0) {
qerror_report_err(local_err);
error_free(local_err);
return fd; return fd;
} }
@ -1415,8 +1415,10 @@ static int sd_open(BlockDriverState *bs, QDict *options, int flags,
if (ret < 0) { if (ret < 0) {
goto out; goto out;
} }
s->fd = get_sheep_fd(s); s->fd = get_sheep_fd(s, &local_err);
if (s->fd < 0) { if (s->fd < 0) {
qerror_report_err(local_err);
error_free(local_err);
ret = s->fd; ret = s->fd;
goto out; goto out;
} }