Skip to main content

load_disk

Function load_disk 

Source
pub fn load_disk(world_id: u64, bytes: &[u8]) -> Result<u64, DiskError>
Expand description

Replaces the contents of a world’s block device with a disk image.

bytes must be a non-empty multiple of VMM_DISK_SECTOR_SIZE and at most VMM_DISK_MAX_BYTES. The image is copied from sector 0, the device is never shrunk, and the capacity after the call is at least max(current, VMM_DISK_DEFAULT_BYTES, image length). Bytes past the image are zero, so a shorter image fully replaces the previous content; when the device has to grow it is rebuilt zeroed (read-only mode preserved), which resets its virtio transport state. Meant to be called before the guest boots. Returns the resulting capacity in 512-byte sectors.