From 57a9023ba5482c22d6f40b7676c10a3a06fd0dba Mon Sep 17 00:00:00 2001 Message-Id: <57a9023ba5482c22d6f40b7676c10a3a06fd0dba.1368098699.git.minovotn@redhat.com> In-Reply-To: <618a4b91ddb04b21f9dc0c1defe7693fb7cc1748.1368098699.git.minovotn@redhat.com> References: <618a4b91ddb04b21f9dc0c1defe7693fb7cc1748.1368098699.git.minovotn@redhat.com> From: Laszlo Ersek Date: Thu, 18 Apr 2013 19:04:44 +0200 Subject: [PATCH 20/24] block: bdrv_img_create(): drop unused error handling code RH-Author: Laszlo Ersek Message-id: <1366311884-18091-6-git-send-email-lersek@redhat.com> Patchwork-id: 50693 O-Subject: [RHEL-6.5 qemu-kvm PATCH 5/5] block: bdrv_img_create(): drop unused error handling code Bugzilla: 877240 RH-Acked-by: Stefan Hajnoczi RH-Acked-by: Paolo Bonzini RH-Acked-by: Luiz Capitulino Signed-off-by: Luiz Capitulino Signed-off-by: Kevin Wolf (cherry picked from commit d92ada2202a0730e396304908ff7b870168387d2) Conflicts: block.c Signed-off-by: Laszlo Ersek --- block.h | 6 +++--- block.c | 40 +++++----------------------------------- 2 files changed, 8 insertions(+), 38 deletions(-) Signed-off-by: Michal Novotny --- block.c | 40 +++++----------------------------------- block.h | 6 +++--- 2 files changed, 8 insertions(+), 38 deletions(-) diff --git a/block.c b/block.c index 5d64f22..d3ebbe8 100644 --- a/block.c +++ b/block.c @@ -4025,9 +4025,9 @@ int bdrv_in_use(BlockDriverState *bs) return bs->in_use; } -int bdrv_img_create(const char *filename, const char *fmt, - const char *base_filename, const char *base_fmt, - char *options, uint64_t img_size, int flags, Error **errp) +void bdrv_img_create(const char *filename, const char *fmt, + const char *base_filename, const char *base_fmt, + char *options, uint64_t img_size, int flags, Error **errp) { QEMUOptionParameter *param = NULL, *create_options = NULL; QEMUOptionParameter *backing_fmt, *backing_file; @@ -4039,18 +4039,14 @@ int bdrv_img_create(const char *filename, const char *fmt, /* Find driver and parse its options */ drv = bdrv_find_format(fmt); if (!drv) { - error_report("Unknown file format '%s'", fmt); error_setg(errp, "Unknown file format '%s'", fmt); - ret = -EINVAL; - goto out; + return; } proto_drv = bdrv_find_protocol(filename); if (!proto_drv) { - error_report("Unknown protocol '%s'", filename); error_setg(errp, "Unknown protocol '%s'", filename); - ret = -EINVAL; - goto out; + return; } create_options = append_option_parameters(create_options, @@ -4067,9 +4063,7 @@ int bdrv_img_create(const char *filename, const char *fmt, if (options) { param = parse_option_parameters(options, create_options, param); if (param == NULL) { - error_report("Invalid options for file format '%s'.", fmt); error_setg(errp, "Invalid options for file format '%s'.", fmt); - ret = -EINVAL; goto out; } } @@ -4077,22 +4071,16 @@ int bdrv_img_create(const char *filename, const char *fmt, if (base_filename) { if (set_option_parameter(param, BLOCK_OPT_BACKING_FILE, base_filename)) { - error_report("Backing file not supported for file format '%s'", - fmt); error_setg(errp, "Backing file not supported for file format '%s'", fmt); - ret = -EINVAL; goto out; } } if (base_fmt) { if (set_option_parameter(param, BLOCK_OPT_BACKING_FMT, base_fmt)) { - error_report("Backing file format not supported for file " - "format '%s'", fmt); error_setg(errp, "Backing file format not supported for file " "format '%s'", fmt); - ret = -EINVAL; goto out; } } @@ -4100,11 +4088,8 @@ int bdrv_img_create(const char *filename, const char *fmt, backing_file = get_option_parameter(param, BLOCK_OPT_BACKING_FILE); if (backing_file && backing_file->value.s) { if (!strcmp(filename, backing_file->value.s)) { - error_report("Error: Trying to create an image with the " - "same filename as the backing file"); error_setg(errp, "Error: Trying to create an image with the " "same filename as the backing file"); - ret = -EINVAL; goto out; } } @@ -4113,11 +4098,8 @@ int bdrv_img_create(const char *filename, const char *fmt, if (backing_fmt && backing_fmt->value.s) { backing_drv = bdrv_find_format(backing_fmt->value.s); if (!backing_drv) { - error_report("Unknown backing file format '%s'", - backing_fmt->value.s); error_setg(errp, "Unknown backing file format '%s'", backing_fmt->value.s); - ret = -EINVAL; goto out; } } @@ -4138,7 +4120,6 @@ int bdrv_img_create(const char *filename, const char *fmt, ret = bdrv_open(bs, backing_file->value.s, back_flags, backing_drv); if (ret < 0) { - error_report("Could not open '%s'", backing_file->value.s); error_setg_errno(errp, -ret, "Could not open '%s'", backing_file->value.s); goto out; @@ -4149,9 +4130,7 @@ int bdrv_img_create(const char *filename, const char *fmt, snprintf(buf, sizeof(buf), "%" PRId64, size); set_option_parameter(param, BLOCK_OPT_SIZE, buf); } else { - error_report("Image creation needs a size parameter"); error_setg(errp, "Image creation needs a size parameter"); - ret = -EINVAL; goto out; } } @@ -4161,21 +4140,14 @@ int bdrv_img_create(const char *filename, const char *fmt, puts(""); ret = bdrv_create(drv, filename, param); - if (ret < 0) { if (ret == -ENOTSUP) { - error_report("Formatting or formatting option not supported for " - "file format '%s'", fmt); error_setg(errp,"Formatting or formatting option not supported for " "file format '%s'", fmt); } else if (ret == -EFBIG) { - error_report("The image size is too large for file format '%s'", - fmt); error_setg(errp, "The image size is too large for file format '%s'", fmt); } else { - error_report("%s: error while creating %s: %s", filename, fmt, - strerror(-ret)); error_setg(errp, "%s: error while creating %s: %s", filename, fmt, strerror(-ret)); } @@ -4188,8 +4160,6 @@ out: if (bs) { bdrv_delete(bs); } - - return ret; } void *block_job_create(const BlockJobType *job_type, BlockDriverState *bs, diff --git a/block.h b/block.h index f0afbd9..cb3f1f1 100644 --- a/block.h +++ b/block.h @@ -349,9 +349,9 @@ int bdrv_save_vmstate(BlockDriverState *bs, const uint8_t *buf, int bdrv_load_vmstate(BlockDriverState *bs, uint8_t *buf, int64_t pos, int size); -int bdrv_img_create(const char *filename, const char *fmt, - const char *base_filename, const char *base_fmt, - char *options, uint64_t img_size, int flags, Error **errp); +void bdrv_img_create(const char *filename, const char *fmt, + const char *base_filename, const char *base_fmt, + char *options, uint64_t img_size, int flags, Error **errp); struct HBitmapIter; void bdrv_set_dirty_tracking(BlockDriverState *bs, int granularity); -- 1.7.11.7