block: Add special error code for wrong format
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>
This commit is contained in:
parent
884fea4e87
commit
02582abd48
@ -617,8 +617,13 @@ DriveInfo *drive_init(QemuOpts *opts, BlockInterfaceType block_default_type)
|
|||||||
|
|
||||||
ret = bdrv_open(dinfo->bdrv, file, bdrv_flags, drv);
|
ret = bdrv_open(dinfo->bdrv, file, bdrv_flags, drv);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
error_report("could not open disk image %s: %s",
|
if (ret == -EMEDIUMTYPE) {
|
||||||
file, strerror(-ret));
|
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;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,6 +68,9 @@
|
|||||||
#if !defined(ECANCELED)
|
#if !defined(ECANCELED)
|
||||||
#define ECANCELED 4097
|
#define ECANCELED 4097
|
||||||
#endif
|
#endif
|
||||||
|
#if !defined(EMEDIUMTYPE)
|
||||||
|
#define EMEDIUMTYPE 4098
|
||||||
|
#endif
|
||||||
#ifndef TIME_MAX
|
#ifndef TIME_MAX
|
||||||
#define TIME_MAX LONG_MAX
|
#define TIME_MAX LONG_MAX
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user