From nobody Fri May 3 03:57:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502109973654490.35113362181835; Mon, 7 Aug 2017 05:46:13 -0700 (PDT) Received: from localhost ([::1]:37143 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dehQC-0002Fy-7Z for importer@patchew.org; Mon, 07 Aug 2017 08:46:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53498) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dehIu-0003Vu-S7 for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dehIp-0003Ib-PW for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47402) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dehIf-00039P-3Q; Mon, 07 Aug 2017 08:38:25 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 09183285A0; Mon, 7 Aug 2017 12:38:24 +0000 (UTC) Received: from localhost (ovpn-116-54.phx2.redhat.com [10.3.116.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9265D9172C; Mon, 7 Aug 2017 12:38:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 09183285A0 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jcody@redhat.com From: Jeff Cody To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 08:38:19 -0400 Message-Id: <102a86250b48b54d3a5a60bfa9f49a33c0735c13.1502109078.git.jcody@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 07 Aug 2017 12:38:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 for-2.10 1/4] block/vhdx: check error return of bdrv_getlength() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, armbru@redhat.com, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Calls to bdrv_getlength() were not checking for error. In vhdx.c, this can lead to truncating an image file, so it is a definite bug. In vhdx-log.c, the path for improper behavior is less clear, but it is best to check in any case. Some minor code movement of the log_guid intialization, as well. Reported-by: Markus Armbruster Reviewed-by: Eric Blake Signed-off-by: Jeff Cody --- block/vhdx-log.c | 23 ++++++++++++++++++----- block/vhdx.c | 9 ++++++++- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/block/vhdx-log.c b/block/vhdx-log.c index 01278f3..2e26fd4 100644 --- a/block/vhdx-log.c +++ b/block/vhdx-log.c @@ -491,6 +491,7 @@ static int vhdx_log_flush(BlockDriverState *bs, BDRVVHD= XState *s, uint32_t cnt, sectors_read; uint64_t new_file_size; void *data =3D NULL; + int64_t file_length; VHDXLogDescEntries *desc_entries =3D NULL; VHDXLogEntryHeader hdr_tmp =3D { 0 }; =20 @@ -510,10 +511,15 @@ static int vhdx_log_flush(BlockDriverState *bs, BDRVV= HDXState *s, if (ret < 0) { goto exit; } + file_length =3D bdrv_getlength(bs->file->bs); + if (file_length < 0) { + ret =3D file_length; + goto exit; + } /* if the log shows a FlushedFileOffset larger than our current fi= le * size, then that means the file has been truncated / corrupted, = and * we must refused to open it / use it */ - if (hdr_tmp.flushed_file_offset > bdrv_getlength(bs->file->bs)) { + if (hdr_tmp.flushed_file_offset > file_length) { ret =3D -EINVAL; goto exit; } @@ -543,7 +549,7 @@ static int vhdx_log_flush(BlockDriverState *bs, BDRVVHD= XState *s, goto exit; } } - if (bdrv_getlength(bs->file->bs) < desc_entries->hdr.last_file_off= set) { + if (file_length < desc_entries->hdr.last_file_offset) { new_file_size =3D desc_entries->hdr.last_file_offset; if (new_file_size % (1024*1024)) { /* round up to nearest 1MB boundary */ @@ -851,6 +857,7 @@ static int vhdx_log_write(BlockDriverState *bs, BDRVVHD= XState *s, uint32_t partial_sectors =3D 0; uint32_t bytes_written =3D 0; uint64_t file_offset; + int64_t file_length; VHDXHeader *header; VHDXLogEntryHeader new_hdr; VHDXLogDescriptor *new_desc =3D NULL; @@ -904,6 +911,12 @@ static int vhdx_log_write(BlockDriverState *bs, BDRVVH= DXState *s, =20 sectors +=3D partial_sectors; =20 + file_length =3D bdrv_getlength(bs->file->bs); + if (file_length < 0) { + ret =3D file_length; + goto exit; + } + /* sectors is now how many sectors the data itself takes, not * including the header and descriptor metadata */ =20 @@ -913,11 +926,11 @@ static int vhdx_log_write(BlockDriverState *bs, BDRVV= HDXState *s, .sequence_number =3D s->log.sequence, .descriptor_count =3D sectors, .reserved =3D 0, - .flushed_file_offset =3D bdrv_getlength(bs->file->bs), - .last_file_offset =3D bdrv_getlength(bs->file->bs), + .flushed_file_offset =3D file_length, + .last_file_offset =3D file_length, + .log_guid =3D header->log_guid, }; =20 - new_hdr.log_guid =3D header->log_guid; =20 desc_sectors =3D vhdx_compute_desc_sectors(new_hdr.descriptor_count); =20 diff --git a/block/vhdx.c b/block/vhdx.c index a9cecd2..37224b8 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -1166,7 +1166,14 @@ exit: static int vhdx_allocate_block(BlockDriverState *bs, BDRVVHDXState *s, uint64_t *new_offset) { - *new_offset =3D bdrv_getlength(bs->file->bs); + int64_t current_len; + + current_len =3D bdrv_getlength(bs->file->bs); + if (current_len < 0) { + return current_len; + } + + *new_offset =3D current_len; =20 /* per the spec, the address for a block is in units of 1MB */ *new_offset =3D ROUND_UP(*new_offset, 1024 * 1024); --=20 2.9.4 From nobody Fri May 3 03:57:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502109926081974.7447510945415; Mon, 7 Aug 2017 05:45:26 -0700 (PDT) Received: from localhost ([::1]:37137 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dehPQ-0001Hm-Ee for importer@patchew.org; Mon, 07 Aug 2017 08:45:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53505) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dehIv-0003WA-3E for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dehIp-0003In-VA for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43088) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dehIf-00039w-Pu; Mon, 07 Aug 2017 08:38:25 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C2520787FB; Mon, 7 Aug 2017 12:38:24 +0000 (UTC) Received: from localhost (ovpn-116-54.phx2.redhat.com [10.3.116.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 70EEB52FCF; Mon, 7 Aug 2017 12:38:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C2520787FB Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jcody@redhat.com From: Jeff Cody To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 08:38:20 -0400 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 07 Aug 2017 12:38:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 for-2.10 2/4] block/vhdx: check for offset overflow to bdrv_truncate() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, armbru@redhat.com, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" VHDX uses uint64_t types for most offsets, following the VHDX spec. However, bdrv_truncate() takes an int64_t value for the truncating offset. Check for overflow before calling bdrv_truncate(). While we are here, replace the bit shifting with QEMU_ALIGN_UP as well. N.B.: For a compliant image this is not an issue, as the maximum VHDX image size is defined per the spec to be 64TB. Reviewed-by: Eric Blake Reviewed-by: Kevin Wolf Signed-off-by: Jeff Cody Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- block/vhdx-log.c | 6 +++++- block/vhdx.c | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/block/vhdx-log.c b/block/vhdx-log.c index 2e26fd4..9597223 100644 --- a/block/vhdx-log.c +++ b/block/vhdx-log.c @@ -553,7 +553,11 @@ static int vhdx_log_flush(BlockDriverState *bs, BDRVVH= DXState *s, new_file_size =3D desc_entries->hdr.last_file_offset; if (new_file_size % (1024*1024)) { /* round up to nearest 1MB boundary */ - new_file_size =3D ((new_file_size >> 20) + 1) << 20; + new_file_size =3D QEMU_ALIGN_UP(new_file_size, MiB); + if (new_file_size > INT64_MAX) { + ret =3D -EINVAL; + goto exit; + } bdrv_truncate(bs->file, new_file_size, PREALLOC_MODE_OFF, = NULL); } } diff --git a/block/vhdx.c b/block/vhdx.c index 37224b8..7ae4589 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -1177,6 +1177,9 @@ static int vhdx_allocate_block(BlockDriverState *bs, = BDRVVHDXState *s, =20 /* per the spec, the address for a block is in units of 1MB */ *new_offset =3D ROUND_UP(*new_offset, 1024 * 1024); + if (*new_offset > INT64_MAX) { + return -EINVAL; + } =20 return bdrv_truncate(bs->file, *new_offset + s->block_size, PREALLOC_MODE_OFF, NULL); --=20 2.9.4 From nobody Fri May 3 03:57:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150211008666054.0972754243777; Mon, 7 Aug 2017 05:48:06 -0700 (PDT) Received: from localhost ([::1]:37147 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dehS1-0003ba-82 for importer@patchew.org; Mon, 07 Aug 2017 08:48:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53517) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dehIv-0003Wb-Ii for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dehIq-0003Je-Qw for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47556) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dehIg-0003Am-Py; Mon, 07 Aug 2017 08:38:26 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C53B6356ED; Mon, 7 Aug 2017 12:38:25 +0000 (UTC) Received: from localhost (ovpn-116-54.phx2.redhat.com [10.3.116.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7749418967; Mon, 7 Aug 2017 12:38:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C53B6356ED Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jcody@redhat.com From: Jeff Cody To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 08:38:21 -0400 Message-Id: <3f89708534aeb149ebf4a0e3e54b4c24b44a1116.1502109078.git.jcody@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 07 Aug 2017 12:38:25 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 for-2.10 3/4] block/vhdx: check error return of bdrv_flush() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, armbru@redhat.com, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Reported-by: Kevin Wolf Signed-off-by: Jeff Cody Reviewed-by: Eric Blake --- block/vhdx-log.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/block/vhdx-log.c b/block/vhdx-log.c index 9597223..a27dc05 100644 --- a/block/vhdx-log.c +++ b/block/vhdx-log.c @@ -565,7 +565,10 @@ static int vhdx_log_flush(BlockDriverState *bs, BDRVVH= DXState *s, desc_entries =3D NULL; } =20 - bdrv_flush(bs); + ret =3D bdrv_flush(bs); + if (ret < 0) { + goto exit; + } /* once the log is fully flushed, indicate that we have an empty log * now. This also sets the log guid to 0, to indicate an empty log */ vhdx_log_reset(bs, s); @@ -1039,7 +1042,11 @@ int vhdx_log_write_and_flush(BlockDriverState *bs, B= DRVVHDXState *s, =20 /* Make sure data written (new and/or changed blocks) is stable * on disk, before creating log entry */ - bdrv_flush(bs); + ret =3D bdrv_flush(bs); + if (ret < 0) { + goto exit; + } + ret =3D vhdx_log_write(bs, s, data, length, offset); if (ret < 0) { goto exit; @@ -1047,7 +1054,11 @@ int vhdx_log_write_and_flush(BlockDriverState *bs, B= DRVVHDXState *s, logs.log =3D s->log; =20 /* Make sure log is stable on disk */ - bdrv_flush(bs); + ret =3D bdrv_flush(bs); + if (ret < 0) { + goto exit; + } + ret =3D vhdx_log_flush(bs, s, &logs); if (ret < 0) { goto exit; --=20 2.9.4 From nobody Fri May 3 03:57:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502110044537733.0169163457548; Mon, 7 Aug 2017 05:47:24 -0700 (PDT) Received: from localhost ([::1]:37146 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dehRL-00039D-8D for importer@patchew.org; Mon, 07 Aug 2017 08:47:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53530) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dehIw-0003XP-FE for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dehIr-0003KO-Qk for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41596) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dehIh-0003Bm-RK; Mon, 07 Aug 2017 08:38:27 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C6BC4C047B7A; Mon, 7 Aug 2017 12:38:26 +0000 (UTC) Received: from localhost (ovpn-116-54.phx2.redhat.com [10.3.116.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5FDD686E62; Mon, 7 Aug 2017 12:38:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C6BC4C047B7A Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jcody@redhat.com From: Jeff Cody To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 08:38:22 -0400 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 07 Aug 2017 12:38:26 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 for-2.10 4/4] block/vhdx: check error return of bdrv_truncate() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, armbru@redhat.com, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jeff Cody Reviewed-by: Eric Blake --- block/vhdx-log.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/block/vhdx-log.c b/block/vhdx-log.c index a27dc05..14b724e 100644 --- a/block/vhdx-log.c +++ b/block/vhdx-log.c @@ -558,7 +558,11 @@ static int vhdx_log_flush(BlockDriverState *bs, BDRVVH= DXState *s, ret =3D -EINVAL; goto exit; } - bdrv_truncate(bs->file, new_file_size, PREALLOC_MODE_OFF, = NULL); + ret =3D bdrv_truncate(bs->file, new_file_size, PREALLOC_MO= DE_OFF, + NULL); + if (ret < 0) { + goto exit; + } } } qemu_vfree(desc_entries); --=20 2.9.4