pub struct ChunkBuf(/* private fields */);Expand description
A page-aligned chunk buffer for streaming file data into guest memory.
The buffer is guaranteed to hold at least one page (HV_PAGE_SIZE) and its
length is always a whole number of pages. Reuse the same ChunkBuf across
multiple imports to avoid repeated allocations.
Implementations§
Source§impl ChunkBuf
impl ChunkBuf
Sourcepub fn with_size(size: usize) -> Self
pub fn with_size(size: usize) -> Self
Create a new chunk buffer with the given byte size, rounded down to a whole number of pages.
Panics if size is less than HV_PAGE_SIZE.
Sourcepub fn import_file_region<F, R: GuestArch>(
&mut self,
importer: &mut dyn ImageLoad<R>,
params: ImportFileRegion<'_, F>,
) -> Result<(), ImportFileRegionError>
pub fn import_file_region<F, R: GuestArch>( &mut self, importer: &mut dyn ImageLoad<R>, params: ImportFileRegion<'_, F>, ) -> Result<(), ImportFileRegionError>
Import a region from a file into guest memory.
Reads file_length bytes from file at file_offset, importing them
at guest physical address gpa. If gpa is not page-aligned, the
leading bytes of that page are zeroed. If memory_length exceeds
file_length, the remaining bytes are zeroed. Zeroing extends to the
end of the last target page.
Auto Trait Implementations§
impl Freeze for ChunkBuf
impl RefUnwindSafe for ChunkBuf
impl Send for ChunkBuf
impl Sync for ChunkBuf
impl Unpin for ChunkBuf
impl UnwindSafe for ChunkBuf
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