MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / set_disks

Method set_disks

crates/openshell-driver-vm/src/runtime.rs:1015–1084  ·  view source on GitHub ↗
(
        &self,
        root_disk: &Path,
        overlay_disk: &Path,
        image_disk: Option<&Path>,
    )

Source from the content-addressed store, hash-verified

1013 }
1014
1015 fn set_disks(
1016 &self,
1017 root_disk: &Path,
1018 overlay_disk: &Path,
1019 image_disk: Option<&Path>,
1020 ) -> Result<(), String> {
1021 let root_disk_c = path_to_cstring(root_disk)?;
1022 let block_id_c = CString::new("root").map_err(|e| format!("invalid block id: {e}"))?;
1023 check(
1024 unsafe {
1025 (self.krun.krun_add_disk)(
1026 self.ctx_id,
1027 block_id_c.as_ptr(),
1028 root_disk_c.as_ptr(),
1029 true,
1030 )
1031 },
1032 "krun_add_disk",
1033 )?;
1034
1035 let overlay_disk_c = path_to_cstring(overlay_disk)?;
1036 let overlay_block_id_c =
1037 CString::new("overlay").map_err(|e| format!("invalid block id: {e}"))?;
1038 check(
1039 unsafe {
1040 (self.krun.krun_add_disk)(
1041 self.ctx_id,
1042 overlay_block_id_c.as_ptr(),
1043 overlay_disk_c.as_ptr(),
1044 false,
1045 )
1046 },
1047 "krun_add_disk",
1048 )?;
1049
1050 if let Some(image_disk) = image_disk {
1051 let image_disk_c = path_to_cstring(image_disk)?;
1052 let image_block_id_c =
1053 CString::new("image").map_err(|e| format!("invalid image block id: {e}"))?;
1054 check(
1055 unsafe {
1056 (self.krun.krun_add_disk)(
1057 self.ctx_id,
1058 image_block_id_c.as_ptr(),
1059 image_disk_c.as_ptr(),
1060 true,
1061 )
1062 },
1063 "krun_add_disk",
1064 )?;
1065 }
1066
1067 let device_c =
1068 CString::new("/dev/vda").map_err(|e| format!("invalid root disk device: {e}"))?;
1069 let fstype_c =
1070 CString::new("ext4").map_err(|e| format!("invalid root disk fstype: {e}"))?;
1071 let options_c =
1072 CString::new("ro").map_err(|e| format!("invalid root disk options: {e}"))?;

Callers 1

run_libkrun_vmFunction · 0.80

Calls 2

path_to_cstringFunction · 0.85
checkFunction · 0.85

Tested by

no test coverage detected