From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58005) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XqfwU-0007MF-6u for qemu-devel@nongnu.org; Tue, 18 Nov 2014 05:23:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XqfwN-0008Px-Ug for qemu-devel@nongnu.org; Tue, 18 Nov 2014 05:23:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38893) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XqfwN-0008Pt-Mh for qemu-devel@nongnu.org; Tue, 18 Nov 2014 05:23:19 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sAIANIaU003452 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 18 Nov 2014 05:23:18 -0500 From: Max Reitz Date: Tue, 18 Nov 2014 11:23:06 +0100 Message-Id: <1416306186-19053-4-git-send-email-mreitz@redhat.com> In-Reply-To: <1416306186-19053-1-git-send-email-mreitz@redhat.com> References: <1416306186-19053-1-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH for-2.2 3/3] block/raw-posix: Catch fsync() errors List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , =?UTF-8?q?L=C3=A1szl=C3=B3=20=C3=89rsek?= , Stefan Hajnoczi , 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 --- 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 f67fb11..666cdec 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -1460,7 +1460,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.9.3