summaryrefslogtreecommitdiff
path: root/block/mirror.c
diff options
context:
space:
mode:
authorJeff Cody <jcody@redhat.com>2014-02-12 14:46:24 -0500
committerStefan Hajnoczi <stefanha@redhat.com>2014-02-14 18:05:38 +0100
commit39a611a3e035e148257af314a522a6cd169c2d0e (patch)
tree754c96b3c089acd52d67861615c62116becfff47 /block/mirror.c
parent28f106afb35a86aa01e1907ef7632e015fabce02 (diff)
downloadqemu-39a611a3e035e148257af314a522a6cd169c2d0e.tar.gz
block: Don't throw away errno via error_setg
There are a handful of places in the block layer where a failure path has a valid -errno value, yet error_setg() is used. Those instances should instead use error_setg_errno(), to preserve as much error information as possible. This patch replaces those instances with error_setg_errno(), so that errno is passed up the stack in the error message. Reported-By: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Jeff Cody <jcody@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block/mirror.c')
-rw-r--r--block/mirror.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/block/mirror.c b/block/mirror.c
index 2a4333474e..26d18e44d7 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -633,6 +633,7 @@ void commit_active_start(BlockDriverState *bs, BlockDriverState *base,
{
int64_t length, base_length;
int orig_base_flags;
+ int ret;
orig_base_flags = bdrv_get_flags(base);
@@ -642,19 +643,23 @@ void commit_active_start(BlockDriverState *bs, BlockDriverState *base,
length = bdrv_getlength(bs);
if (length < 0) {
- error_setg(errp, "Unable to determine length of %s", bs->filename);
+ error_setg_errno(errp, -length,
+ "Unable to determine length of %s", bs->filename);
goto error_restore_flags;
}
base_length = bdrv_getlength(base);
if (base_length < 0) {
- error_setg(errp, "Unable to determine length of %s", base->filename);
+ error_setg_errno(errp, -base_length,
+ "Unable to determine length of %s", base->filename);
goto error_restore_flags;
}
if (length > base_length) {
- if (bdrv_truncate(base, length) < 0) {
- error_setg(errp, "Top image %s is larger than base image %s, and "
+ ret = bdrv_truncate(base, length);
+ if (ret < 0) {
+ error_setg_errno(errp, -ret,
+ "Top image %s is larger than base image %s, and "
"resize of base image failed",
bs->filename, base->filename);
goto error_restore_flags;