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

Method load_or_compute_measurements

verifier/src/verification.rs:309–339  ·  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

307 }
308
309 fn load_or_compute_measurements(
310 &self,
311 vm_config: &VmConfig,
312 fw_path: &Path,
313 kernel_path: &Path,
314 initrd_path: &Path,
315 kernel_cmdline: &str,
316 ) -> Result<TdxMeasurements> {
317 let cache_key = Self::vm_config_cache_key(vm_config)?;
318
319 if let Some(measurements) = self.load_measurements_from_cache(&cache_key)? {
320 return Ok(measurements);
321 }
322
323 let measurements = self.compute_measurements(
324 vm_config,
325 fw_path,
326 kernel_path,
327 initrd_path,
328 kernel_cmdline,
329 )?;
330
331 if let Err(e) = self.store_measurements_in_cache(&cache_key, &measurements) {
332 warn!(
333 "Failed to write measurement cache entry for {}: {e:?}",
334 cache_key
335 );
336 }
337
338 Ok(measurements)
339 }
340
341 /// Helper method to ensure image is downloaded and return image paths
342 async fn ensure_image_downloaded(&self, vm_config: &VmConfig) -> Result<ImagePaths> {

Callers 1

Tested by

no test coverage detected