From 149c342867efd93566df6309217679ba5c45898a Mon Sep 17 00:00:00 2001 From: Muminul Islam Date: Thu, 5 Sep 2024 15:36:14 -0700 Subject: [PATCH] vmm: pass memory size during VM creation Pass memory size from vmm crate to hypervisor VM creation API so use for creating Bitmap for SEV-SNP guest. Signed-off-by: Muminul Islam --- vmm/src/lib.rs | 2 ++ vmm/src/vm.rs | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/vmm/src/lib.rs b/vmm/src/lib.rs index 814d5eb5f..eef29e98d 100644 --- a/vmm/src/lib.rs +++ b/vmm/src/lib.rs @@ -786,6 +786,8 @@ impl Vmm { false, #[cfg(feature = "sev_snp")] false, + #[cfg(feature = "sev_snp")] + config.lock().unwrap().memory.total_size(), ) .map_err(|e| { MigratableError::MigrateReceive(anyhow!( diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index db035f469..450af5e45 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -827,6 +827,8 @@ impl Vm { tdx_enabled, #[cfg(feature = "sev_snp")] sev_snp_enabled, + #[cfg(feature = "sev_snp")] + vm_config.lock().unwrap().memory.total_size(), )?; let phys_bits = physical_bits(&hypervisor, vm_config.lock().unwrap().cpus.max_phys_bits); @@ -885,6 +887,7 @@ impl Vm { hypervisor: &Arc, #[cfg(feature = "tdx")] tdx_enabled: bool, #[cfg(feature = "sev_snp")] sev_snp_enabled: bool, + #[cfg(feature = "sev_snp")] mem_size: u64, ) -> Result> { hypervisor.check_required_extensions().unwrap(); @@ -901,7 +904,7 @@ impl Vm { // Otherwise SEV_SNP_DISABLED: 0 // value of sev_snp_enabled is mapped to SEV_SNP_ENABLED for true or SEV_SNP_DISABLED for false let vm = hypervisor - .create_vm_with_type(u64::from(sev_snp_enabled)) + .create_vm_with_type_and_memory(u64::from(sev_snp_enabled), mem_size) .unwrap(); } else { let vm = hypervisor.create_vm().unwrap();