From: Denis V. Lunev Date: Mon, 27 Mar 2017 14:38:08 +0000 (+0300) Subject: parallels: wrong call to bdrv_truncate X-Git-Tag: v2.9.0-rc2~6^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dc62da88b5d17477227a3563a6ad466129d416d6;p=thirdparty%2Fqemu.git parallels: wrong call to bdrv_truncate Parallels driver should not call bdrv_truncate if the image was opened in the read-only mode. Without the patch qemu-img check harddisk.hds asserts with bdrv_truncate: Assertion `child->perm & BLK_PERM_RESIZE' failed. Parameters used on the write path are not needed if the image is opened in the read-only mode. Signed-off-by: Denis V. Lunev Reported-by: Edgar Kaziahmedov Message-id: 1490625488-7980-1-git-send-email-den@openvz.org CC: Stefan Hajnoczi Signed-off-by: Stefan Hajnoczi --- diff --git a/block/parallels.c b/block/parallels.c index 6bf93753e82..4173b3fb9d2 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -687,7 +687,8 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, if (local_err != NULL) { goto fail_options; } - if (!bdrv_has_zero_init(bs->file->bs) || + + if (!(flags & BDRV_O_RESIZE) || !bdrv_has_zero_init(bs->file->bs) || bdrv_truncate(bs->file, bdrv_getlength(bs->file->bs)) != 0) { s->prealloc_mode = PRL_PREALLOC_MODE_FALLOCATE; }