From: Max Reitz <mre...@redhat.com> fsync() may fail, and that case should be handled.
Reported-by: László Érsek <ler...@redhat.com> Signed-off-by: Max Reitz <mre...@redhat.com> Signed-off-by: Kevin Wolf <kw...@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