Struct Header

Source
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

Source

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).

Source

pub async fn write<S: Storage>(&mut self, image: &S) -> Result<()>

Write the qcow2 header to disk.

Source

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.

Source

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.

Source

pub fn size(&self) -> u64

Guest disk size.

Source

pub fn require_version(&self, minimum: u32) -> Result<()>

Require a minimum qcow2 version.

Return an error if the version requirement is not met.

Source

pub fn set_size(&self, new_size: u64)

Set the guest disk size.

Source

pub fn cluster_bits(&self) -> u32

log2 of the cluster size.

Source

pub fn cluster_size(&self) -> usize

Cluster size in bytes.

Source

pub fn l2_entries(&self) -> usize

Number of entries per L2 table.

Source

pub fn rb_bits(&self) -> u32

log2 of the number of entries per refcount block.

Source

pub fn rb_entries(&self) -> usize

Number of entries per refcount block.

Source

pub fn refcount_order(&self) -> u32

log2 of the refcount bits.

Source

pub fn l1_table_offset(&self) -> HostOffset

Offset of the L1 table.

Source

pub fn l1_table_entries(&self) -> usize

Number of entries in the L1 table.

Source

pub fn set_l1_table(&self, l1_table: &L1Table) -> Result<()>

Enter a new L1 table in the image header.

Source

pub fn reftable_offset(&self) -> HostOffset

Offset of the refcount table.

Source

pub fn reftable_clusters(&self) -> ClusterCount

Number of clusters occupied by the refcount table.

Source

pub fn reftable_entries(&self) -> usize

Number of entries in the refcount table.

Source

pub fn set_reftable(&self, reftable: &RefTable) -> Result<()>

Enter a new refcount table in the image header.

Source

pub fn backing_filename(&self) -> Option<&String>

Backing filename from the image header (if any).

Source

pub fn backing_format(&self) -> Option<&String>

Backing format string from the image header (if any).

Source

pub fn external_data_file(&self) -> bool

Whether this image requires an external data file.

Source

pub fn external_data_filename(&self) -> Option<&String>

External data file filename from the image header (if any).

Source

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.

Source

fn serialize_extensions(&self) -> Result<Vec<u8>>

Serialize all header extensions.

Source

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.

Source

pub async fn write_reftable_pointer<S: Storage>(&self, image: &S) -> Result<()>

Write the refcount table pointer (offset and size) to disk.

Source

pub async fn write_l1_table_pointer<S: Storage>(&self, image: &S) -> Result<()>

Write the L1 table pointer (offset and size) to disk.

Source

pub async fn write_size<S: Storage>(&self, image: &S) -> Result<()>

Write the guest disk size to disk.

Auto Trait Implementations§

§

impl !Freeze for Header

§

impl RefUnwindSafe for Header

§

impl Send for Header

§

impl Sync for Header

§

impl Unpin for Header

§

impl UnwindSafe for Header

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more