qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 2/4] block: Improve error report for wrong forma


From: Luiz Capitulino
Subject: Re: [Qemu-devel] [PATCH 2/4] block: Improve error report for wrong format
Date: Mon, 17 Dec 2012 13:08:01 -0200

On Sat, 15 Dec 2012 15:09:31 +0100
Stefan Weil <address@hidden> wrote:

> There is no good system error for this kind of error,
> so it needs special handling instead of strerror.
> 
> Signed-off-by: Stefan Weil <address@hidden>
> ---
>  blockdev.c |    9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/blockdev.c b/blockdev.c
> index 5a4cd56..3da44f6 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -624,8 +624,13 @@ DriveInfo *drive_init(QemuOpts *opts, BlockInterfaceType 
> block_default_type)
>  
>      ret = bdrv_open(dinfo->bdrv, file, bdrv_flags, drv);
>      if (ret < 0) {
> -        error_report("could not open disk image %s: %s",
> -                     file, strerror(-ret));
> +        if (ret == BDRV_WRONG_FORMAT) {
> +            error_report("could not open disk image %s: not in %s format",
> +                         file, drv->format_name);
> +        } else {
> +            error_report("could not open disk image %s: %s",
> +                         file, strerror(-ret));

IIRC, I have an rfc series propagating an Error object down to bdrv_open(),
and was planning to propagate it to block drivers. You could do it instead
of creating this new error code.

It's usually more work, but the end result is usually better.

> +        }
>          goto err;
>      }
>  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]