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>
This commit is contained in:
Jeff Cody 2014-02-12 14:46:24 -05:00 committed by Stefan Hajnoczi
parent 28f106afb3
commit 39a611a3e0
3 changed files with 17 additions and 10 deletions

View file

@ -1502,7 +1502,7 @@ static int vmdk_create_extent(const char *filename, int64_t filesize,
if (flat) {
ret = bdrv_truncate(bs, filesize);
if (ret < 0) {
error_setg(errp, "Could not truncate file");
error_setg_errno(errp, -ret, "Could not truncate file");
}
goto exit;
}
@ -1562,7 +1562,7 @@ static int vmdk_create_extent(const char *filename, int64_t filesize,
ret = bdrv_truncate(bs, le64_to_cpu(header.grain_offset) << 9);
if (ret < 0) {
error_setg(errp, "Could not truncate file");
error_setg_errno(errp, -ret, "Could not truncate file");
goto exit;
}
@ -1846,7 +1846,7 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options,
if (desc_offset == 0) {
ret = bdrv_truncate(new_bs, desc_len);
if (ret < 0) {
error_setg(errp, "Could not truncate file");
error_setg_errno(errp, -ret, "Could not truncate file");
}
}
exit: