qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Weil <sw@weilnetz.de>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Stefan Weil <sw@weilnetz.de>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH v2 1/5] block: Add special error code for wrong format
Date: Thu, 17 Jan 2013 21:45:24 +0100	[thread overview]
Message-ID: <1358455528-29813-2-git-send-email-sw@weilnetz.de> (raw)
In-Reply-To: <1358455528-29813-1-git-send-email-sw@weilnetz.de>

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 <sw@weilnetz.de>
---
 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

  reply	other threads:[~2013-01-17 20:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-17 20:45 [Qemu-devel] [PATCH v2 0/5] block: Fix error report for wrong file format Stefan Weil
2013-01-17 20:45 ` Stefan Weil [this message]
2013-01-17 20:45 ` [Qemu-devel] [PATCH v2 2/5] block: Use error code EMEDIUMTYPE for wrong format in some block drivers Stefan Weil
2013-01-18  8:53   ` Markus Armbruster
2013-01-18 18:10     ` Stefan Weil
2013-01-21 11:03       ` Markus Armbruster
2013-01-17 20:45 ` [Qemu-devel] [PATCH v2 3/5] block/vdi: Improve debug output for signature Stefan Weil
2013-01-17 20:45 ` [Qemu-devel] [PATCH v2 4/5] block/vdi: Improved return values from vdi_open Stefan Weil
2013-01-17 20:45 ` [Qemu-devel] [PATCH v2 5/5] block/vdi: Check for bad signature Stefan Weil
2013-01-17 21:28 ` [Qemu-devel] [PATCH v2 0/5] block: Fix error report for wrong file format Eric Blake
2013-01-17 22:25   ` Stefan Weil
2013-01-17 22:41     ` Eric Blake

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=1358455528-29813-2-git-send-email-sw@weilnetz.de \
    --to=sw@weilnetz.de \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.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).