From patchwork Tue Nov 18 11:35:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 411994 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 088F4140174 for ; Tue, 18 Nov 2014 22:36:19 +1100 (AEDT) Received: from localhost ([::1]:52550 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xqh4y-0001LE-W4 for incoming@patchwork.ozlabs.org; Tue, 18 Nov 2014 06:36:17 -0500 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 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sAIBZL7w000724 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 18 Nov 2014 06:35:21 -0500 Received: from noname.redhat.com (ovpn-116-25.ams2.redhat.com [10.36.116.25]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sAIBZAMr017795; Tue, 18 Nov 2014 06:35:20 -0500 From: Kevin Wolf To: qemu-devel@nongnu.org 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 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-MIME-Autoconverted: from 8bit to quoted-printable by mx1.redhat.com id sAIBZL7w000724 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, peter.maydell@linaro.org, mreitz@redhat.com Subject: [Qemu-devel] [PULL 6/6] block/raw-posix: Catch fsync() errors X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Max Reitz fsync() may fail, and that case should be handled. Reported-by: László Érsek 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, 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;