[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2] block/cow.c : return real error code in cow.
From: |
Kevin Wolf |
Subject: |
Re: [Qemu-devel] [PATCH v2] block/cow.c : return real error code in cow.c |
Date: |
Fri, 09 Dec 2011 11:57:08 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111115 Thunderbird/8.0 |
Am 09.12.2011 08:58, schrieb Li Zhi Hui:
> v2: modify some errors
>
> Signed-off-by: Li Zhi Hui <address@hidden>
> ---
> block/cow.c | 31 ++++++++++++++++++-------------
> 1 files changed, 18 insertions(+), 13 deletions(-)
>
> diff --git a/block/cow.c b/block/cow.c
> index 3c52735..51ca681 100644
> --- a/block/cow.c
> +++ b/block/cow.c
> @@ -64,15 +64,17 @@ static int cow_open(BlockDriverState *bs, int flags)
> struct cow_header_v2 cow_header;
> int bitmap_size;
> int64_t size;
> + int ret;
>
> /* see if it is a cow image */
> - if (bdrv_pread(bs->file, 0, &cow_header, sizeof(cow_header)) !=
> - sizeof(cow_header)) {
> + ret = bdrv_pread(bs->file, 0, &cow_header, sizeof(cow_header));
> + if (ret < 0) {
> goto fail;
> }
>
> if (be32_to_cpu(cow_header.magic) != COW_MAGIC ||
> be32_to_cpu(cow_header.version) != COW_VERSION) {
> + ret = -1;
ret is interpreted as -errno by the caller, so usually on Linux systems
you'll get a -EPERM (Operation not permitted) error message, which
doesn't describe the error very well.
I think a better return value for a wrong magic would be -EINVAL. For a
wrong version have a look at the qcow2 code (qerror_report and -ENOTSUP).
Kevin