[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [Qemu-devel] [PATCH for-2.10 3/3] block: Add some bdrv_
From: |
Eric Blake |
Subject: |
Re: [Qemu-block] [Qemu-devel] [PATCH for-2.10 3/3] block: Add some bdrv_truncate() error messages |
Date: |
Mon, 6 Mar 2017 14:09:45 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 |
On 03/06/2017 01:54 PM, Max Reitz wrote:
> Add missing error messages for the drivers I am comfortable to do this
> in.
>
> Signed-off-by: Max Reitz <address@hidden>
> ---
> block/file-posix.c | 8 +++++++-
> block/qcow2.c | 2 ++
> block/qed.c | 4 +++-
> block/raw-format.c | 2 ++
> 4 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/block/file-posix.c b/block/file-posix.c
> index 9d2bea730d..553213221c 100644
> --- a/block/file-posix.c
> +++ b/block/file-posix.c
> @@ -1341,20 +1341,26 @@ static int raw_truncate(BlockDriverState *bs, int64_t
> offset, Error **errp)
> {
> BDRVRawState *s = bs->opaque;
> struct stat st;
> + int ret;
>
> if (fstat(s->fd, &st)) {
> - return -errno;
> + ret = -errno;
> + error_setg_errno(errp, -ret, "Failed to fstat() the file");
> + return ret;
> }
>
> if (S_ISREG(st.st_mode)) {
> if (ftruncate(s->fd, offset) < 0) {
> + /* The generic error message will be fine */
> return -errno;
Relying on a generic error message in the caller is awkward. I see it as
evidence of a partial conversion if we have an interface that requires a
return of a negative errno value to make up for when errp is not set. I
know you aren't comfortable converting all drivers, but for the drivers
you do convert, I'd rather guarantee that ALL errors set errp.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-block] [PATCH for-2.10 0/3] block: Add errp to b{lk, drv}_turncate(), Max Reitz, 2017/03/06
- [Qemu-block] [PATCH for-2.10 2/3] block: Add errp to BD.bdrv_truncate(), Max Reitz, 2017/03/06
- [Qemu-block] [PATCH for-2.10 1/3] block: Add errp to b{lk, drv}_truncate(), Max Reitz, 2017/03/06
- [Qemu-block] [PATCH for-2.10 3/3] block: Add some bdrv_truncate() error messages, Max Reitz, 2017/03/06
- Re: [Qemu-block] [Qemu-devel] [PATCH for-2.10 3/3] block: Add some bdrv_truncate() error messages,
Eric Blake <=
- Re: [Qemu-block] [Qemu-devel] [PATCH for-2.10 3/3] block: Add some bdrv_truncate() error messages, Max Reitz, 2017/03/06
- Re: [Qemu-block] [Qemu-devel] [PATCH for-2.10 3/3] block: Add some bdrv_truncate() error messages, Eric Blake, 2017/03/06
- Re: [Qemu-block] [Qemu-devel] [PATCH for-2.10 3/3] block: Add some bdrv_truncate() error messages, Max Reitz, 2017/03/06
- Re: [Qemu-block] [Qemu-devel] [PATCH for-2.10 3/3] block: Add some bdrv_truncate() error messages, Eric Blake, 2017/03/06
- Re: [Qemu-block] [Qemu-devel] [PATCH for-2.10 3/3] block: Add some bdrv_truncate() error messages, Kevin Wolf, 2017/03/07
Re: [Qemu-block] [Qemu-devel] [PATCH for-2.10 0/3] block: Add errp to b{lk, drv}_turncate(), no-reply, 2017/03/06