From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:59537) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkcIY-0001St-3r for qemu-devel@nongnu.org; Mon, 17 Dec 2012 10:08:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TkcIT-0004hn-5N for qemu-devel@nongnu.org; Mon, 17 Dec 2012 10:08:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:20831) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkcIS-0004hi-UZ for qemu-devel@nongnu.org; Mon, 17 Dec 2012 10:08:01 -0500 Date: Mon, 17 Dec 2012 13:08:01 -0200 From: Luiz Capitulino Message-ID: <20121217130801.67265153@doriath.home> In-Reply-To: <1355580573-19323-3-git-send-email-sw@weilnetz.de> References: <1355580573-19323-1-git-send-email-sw@weilnetz.de> <1355580573-19323-3-git-send-email-sw@weilnetz.de> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/4] block: Improve error report for wrong format List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Weil Cc: Kevin Wolf , qemu-devel@nongnu.org, Stefan Hajnoczi On Sat, 15 Dec 2012 15:09:31 +0100 Stefan Weil 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 > --- > 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; > } >