From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37861) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvwLN-0006Sg-G0 for qemu-devel@nongnu.org; Thu, 17 Jan 2013 15:45:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TvwLH-000435-Qs for qemu-devel@nongnu.org; Thu, 17 Jan 2013 15:45:49 -0500 Received: from v220110690675601.yourvserver.net ([78.47.199.172]:46788) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvwLH-00042w-JX for qemu-devel@nongnu.org; Thu, 17 Jan 2013 15:45:43 -0500 From: Stefan Weil Date: Thu, 17 Jan 2013 21:45:24 +0100 Message-Id: <1358455528-29813-2-git-send-email-sw@weilnetz.de> In-Reply-To: <1358455528-29813-1-git-send-email-sw@weilnetz.de> References: <1358455528-29813-1-git-send-email-sw@weilnetz.de> Subject: [Qemu-devel] [PATCH v2 1/5] block: Add special error code for wrong format List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Weil , Stefan Hajnoczi The block drivers need a special error code for "wrong format". >>From the available error codes EMEDIUMTYPE fits best. It is not available on all platforms, so a definition in qemu-common.h and a specific error report are needed. Signed-off-by: Stefan Weil --- blockdev.c | 9 +++++++-- include/qemu-common.h | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/blockdev.c b/blockdev.c index 9126587..34cde32 100644 --- a/blockdev.c +++ b/blockdev.c @@ -617,8 +617,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 == -EMEDIUMTYPE) { + 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)); + } goto err; } diff --git a/include/qemu-common.h b/include/qemu-common.h index ca464bb..af2379f 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -68,6 +68,9 @@ #if !defined(ECANCELED) #define ECANCELED 4097 #endif +#if !defined(EMEDIUMTYPE) +#define EMEDIUMTYPE 4098 +#endif #ifndef TIME_MAX #define TIME_MAX LONG_MAX #endif -- 1.7.10.4