]> git.proxmox.com Git - qemu.git/commitdiff
block: Add special error code for wrong format
authorStefan Weil <sw@weilnetz.de>
Thu, 17 Jan 2013 20:45:24 +0000 (21:45 +0100)
committerKevin Wolf <kwolf@redhat.com>
Fri, 25 Jan 2013 17:18:35 +0000 (18:18 +0100)
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>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
blockdev.c
include/qemu-common.h

index ad25b9b86efb0827876d06006d154f60601b7da0..ac396f3c945e00f4220323387250678a2f30d867 100644 (file)
@@ -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;
     }
 
index ca464bb3679cdb5ade8b5188c754b4fd3d78ce97..af2379ff38473c62e324ce587541298c1a1ef9fe 100644 (file)
@@ -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