qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Li Zhi Hui <zhihuili@linux.vnet.ibm.com>
Cc: qemu-devel@nongnu.org, stefanha@linux.vnet.ibm.com
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	[thread overview]
Message-ID: <4EE1E984.6070800@redhat.com> (raw)
In-Reply-To: <1323417518-10195-1-git-send-email-zhihuili@linux.vnet.ibm.com>

Am 09.12.2011 08:58, schrieb Li Zhi Hui:
> v2: modify some errors
> 
> Signed-off-by: Li Zhi Hui <zhihuili@linux.vnet.ibm.com>
> ---
>  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

      reply	other threads:[~2011-12-09 10:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-09  7:58 [Qemu-devel] [PATCH v2] block/cow.c : return real error code in cow.c Li Zhi Hui
2011-12-09 10:57 ` Kevin Wolf [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EE1E984.6070800@redhat.com \
    --to=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@linux.vnet.ibm.com \
    --cc=zhihuili@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).