mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: qcow: Preserve the compression type when writing the header
When writing the header after a resize the compression type field was always set to 0, which selects zlib, even when the image was originally created with zstd. The resized image would then no longer be usable. Write the actual configured compression type instead. Fixes: #8558 Assisted-by: Claude:Opus-4.8 Signed-off-by: Rob Bradford <rbradford@meta.com>
This commit is contained in:
@@ -576,8 +576,12 @@ impl QcowHeader {
|
||||
buf.extend_from_slice(v3.as_bytes());
|
||||
|
||||
if self.header_size > V3_BARE_HEADER_SIZE {
|
||||
// no compression
|
||||
buf.extend_from_slice(BeU64::new(0).as_bytes());
|
||||
let compression_type = match &self.compression_type {
|
||||
CompressionType::Zlib => COMPRESSION_TYPE_ZLIB,
|
||||
CompressionType::Zstd => COMPRESSION_TYPE_ZSTD,
|
||||
};
|
||||
let compression_type = BeU64::new(compression_type << (64 - 8));
|
||||
buf.extend_from_slice(compression_type.as_bytes());
|
||||
}
|
||||
|
||||
let end_extension = ExtensionHeader::end();
|
||||
|
||||
Reference in New Issue
Block a user