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 <muislam@microsoft.com>
This commit is contained in:
Muminul Islam 2024-09-05 15:36:14 -07:00 committed by Wei Liu
parent 4054a49e2d
commit 149c342867
2 changed files with 6 additions and 1 deletions

View File

@ -786,6 +786,8 @@ impl Vmm {
false, false,
#[cfg(feature = "sev_snp")] #[cfg(feature = "sev_snp")]
false, false,
#[cfg(feature = "sev_snp")]
config.lock().unwrap().memory.total_size(),
) )
.map_err(|e| { .map_err(|e| {
MigratableError::MigrateReceive(anyhow!( MigratableError::MigrateReceive(anyhow!(

View File

@ -827,6 +827,8 @@ impl Vm {
tdx_enabled, tdx_enabled,
#[cfg(feature = "sev_snp")] #[cfg(feature = "sev_snp")]
sev_snp_enabled, 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); let phys_bits = physical_bits(&hypervisor, vm_config.lock().unwrap().cpus.max_phys_bits);
@ -885,6 +887,7 @@ impl Vm {
hypervisor: &Arc<dyn hypervisor::Hypervisor>, hypervisor: &Arc<dyn hypervisor::Hypervisor>,
#[cfg(feature = "tdx")] tdx_enabled: bool, #[cfg(feature = "tdx")] tdx_enabled: bool,
#[cfg(feature = "sev_snp")] sev_snp_enabled: bool, #[cfg(feature = "sev_snp")] sev_snp_enabled: bool,
#[cfg(feature = "sev_snp")] mem_size: u64,
) -> Result<Arc<dyn hypervisor::Vm>> { ) -> Result<Arc<dyn hypervisor::Vm>> {
hypervisor.check_required_extensions().unwrap(); hypervisor.check_required_extensions().unwrap();
@ -901,7 +904,7 @@ impl Vm {
// Otherwise SEV_SNP_DISABLED: 0 // Otherwise SEV_SNP_DISABLED: 0
// value of sev_snp_enabled is mapped to SEV_SNP_ENABLED for true or SEV_SNP_DISABLED for false // value of sev_snp_enabled is mapped to SEV_SNP_ENABLED for true or SEV_SNP_DISABLED for false
let vm = hypervisor 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(); .unwrap();
} else { } else {
let vm = hypervisor.create_vm().unwrap(); let vm = hypervisor.create_vm().unwrap();