[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 29/33] block/sheepdog: Propagate errors through do_sd
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 29/33] block/sheepdog: Propagate errors through do_sd_create() |
Date: |
Fri, 23 May 2014 17:42:01 +0200 |
From: Markus Armbruster <address@hidden>
Cc: MORITA Kazutaka <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
block/sheepdog.c | 35 +++++++++++++++++++++--------------
1 file changed, 21 insertions(+), 14 deletions(-)
diff --git a/block/sheepdog.c b/block/sheepdog.c
index 4df45a1..d01cc88 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -1481,19 +1481,17 @@ out:
return ret;
}
-static int do_sd_create(BDRVSheepdogState *s, uint32_t *vdi_id, int snapshot)
+static int do_sd_create(BDRVSheepdogState *s, uint32_t *vdi_id, int snapshot,
+ Error **errp)
{
- Error *local_err = NULL;
SheepdogVdiReq hdr;
SheepdogVdiRsp *rsp = (SheepdogVdiRsp *)&hdr;
int fd, ret;
unsigned int wlen, rlen = 0;
char buf[SD_MAX_VDI_LEN];
- 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;
}
@@ -1522,11 +1520,12 @@ static int do_sd_create(BDRVSheepdogState *s, uint32_t
*vdi_id, int snapshot)
closesocket(fd);
if (ret) {
+ error_setg_errno(errp, -ret, "create failed");
return ret;
}
if (rsp->result != SD_RES_SUCCESS) {
- error_report("%s, %s", sd_strerror(rsp->result), s->inode.name);
+ error_setg(errp, "%s, %s", sd_strerror(rsp->result), s->inode.name);
return -EIO;
}
@@ -1731,15 +1730,19 @@ static int sd_create(const char *filename,
QEMUOptionParameter *options,
bdrv_unref(bs);
}
- ret = do_sd_create(s, &vid, 0);
- if (!prealloc || ret) {
+ ret = do_sd_create(s, &vid, 0, &local_err);
+ if (ret) {
+ qerror_report_err(local_err);
+ error_free(local_err);
goto out;
}
- ret = sd_prealloc(filename, &local_err);
- if (ret < 0) {
- qerror_report_err(local_err);
- error_free(local_err);
+ if (prealloc) {
+ ret = sd_prealloc(filename, &local_err);
+ if (ret < 0) {
+ qerror_report_err(local_err);
+ error_free(local_err);
+ }
}
out:
g_free(s);
@@ -1928,8 +1931,10 @@ static int sd_create_branch(BDRVSheepdogState *s)
* false bail out.
*/
deleted = sd_delete(s);
- ret = do_sd_create(s, &vid, !deleted);
+ ret = do_sd_create(s, &vid, !deleted, &local_err);
if (ret) {
+ qerror_report_err(local_err);
+ error_free(local_err);
goto out;
}
@@ -2197,8 +2202,10 @@ static int sd_snapshot_create(BlockDriverState *bs,
QEMUSnapshotInfo *sn_info)
goto cleanup;
}
- ret = do_sd_create(s, &new_vid, 1);
+ ret = do_sd_create(s, &new_vid, 1, &local_err);
if (ret < 0) {
+ qerror_report_err(local_err);
+ error_free(local_err);
error_report("failed to create inode for snapshot. %s",
strerror(errno));
goto cleanup;
--
1.9.0
- [Qemu-devel] [PULL 18/33] block/rbd: Propagate errors to open and create methods, (continued)
- [Qemu-devel] [PULL 18/33] block/rbd: Propagate errors to open and create methods, Stefan Hajnoczi, 2014/05/23
- [Qemu-devel] [PULL 19/33] block/ssh: Drop superfluous libssh2_session_last_errno() calls, Stefan Hajnoczi, 2014/05/23
- [Qemu-devel] [PULL 20/33] block/ssh: Propagate errors through check_host_key(), Stefan Hajnoczi, 2014/05/23
- [Qemu-devel] [PULL 21/33] block/ssh: Propagate errors through authenticate(), Stefan Hajnoczi, 2014/05/23
- [Qemu-devel] [PULL 23/33] block/ssh: Propagate errors to open and create methods, Stefan Hajnoczi, 2014/05/23
- [Qemu-devel] [PULL 24/33] block/vvfat: Propagate errors through enable_write_target(), Stefan Hajnoczi, 2014/05/23
- [Qemu-devel] [PULL 25/33] block/vvfat: Propagate errors through init_directories(), Stefan Hajnoczi, 2014/05/23
- [Qemu-devel] [PULL 26/33] block/sheepdog: Propagate errors through connect_to_sdog(), Stefan Hajnoczi, 2014/05/23
- [Qemu-devel] [PULL 27/33] block/sheepdog: Propagate errors through get_sheep_fd(), Stefan Hajnoczi, 2014/05/23
- [Qemu-devel] [PULL 28/33] block/sheepdog: Propagate errors through sd_prealloc(), Stefan Hajnoczi, 2014/05/23
- [Qemu-devel] [PULL 29/33] block/sheepdog: Propagate errors through do_sd_create(),
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 30/33] block/sheepdog: Propagate errors through find_vdi_name(), Stefan Hajnoczi, 2014/05/23
- [Qemu-devel] [PULL 31/33] block/sheepdog: Propagate errors to open and create methods, Stefan Hajnoczi, 2014/05/23
- [Qemu-devel] [PULL 32/33] block/sheepdog: Fix silent sd_open(), sd_create() failures, Stefan Hajnoczi, 2014/05/23
- [Qemu-devel] [PULL 33/33] block/sheepdog: Don't use qerror_report(), Stefan Hajnoczi, 2014/05/23
- [Qemu-devel] [PULL 22/33] block/ssh: Propagate errors through connect_to_ssh(), Stefan Hajnoczi, 2014/05/23
- Re: [Qemu-devel] [PULL 00/33] Block patches, Peter Maydell, 2014/05/27