]> git.proxmox.com Git - mirror_qemu.git/commitdiff
block/raw-posix: Catch fsync() errors
authorMax Reitz <mreitz@redhat.com>
Tue, 18 Nov 2014 10:23:06 +0000 (11:23 +0100)
committerKevin Wolf <kwolf@redhat.com>
Tue, 18 Nov 2014 11:09:00 +0000 (12:09 +0100)
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

index d106fc456b842c9cd04aa9388df25b5654e84633..b1af77e47fc2e1aad55127b6383fc57e3540b6d3 100644 (file)
@@ -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;