pub(super) struct RefTable {
cluster: Option<HostCluster>,
data: Box<[RefTableEntry]>,
cluster_bits: u32,
modified: AtomicBool,
}
Expand description
Refcount table.
Fields§
§cluster: Option<HostCluster>
First cluster in the image file.
data: Box<[RefTableEntry]>
Table data.
cluster_bits: u32
log2 of the cluster size.
modified: AtomicBool
Whether this table has been modified since it was last written.
Implementations§
Source§impl RefTable
impl RefTable
Sourcepub fn clone_and_grow(
&self,
header: &Header,
at_least_index: usize,
) -> Result<Self>
pub fn clone_and_grow( &self, header: &Header, at_least_index: usize, ) -> Result<Self>
Create a clone that covers at least at_least_index
.
Also ensure that beyond at_least_index
, there are enough entries to self-describe the new
refcount table (so that it can actually be allocated).
Trait Implementations§
Source§impl Table for RefTable
impl Table for RefTable
Source§const MAX_ENTRIES: usize = 4_194_304usize
const MAX_ENTRIES: usize = 4_194_304usize
Maximum number of refcount table entries.
Not in QEMU, but makes sense to limit to the same as the L1 table. Note that refcount blocks usually cover more clusters than an L2 table, so this generally allows larger image files than would be necessary for the maximum guest disk size determined by the maximum number of L1 entries.
Source§type InternalEntry = RefTableEntry
type InternalEntry = RefTableEntry
Internal type for each table entry.
Source§type Entry = RefTableEntry
type Entry = RefTableEntry
Externally visible type for each table entry.
Source§fn from_data(data: Box<[RefTableEntry]>, header: &Header) -> Self
fn from_data(data: Box<[RefTableEntry]>, header: &Header) -> Self
Create a new table with the given contents
Source§fn get(&self, index: usize) -> RefTableEntry
fn get(&self, index: usize) -> RefTableEntry
Get the given entry (copied).
Source§fn get_cluster(&self) -> Option<HostCluster>
fn get_cluster(&self) -> Option<HostCluster>
Get this table’s (first) cluster in the image file.
Source§fn get_offset(&self) -> Option<HostOffset>
fn get_offset(&self) -> Option<HostOffset>
Get this table’s offset in the image file.
Source§fn set_cluster(&mut self, cluster: HostCluster)
fn set_cluster(&mut self, cluster: HostCluster)
Set this table’s (first) cluster in the image file (for writing).
Source§fn unset_cluster(&mut self)
fn unset_cluster(&mut self)
Remove the table’s association with any cluster in the image file.
Source§fn is_modified(&self) -> bool
fn is_modified(&self) -> bool
Check whether this table has been modified since it was last written.
Source§fn clear_modified(&self)
fn clear_modified(&self)
Clear the modified flag.
Source§fn set_modified(&self)
fn set_modified(&self)
Set the modified flag.
Source§fn cluster_bits(&self) -> u32
fn cluster_bits(&self) -> u32
Return log2 of the cluster size. Read more
Source§fn cluster_count(&self) -> ClusterCount
fn cluster_count(&self) -> ClusterCount
Number of clusters used by this table.
Source§async fn load<S: Storage>(
image: &S,
header: &Header,
cluster: HostCluster,
entries: usize,
) -> Result<Self>
async fn load<S: Storage>( image: &S, header: &Header, cluster: HostCluster, entries: usize, ) -> Result<Self>
Load a table from the image file.
Auto Trait Implementations§
impl !Freeze for RefTable
impl RefUnwindSafe for RefTable
impl Send for RefTable
impl Sync for RefTable
impl Unpin for RefTable
impl UnwindSafe for RefTable
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more