[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH 4/4] qcow2: Check failure of bdrv_getlength()
From: |
Jeff Cody |
Subject: |
Re: [Qemu-block] [PATCH 4/4] qcow2: Check failure of bdrv_getlength() |
Date: |
Mon, 7 Aug 2017 19:34:25 -0400 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
On Mon, Aug 07, 2017 at 03:30:07PM -0500, Eric Blake wrote:
> qcow2_co_pwritev_compressed() should not call bdrv_truncate()
> if determining the size failed.
>
> Reported-by: Markus Armbruster <address@hidden>
> Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: Jeff Cody <address@hidden>
> ---
> block/qcow2.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/block/qcow2.c b/block/qcow2.c
> index 99407403ea..40ba26c111 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
> @@ -3282,12 +3282,15 @@ qcow2_co_pwritev_compressed(BlockDriverState *bs,
> uint64_t offset,
> z_stream strm;
> int ret, out_len;
> uint8_t *buf, *out_buf;
> - uint64_t cluster_offset;
> + int64_t cluster_offset;
>
> if (bytes == 0) {
> /* align end of file to a sector boundary to ease reading with
> sector based I/Os */
> cluster_offset = bdrv_getlength(bs->file->bs);
> + if (cluster_offset < 0) {
> + return cluster_offset;
> + }
> return bdrv_truncate(bs->file, cluster_offset, PREALLOC_MODE_OFF,
> NULL);
> }
>
> --
> 2.13.4
>
>
- Re: [Qemu-block] [PATCH 2/4] qcow: Check failure of bdrv_getlength() and bdrv_truncate(), (continued)