vmm: parse IGVM file early and thread it through VM setup

Move IGVM file parsing from load_igvm() into a dedicated parse_igvm()
helper in igvm/mod.rs, and parse the file upfront in Vm::new() so the
resulting IgvmFile struct is available throughout VM initialization.

This is a prerequisite for extracting VMSA SEV features from the parsed
IGVM before issuing KVM_SEV_INIT2, which needs sev_features.

Signed-off-by: Ruben Hakobyan <hruben@meta.com>
This commit is contained in:
Ruben Hakobyan
2026-04-09 16:58:58 -07:00
committed by Rob Bradford
parent 4f1119a788
commit 425609a8b5
4 changed files with 52 additions and 19 deletions
+9
View File
@@ -27,10 +27,19 @@
pub mod igvm_loader;
mod loader;
use std::path::Path;
use igvm::snp_defs::SevVmsa;
use igvm::{IgvmFile, IsolationType};
use igvm_defs::IGVM_VHS_SNP_ID_BLOCK;
use zerocopy::FromZeros;
pub fn parse_igvm(igvm_path: &Path) -> Result<IgvmFile, igvm_loader::Error> {
let file_contents = std::fs::read(igvm_path).map_err(igvm_loader::Error::Igvm)?;
IgvmFile::new_from_binary(&file_contents, Some(IsolationType::Snp))
.map_err(igvm_loader::Error::InvalidIgvmFile)
}
#[derive(Debug, Clone)]
pub struct IgvmLoadedInfo {
pub gpas: Vec<u64>,