mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
block: Error parameter for create functions
Add an Error ** parameter to bdrv_create and its associated functions to allow more specific error messages. Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
34b5d2c68e
commit
cc84d90ff5
9 changed files with 86 additions and 43 deletions
16
qemu-img.c
16
qemu-img.c
|
@ -1139,6 +1139,7 @@ static int img_convert(int argc, char **argv)
|
|||
float local_progress = 0;
|
||||
int min_sparse = 8; /* Need at least 4k of zeros for sparse detection */
|
||||
bool quiet = false;
|
||||
Error *local_err = NULL;
|
||||
|
||||
fmt = NULL;
|
||||
out_fmt = "raw";
|
||||
|
@ -1341,18 +1342,11 @@ static int img_convert(int argc, char **argv)
|
|||
|
||||
if (!skip_create) {
|
||||
/* Create the new image */
|
||||
ret = bdrv_create(drv, out_filename, param);
|
||||
ret = bdrv_create(drv, out_filename, param, &local_err);
|
||||
if (ret < 0) {
|
||||
if (ret == -ENOTSUP) {
|
||||
error_report("Formatting not supported for file format '%s'",
|
||||
out_fmt);
|
||||
} else if (ret == -EFBIG) {
|
||||
error_report("The image size is too large for file format '%s'",
|
||||
out_fmt);
|
||||
} else {
|
||||
error_report("%s: error while converting %s: %s",
|
||||
out_filename, out_fmt, strerror(-ret));
|
||||
}
|
||||
error_report("%s: error while converting %s: %s",
|
||||
out_filename, out_fmt, error_get_pretty(local_err));
|
||||
error_free(local_err);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue