From: Max Reitz Date: Tue, 18 Nov 2014 10:23:06 +0000 (+0100) Subject: block/raw-posix: Catch fsync() errors X-Git-Tag: qemu-xen-4.6.0-rc1~64^2 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=098ffa6674a82ceac0e3ccb3a8a5bf6ca44adcd5;p=qemu-upstream-4.6-testing.git block/raw-posix: Catch fsync() errors fsync() may fail, and that case should be handled. Reported-by: László Érsek Signed-off-by: Max Reitz Signed-off-by: Kevin Wolf --- diff --git a/block/raw-posix.c b/block/raw-posix.c index d106fc456..b1af77e47 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;