qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PULL 6/6] block/raw-posix: Catch fsync() errors


From: Kevin Wolf
Subject: [Qemu-devel] [PULL 6/6] block/raw-posix: Catch fsync() errors
Date: Tue, 18 Nov 2014 12:35:08 +0100

From: Max Reitz <address@hidden>

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

Reported-by: László Érsek <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]