pub(super) struct Header {
v2: V2Header,
v3: V3HeaderBase,
unknown_header_fields: Vec<u8>,
backing_filename: Option<String>,
extensions: Vec<HeaderExtension>,
external_data_file: bool,
}
Expand description
Integrated header representation.
Fields§
§v2: V2Header
v2 part of the header.
v3: V3HeaderBase
Base v3 part of the header.
unknown_header_fields: Vec<u8>
Unrecognized header fields.
backing_filename: Option<String>
Backing filename string.
extensions: Vec<HeaderExtension>
Extensions.
external_data_file: bool
Whether an external data file is required.
Implementations§
Source§impl Header
impl Header
Sourcepub async fn load<S: Storage>(image: &S, writable: bool) -> Result<Self>
pub async fn load<S: Storage>(image: &S, writable: bool) -> Result<Self>
Load the qcow2 header from disk.
If writable
is false, do not perform any modifications (e.g. clearing auto-clear bits).
Sourcepub async fn write<S: Storage>(&mut self, image: &S) -> Result<()>
pub async fn write<S: Storage>(&mut self, image: &S) -> Result<()>
Write the qcow2 header to disk.
Sourcepub fn new(
cluster_bits: u32,
refcount_order: u32,
backing_filename: Option<String>,
backing_format: Option<String>,
external_data_file: Option<String>,
) -> Self
pub fn new( cluster_bits: u32, refcount_order: u32, backing_filename: Option<String>, backing_format: Option<String>, external_data_file: Option<String>, ) -> Self
Create a header for a new image.
Sourcepub fn update(&self, new_header: &Header) -> Result<()>
pub fn update(&self, new_header: &Header) -> Result<()>
Update from a newly loaded header.
Checks whether fields we consider immutable have remained the same, and updates mutable fields.
Sourcepub fn require_version(&self, minimum: u32) -> Result<()>
pub fn require_version(&self, minimum: u32) -> Result<()>
Require a minimum qcow2 version.
Return an error if the version requirement is not met.
Sourcepub fn cluster_bits(&self) -> u32
pub fn cluster_bits(&self) -> u32
log2 of the cluster size.
Sourcepub fn cluster_size(&self) -> usize
pub fn cluster_size(&self) -> usize
Cluster size in bytes.
Sourcepub fn l2_entries(&self) -> usize
pub fn l2_entries(&self) -> usize
Number of entries per L2 table.
Sourcepub fn rb_entries(&self) -> usize
pub fn rb_entries(&self) -> usize
Number of entries per refcount block.
Sourcepub fn refcount_order(&self) -> u32
pub fn refcount_order(&self) -> u32
log2 of the refcount bits.
Sourcepub fn l1_table_offset(&self) -> HostOffset
pub fn l1_table_offset(&self) -> HostOffset
Offset of the L1 table.
Sourcepub fn l1_table_entries(&self) -> usize
pub fn l1_table_entries(&self) -> usize
Number of entries in the L1 table.
Sourcepub fn set_l1_table(&self, l1_table: &L1Table) -> Result<()>
pub fn set_l1_table(&self, l1_table: &L1Table) -> Result<()>
Enter a new L1 table in the image header.
Sourcepub fn reftable_offset(&self) -> HostOffset
pub fn reftable_offset(&self) -> HostOffset
Offset of the refcount table.
Sourcepub fn reftable_clusters(&self) -> ClusterCount
pub fn reftable_clusters(&self) -> ClusterCount
Number of clusters occupied by the refcount table.
Sourcepub fn reftable_entries(&self) -> usize
pub fn reftable_entries(&self) -> usize
Number of entries in the refcount table.
Sourcepub fn set_reftable(&self, reftable: &RefTable) -> Result<()>
pub fn set_reftable(&self, reftable: &RefTable) -> Result<()>
Enter a new refcount table in the image header.
Sourcepub fn backing_filename(&self) -> Option<&String>
pub fn backing_filename(&self) -> Option<&String>
Backing filename from the image header (if any).
Sourcepub fn backing_format(&self) -> Option<&String>
pub fn backing_format(&self) -> Option<&String>
Backing format string from the image header (if any).
Sourcepub fn external_data_file(&self) -> bool
pub fn external_data_file(&self) -> bool
Whether this image requires an external data file.
Sourcepub fn external_data_filename(&self) -> Option<&String>
pub fn external_data_filename(&self) -> Option<&String>
External data file filename from the image header (if any).
Sourcepub fn feature_name(&self, feat_type: FeatureType, bit: u32) -> Option<&String>
pub fn feature_name(&self, feat_type: FeatureType, bit: u32) -> Option<&String>
Translate a feature bit to a human-readable name.
Uses the feature name table from the image header, if present.
Sourcefn serialize_extensions(&self) -> Result<Vec<u8>>
fn serialize_extensions(&self) -> Result<Vec<u8>>
Serialize all header extensions.
Sourceasync fn write_v2_header<S: Storage>(&self, image: &S) -> Result<()>
async fn write_v2_header<S: Storage>(&self, image: &S) -> Result<()>
Helper for functions that just need to change little bits in the v2 header part.
Sourcepub async fn write_reftable_pointer<S: Storage>(&self, image: &S) -> Result<()>
pub async fn write_reftable_pointer<S: Storage>(&self, image: &S) -> Result<()>
Write the refcount table pointer (offset and size) to disk.