block: qcow: Add pread_alloc and decompress_cluster helpers

Add two reusable helpers for the compressed cluster read path:

- pread_alloc(fd, offset, len) allocates a buffer and fills it with
  pread_exact, returning the owned Vec.
- decompress_cluster(compressed, cluster_size, decoder) allocates the
  output buffer, decodes via the Decoder trait, and validates that the
  decoder produced exactly cluster_size bytes.

These will be used by QcowSync, QcowAsync, Qcow2Backing, and the
legacy QcowFile.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2026-04-17 19:50:03 +02:00
committed by Rob Bradford
parent 78a05ab0c1
commit d9b188c1be
2 changed files with 30 additions and 1 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
pub(crate) mod backing;
mod decoder;
pub(crate) mod decoder;
mod header;
pub(crate) mod metadata;
pub(crate) mod qcow_raw_file;