@@ -292,6 +292,14 @@ static int add_old_style_options(const char *fmt, QEMUOptionParameter *list,
return 0;
}
+static void qemu_img_handle_error(Error *err)
+{
+ if (error_is_set(&err)) {
+ error_report("%s", error_get_pretty(err));
+ error_free(err);
+ }
+}
+
static int img_create(int argc, char **argv)
{
int c;
@@ -367,8 +375,7 @@ static int img_create(int argc, char **argv)
bdrv_img_create(filename, fmt, base_filename, base_fmt,
options, img_size, BDRV_O_FLAGS, &local_err);
if (error_is_set(&local_err)) {
- error_report("%s", error_get_pretty(local_err));
- error_free(local_err);
+ qemu_img_handle_error(local_err);
return 1;
}
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- qemu-img.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)