MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / compute_measurement_details

Method compute_measurement_details

verifier/src/verification.rs:244–289  ·  view source on GitHub ↗
(
        &self,
        vm_config: &VmConfig,
        fw_path: &Path,
        kernel_path: &Path,
        initrd_path: &Path,
        kernel_cmdline: &str,
    )

Source from the content-addressed store, hash-verified

242 }
243
244 fn compute_measurement_details(
245 &self,
246 vm_config: &VmConfig,
247 fw_path: &Path,
248 kernel_path: &Path,
249 initrd_path: &Path,
250 kernel_cmdline: &str,
251 ) -> Result<TdxMeasurementDetails> {
252 let firmware = fw_path.display().to_string();
253 let kernel = kernel_path.display().to_string();
254 let initrd = initrd_path.display().to_string();
255
256 // Prefer the explicit variant the image declared; fall back to parsing
257 // the version out of the image name for pre-`ovmf_variant` deployments.
258 let ovmf_variant = vm_config
259 .ovmf_variant
260 .unwrap_or_else(|| dstack_mr::ovmf_variant_for_image(vm_config.image.as_deref()));
261
262 let details = dstack_mr::Machine::builder()
263 .cpu_count(vm_config.cpu_count)
264 .memory_size(vm_config.memory_size)
265 .firmware(&firmware)
266 .kernel(&kernel)
267 .initrd(&initrd)
268 .kernel_cmdline(kernel_cmdline)
269 .root_verity(true)
270 .hotplug_off(vm_config.hotplug_off)
271 .maybe_two_pass_add_pages(vm_config.qemu_single_pass_add_pages)
272 .maybe_pic(vm_config.pic)
273 .maybe_qemu_version(vm_config.qemu_version.clone())
274 .maybe_pci_hole64_size(if vm_config.pci_hole64_size > 0 {
275 Some(vm_config.pci_hole64_size)
276 } else {
277 None
278 })
279 .hugepages(vm_config.hugepages)
280 .num_gpus(vm_config.num_gpus)
281 .num_nvswitches(vm_config.num_nvswitches)
282 .host_share_mode(vm_config.host_share_mode.clone())
283 .ovmf_variant(ovmf_variant)
284 .build()
285 .measure_with_logs()
286 .context("Failed to compute expected MRs")?;
287
288 Ok(details)
289 }
290
291 fn compute_measurements(
292 &self,

Callers 2

compute_measurementsMethod · 0.80

Calls 5

ovmf_variant_for_imageFunction · 0.85
displayMethod · 0.80
measure_with_logsMethod · 0.80
cloneMethod · 0.80
buildMethod · 0.45

Tested by

no test coverage detected