Commit c6d10873db for qemu.org
commit c6d10873dbd829cf726fa1f5ebc312fa9a293336
Author: Denis V. Lunev <den@openvz.org>
Date: Tue Aug 11 18:49:33 2026 +0200
parallels: allocate the Format Extension cluster gracefully
s->cluster_size comes from the image and qemu_blockalign() aborts when
the allocation cannot be satisfied, so use the try variant and report
the failure instead.
The two are not interchangeable: qemu_try_blockalign() asserts that the
alignment is non zero, while qemu_blockalign() reaches
qemu_try_memalign(), which quietly raises a zero alignment to
sizeof(void *). bs->bl is only filled in once .bdrv_open() returns, so
the alignment has to come from bs->file, which is the node the cluster
is read through anyway and what parallels_open() uses for the header.
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
diff --git a/block/parallels-ext.c b/block/parallels-ext.c
index 63fe4d5b1e..89fab36039 100644
--- a/block/parallels-ext.c
+++ b/block/parallels-ext.c
@@ -323,10 +323,16 @@ int parallels_read_format_extension(BlockDriverState *bs,
{
BDRVParallelsState *s = bs->opaque;
int ret;
- uint8_t *ext_cluster = qemu_blockalign(bs, s->cluster_size);
+ uint8_t *ext_cluster;
assert(ext_off > 0);
+ ext_cluster = qemu_try_blockalign(bs->file->bs, s->cluster_size);
+ if (!ext_cluster) {
+ error_setg(errp, "Failed to allocate the Format Extension cluster");
+ return -ENOMEM;
+ }
+
ret = bdrv_pread(bs->file, ext_off, s->cluster_size, ext_cluster, 0);
if (ret < 0) {
error_setg_errno(errp, -ret, "Failed to read Format Extension cluster");