提交 d0d5d0e3 编写于 作者: E Eric Blake 提交者: Kevin Wolf

qcow2: Check failure of bdrv_getlength()

qcow2_co_pwritev_compressed() should not call bdrv_truncate()
if determining the size failed.
Reported-by: NMarkus Armbruster <armbru@redhat.com>
Signed-off-by: NEric Blake <eblake@redhat.com>
Reviewed-by: NPhilippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: NJeff Cody <jcody@redhat.com>
Reviewed-by: NKevin Wolf <kwolf@redhat.com>
Reviewed-by: NJohn Snow <jsnow@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 c40fe9c0
......@@ -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);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册