summaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorChen Gang <gang.chen.5i5j@gmail.com>2014-06-23 23:28:23 +0800
committerKevin Wolf <kwolf@redhat.com>2014-06-27 20:00:00 +0200
commit6b8aeca574a15668c47296d8e0c4f96c72e63c36 (patch)
tree276eb681dd5e5649ea49a37f35ad6116d6bfd1ad /block.c
parentd88964aeda6cfc44585fe35c97c37537235c0a96 (diff)
downloadqemu-6b8aeca574a15668c47296d8e0c4f96c72e63c36.tar.gz
qemu-6b8aeca574a15668c47296d8e0c4f96c72e63c36.tar.bz2
qemu-6b8aeca574a15668c47296d8e0c4f96c72e63c36.zip
block.c: Don't return success for bdrv_append_temp_snapshot() failure
When failure occurs, 'ret' need be set, or may return 0 to indicate success. Previously, an error was set in errp, but 0 was returned anyway. So let bdrv_append_temp_snapshot() return an error code and use that for the bdrv_open() return value. Also, error_propagate() need be called only one time within a function. Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/block.c b/block.c
index 9ecadf002f..6856c18aa8 100644
--- a/block.c
+++ b/block.c
@@ -1278,7 +1278,7 @@ done:
return ret;
}
-void bdrv_append_temp_snapshot(BlockDriverState *bs, int flags, Error **errp)
+int bdrv_append_temp_snapshot(BlockDriverState *bs, int flags, Error **errp)
{
/* TODO: extra byte is a hack to ensure MAX_PATH space on Windows. */
char *tmp_filename = g_malloc0(PATH_MAX + 1);
@@ -1296,6 +1296,7 @@ void bdrv_append_temp_snapshot(BlockDriverState *bs, int flags, Error **errp)
/* Get the required size from the image */
total_size = bdrv_getlength(bs);
if (total_size < 0) {
+ ret = total_size;
error_setg_errno(errp, -total_size, "Could not get image size");
goto out;
}
@@ -1342,6 +1343,7 @@ void bdrv_append_temp_snapshot(BlockDriverState *bs, int flags, Error **errp)
out:
g_free(tmp_filename);
+ return ret;
}
/*
@@ -1491,9 +1493,8 @@ int bdrv_open(BlockDriverState **pbs, const char *filename,
/* For snapshot=on, create a temporary qcow2 overlay. bs points to the
* temporary snapshot afterwards. */
if (snapshot_flags) {
- bdrv_append_temp_snapshot(bs, snapshot_flags, &local_err);
+ ret = bdrv_append_temp_snapshot(bs, snapshot_flags, &local_err);
if (local_err) {
- error_propagate(errp, local_err);
goto close_and_fail;
}
}