qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, pbonzini@redhat.com, armbru@redhat.com
Subject: [Qemu-devel] [PATCH 8/8] block: bdrv_img_create(): drop unused error handling code
Date: Wed, 17 Oct 2012 16:35:56 -0300	[thread overview]
Message-ID: <1350502556-4885-9-git-send-email-lcapitulino@redhat.com> (raw)
In-Reply-To: <1350502556-4885-1-git-send-email-lcapitulino@redhat.com>

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 block.c | 41 ++++++-----------------------------------
 block.h |  8 ++++----
 2 files changed, 10 insertions(+), 39 deletions(-)

diff --git a/block.c b/block.c
index 83bcab5..5e8184f 100644
--- a/block.c
+++ b/block.c
@@ -4292,10 +4292,10 @@ bdrv_acct_done(BlockDriverState *bs, BlockAcctCookie *cookie)
     bs->total_time_ns[cookie->type] += get_clock() - cookie->start_time_ns;
 }
 
-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,
-                    QEMUOptionParameter **param_list, 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,
+                     QEMUOptionParameter **param_list, Error **errp)
 {
     QEMUOptionParameter *param = NULL, *create_options = NULL;
     QEMUOptionParameter *backing_fmt, *backing_file, *size;
@@ -4307,18 +4307,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,
@@ -4335,9 +4331,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;
         }
     }
@@ -4345,22 +4339,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;
         }
     }
@@ -4368,11 +4356,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;
         }
     }
@@ -4381,11 +4366,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;
         }
     }
@@ -4417,29 +4399,20 @@ 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;
         }
     }
 
     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));
         }
@@ -4456,6 +4429,4 @@ out:
     if (bs) {
         bdrv_delete(bs);
     }
-
-    return ret;
 }
diff --git a/block.h b/block.h
index 49d89a1..f26e52f 100644
--- a/block.h
+++ b/block.h
@@ -339,10 +339,10 @@ 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,
-                    QEMUOptionParameter **param_list, 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,
+                     QEMUOptionParameter **param_list, Error **errp);
 
 void bdrv_set_buffer_alignment(BlockDriverState *bs, int align);
 void *qemu_blockalign(BlockDriverState *bs, size_t size);
-- 
1.7.12.315.g682ce8b

      parent reply	other threads:[~2012-10-17 19:35 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-17 19:35 [Qemu-devel] [PATCH 0/8] block: bdrv_img_create(): propagate errors Luiz Capitulino
2012-10-17 19:35 ` [Qemu-devel] [PATCH 1/8] error: add error_set_errno and error_setg_errno Luiz Capitulino
2012-10-17 19:35 ` [Qemu-devel] [PATCH 2/8] block: bdrv_img_create(): add param_list argument Luiz Capitulino
2012-10-18 11:57   ` Kevin Wolf
2012-10-18 13:33     ` Luiz Capitulino
2012-10-18 17:18       ` Luiz Capitulino
2012-10-19  9:13         ` Kevin Wolf
2012-10-19 12:49           ` Luiz Capitulino
2012-10-17 19:35 ` [Qemu-devel] [PATCH 3/8] block: bdrv_img_create(): move parameter list printing to qemu-img Luiz Capitulino
2012-10-18 12:01   ` Kevin Wolf
2012-10-18 12:16     ` Kevin Wolf
2012-10-18 13:34       ` Luiz Capitulino
2012-10-17 19:35 ` [Qemu-devel] [PATCH 4/8] block: bdrv_img_create(): add Error ** argument Luiz Capitulino
2012-10-18 12:08   ` Kevin Wolf
2012-10-18 13:41     ` Luiz Capitulino
2012-10-17 19:35 ` [Qemu-devel] [PATCH 5/8] qemu-img: img_create(): use Error object Luiz Capitulino
2012-10-18 12:11   ` Kevin Wolf
2012-10-18 13:49     ` Luiz Capitulino
2012-10-18 14:02       ` Kevin Wolf
2012-10-23  9:58         ` Markus Armbruster
2012-10-23 10:08           ` Kevin Wolf
2012-10-23 13:07             ` Luiz Capitulino
2012-10-17 19:35 ` [Qemu-devel] [PATCH 6/8] qemu-img: img_create(): simplify Luiz Capitulino
2012-10-17 19:35 ` [Qemu-devel] [PATCH 7/8] qmp: qmp_transaction(): pass Error object to bdrv_img_create() Luiz Capitulino
2012-10-17 19:35 ` Luiz Capitulino [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1350502556-4885-9-git-send-email-lcapitulino@redhat.com \
    --to=lcapitulino@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).