qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, peter.maydell@linaro.org, mreitz@redhat.com
Subject: [Qemu-devel] [PULL 6/6] block/raw-posix: Catch fsync() errors
Date: Tue, 18 Nov 2014 12:35:08 +0100	[thread overview]
Message-ID: <1416310508-5122-7-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1416310508-5122-1-git-send-email-kwolf@redhat.com>

From: Max Reitz <mreitz@redhat.com>

fsync() may fail, and that case should be handled.

Reported-by: László Érsek <lersek@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/raw-posix.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/block/raw-posix.c b/block/raw-posix.c
index d106fc4..b1af77e 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -1454,7 +1454,12 @@ static int raw_create(const char *filename, QemuOpts *opts, Error **errp)
             left -= result;
         }
         if (result >= 0) {
-            fsync(fd);
+            result = fsync(fd);
+            if (result < 0) {
+                result = -errno;
+                error_setg_errno(errp, -result,
+                                 "Could not flush new file to disk");
+            }
         }
         g_free(buf);
         break;
-- 
1.8.3.1

  parent reply	other threads:[~2014-11-18 11:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-18 11:35 [Qemu-devel] [PULL 0/6] Block patches for 2.2.0-rc2 Kevin Wolf
2014-11-18 11:35 ` [Qemu-devel] [PULL 1/6] raw-posix: Fix comment for raw_co_get_block_status() Kevin Wolf
2014-11-18 11:35 ` [Qemu-devel] [PULL 2/6] raw-posix: SEEK_HOLE suffices, get rid of FIEMAP Kevin Wolf
2014-11-18 11:35 ` [Qemu-devel] [PULL 3/6] raw-posix: The SEEK_HOLE code is flawed, rewrite it Kevin Wolf
2014-11-18 11:35 ` [Qemu-devel] [PULL 4/6] block/raw-posix: Fix preallocating write() loop Kevin Wolf
2014-11-18 11:35 ` [Qemu-devel] [PULL 5/6] block/raw-posix: Only sync after successful preallocation Kevin Wolf
2014-11-18 11:35 ` Kevin Wolf [this message]
2014-11-18 14:46 ` [Qemu-devel] [PULL 0/6] Block patches for 2.2.0-rc2 Peter Maydell

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=1416310508-5122-7-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=peter.maydell@linaro.org \
    --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).