qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alon Levy <alevy@redhat.com>
To: qemu-devel@nongnu.org, lcapitulino@redhat.com
Cc: mlureau@redhat.com
Subject: [Qemu-devel] [PATCH v2 5/5] blockdev: use error_set_file_open_failed
Date: Thu, 15 Mar 2012 00:55:14 +0200	[thread overview]
Message-ID: <1331765714-26209-6-git-send-email-alevy@redhat.com> (raw)
In-Reply-To: <1331765714-26209-1-git-send-email-alevy@redhat.com>

This is a little trickier, since those calls chain in many fun ways and
produce sometimes their own return values reusing existing errno values
for similar meanings. In that respect error_set_file_open_failed
specifically ignores EINVAL, ENOTSUP and ENOENT. The first two simply
are not returned by open (2), but the last is but I chose to ignore it
to allow easy reuse in blockdev to avoid confusion when it is used
internally by the create functions.

Signed-off-by: Alon Levy <alevy@redhat.com>
---
 blockdev.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/blockdev.c b/blockdev.c
index 1a500b8..544d067 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -777,7 +777,7 @@ void qmp_transaction(BlockdevActionList *dev_list, Error **errp)
                                   states->old_bs->drv->format_name,
                                   NULL, -1, flags);
             if (ret) {
-                error_set(errp, QERR_OPEN_FILE_FAILED, new_image_file);
+                error_set_file_open_failed(errp, new_image_file, -ret);
                 goto delete_and_fail;
             }
         }
@@ -787,7 +787,7 @@ void qmp_transaction(BlockdevActionList *dev_list, Error **errp)
         ret = bdrv_open(states->new_bs, new_image_file,
                         flags | BDRV_O_NO_BACKING, drv);
         if (ret != 0) {
-            error_set(errp, QERR_OPEN_FILE_FAILED, new_image_file);
+            error_set_file_open_failed(errp, new_image_file, -ret);
             goto delete_and_fail;
         }
     }
@@ -881,8 +881,11 @@ static void qmp_bdrv_open_encrypted(BlockDriverState *bs, const char *filename,
                                     int bdrv_flags, BlockDriver *drv,
                                     const char *password, Error **errp)
 {
-    if (bdrv_open(bs, filename, bdrv_flags, drv) < 0) {
-        error_set(errp, QERR_OPEN_FILE_FAILED, filename);
+    int ret;
+
+    ret = bdrv_open(bs, filename, bdrv_flags, drv);
+    if (ret < 0) {
+        error_set_file_open_failed(errp, filename, ret);
         return;
     }
 
-- 
1.7.9.3

  parent reply	other threads:[~2012-03-14 22:55 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-14 22:55 [Qemu-devel] [PATCH v2 0/5] screendump qapi convertion Alon Levy
2012-03-14 22:55 ` [Qemu-devel] [PATCH v2 1/5] error: add error_set_file_open_failed Alon Levy
2012-03-15 14:52   ` Luiz Capitulino
2012-03-15 15:21     ` Alon Levy
2012-03-15 16:00       ` Luiz Capitulino
2012-03-14 22:55 ` [Qemu-devel] [PATCH v2 2/5] vga_hw_screen_dump: add Error** param Alon Levy
2012-03-15 14:54   ` Luiz Capitulino
2012-03-15 15:22     ` Alon Levy
2012-03-14 22:55 ` [Qemu-devel] [PATCH v2 3/5] qapi: convert screendump Alon Levy
2012-03-15 14:55   ` Luiz Capitulino
2012-03-15 15:23     ` Alon Levy
2012-03-14 22:55 ` [Qemu-devel] [PATCH v2 4/5] vga: ppm_save(): Return error on failure Alon Levy
2012-03-14 22:55 ` Alon Levy [this message]
2012-03-15 14:56   ` [Qemu-devel] [PATCH v2 5/5] blockdev: use error_set_file_open_failed Luiz Capitulino
2012-03-15 15:23     ` Alon Levy
2012-03-18 18:29 ` [Qemu-devel] [PATCH v3 0/5] screendump qapi convertion Alon Levy
2012-03-18 18:29   ` [Qemu-devel] [PATCH v3 1/5] qerror: add error codes for fopen failure Alon Levy
2012-03-23 14:21     ` Luiz Capitulino
2012-03-23 19:53       ` Alon Levy
2012-03-23 20:48         ` Luiz Capitulino
2012-03-26 18:44       ` Alon Levy
2012-03-26 18:51       ` Alon Levy
2012-03-18 18:29   ` [Qemu-devel] [PATCH v3 2/5] add qemu_fopen_err Alon Levy
2012-03-23 14:22     ` Luiz Capitulino
2012-03-23 19:55       ` Alon Levy
2012-03-18 18:29   ` [Qemu-devel] [PATCH v3 3/5] vga_hw_screen_dump: add Error** param Alon Levy
2012-03-18 18:29   ` [Qemu-devel] [PATCH v3 4/5] qapi: convert screendump Alon Levy
2012-03-23 14:25     ` Luiz Capitulino
2012-03-18 18:29   ` [Qemu-devel] [PATCH v3 5/5] vga: ppm_save(): Return error on failure Alon Levy
2012-03-23 14:27     ` Luiz Capitulino
2012-03-23 19:54       ` Alon Levy

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=1331765714-26209-6-git-send-email-alevy@redhat.com \
    --to=alevy@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=mlureau@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).