Skip to main content

krun_add_disk

Function krun_add_disk 

Source
pub unsafe extern "C" fn krun_add_disk(
    ctx_id: u32,
    block_id: *const c_char,
    disk_path: *const c_char,
    read_only: bool,
) -> i32
Expand description

Adds a disk image to be used as a general partition for the microVM. The only supported image format is “raw”.

This API is mutually exclusive with the deprecated krun_set_root_disk and krun_set_data_disk methods and must not be used together.

This function deliberately only handles images in the Raw format, because it doesn’t allow specifying an image format, and probing an image’s format is dangerous. For more information, see the security note on krun_add_disk2, which allows opening non-Raw images.

Arguments: “ctx_id” - the configuration context ID. “block_id” - a null-terminated string representing the partition. “disk_path” - a null-terminated string representing the path leading to the disk image. “read_only” - whether the mount should be read-only. Required if the caller does not have write permissions (for disk images in /usr/share).

Returns: Zero on success or a negative error number on failure.