Struct V2Header

Source
struct V2Header {
Show 13 fields magic: u32, version: u32, backing_file_offset: u64, backing_file_size: u32, cluster_bits: u32, size: AtomicU64, crypt_method: u32, l1_size: AtomicU32, l1_table_offset: AtomicU64, refcount_table_offset: AtomicU64, refcount_table_clusters: AtomicU32, nb_snapshots: u32, snapshots_offset: u64,
}
Expand description

Qcow2 v2 header.

Fields§

§magic: u32

Qcow magic string (“QFI\xfb”).

§version: u32

Version number (valid values are 2 and 3).

§backing_file_offset: u64

Offset into the image file at which the backing file name is stored (NB: The string is not null terminated). 0 if the image doesn’t have a backing file.

Note: backing files are incompatible with raw external data files (auto-clear feature bit 1).

§backing_file_size: u32

Length of the backing file name in bytes. Must not be longer than 1023 bytes. Undefined if the image doesn’t have a backing file.

§cluster_bits: u32

Number of bits that are used for addressing an offset within a cluster (1 << cluster_bits is the cluster size). Must not be less than 9 (i.e. 512 byte clusters).

Note: qemu as of today has an implementation limit of 2 MB as the maximum cluster size and won’t be able to open images with larger cluster sizes.

Note: if the image has Extended L2 Entries then cluster_bits must be at least 14 (i.e. 16384 byte clusters).

§size: AtomicU64

Virtual disk size in bytes.

Note: qemu has an implementation limit of 32 MB as the maximum L1 table size. With a 2 MB cluster size, it is unable to populate a virtual cluster beyond 2 EB (61 bits); with a 512 byte cluster size, it is unable to populate a virtual size larger than 128 GB (37 bits). Meanwhile, L1/L2 table layouts limit an image to no more than 64 PB (56 bits) of populated clusters, and an image may hit other limits first (such as a file system’s maximum size).

§crypt_method: u32

Encryption method:

  1. no encryption
  2. AES encryption
  3. LUKS encryption
§l1_size: AtomicU32

Number of entries in the active L1 table.

§l1_table_offset: AtomicU64

Offset into the image file at which the active L1 table starts. Must be aligned to a cluster boundary.

§refcount_table_offset: AtomicU64

Offset into the image file at which the refcount table starts. Must be aligned to a cluster boundary.

§refcount_table_clusters: AtomicU32

Number of clusters that the refcount table occupies.

§nb_snapshots: u32

Number of snapshots contained in the image.

§snapshots_offset: u64

Offset into the image file at which the snapshot table starts. Must be aligned to a cluster boundary.

Implementations§

Source§

impl V2Header

Source

const RAW_SIZE: usize = 72usize

Raw v2 header length.

Trait Implementations§

Source§

impl<'de> Deserialize<'de> for V2Header

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for V2Header

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,