From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46582) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xqh4E-0000B4-5X for qemu-devel@nongnu.org; Tue, 18 Nov 2014 06:35:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xqh47-0007H2-Sx for qemu-devel@nongnu.org; Tue, 18 Nov 2014 06:35:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33869) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xqh47-0007Gx-Mo for qemu-devel@nongnu.org; Tue, 18 Nov 2014 06:35:23 -0500 From: Kevin Wolf Date: Tue, 18 Nov 2014 12:35:08 +0100 Message-Id: <1416310508-5122-7-git-send-email-kwolf@redhat.com> In-Reply-To: <1416310508-5122-1-git-send-email-kwolf@redhat.com> References: <1416310508-5122-1-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 6/6] block/raw-posix: Catch fsync() errors List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, peter.maydell@linaro.org, mreitz@redhat.com From: Max Reitz fsync() may fail, and that case should be handled. Reported-by: L=C3=A1szl=C3=B3 =C3=89rsek Signed-off-by: Max Reitz Signed-off-by: Kevin Wolf --- 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, QemuOp= ts *opts, Error **errp) left -=3D result; } if (result >=3D 0) { - fsync(fd); + result =3D fsync(fd); + if (result < 0) { + result =3D -errno; + error_setg_errno(errp, -result, + "Could not flush new file to disk"); + } } g_free(buf); break; --=20 1.8.3.1