diff --git a/src/main.rs b/src/main.rs index 443fa79ab..e26e766a8 100755 --- a/src/main.rs +++ b/src/main.rs @@ -171,7 +171,7 @@ fn main() { .long("pmem") .help( "Persistent memory parameters \"file=,\ - size=\"", + size=,iommu=on|off\"", ) .takes_value(true) .min_values(1) diff --git a/vmm/src/api/openapi/cloud-hypervisor.yaml b/vmm/src/api/openapi/cloud-hypervisor.yaml index 58b2ea895..f29b4781e 100644 --- a/vmm/src/api/openapi/cloud-hypervisor.yaml +++ b/vmm/src/api/openapi/cloud-hypervisor.yaml @@ -289,6 +289,9 @@ components: type: string size: type: integer + iommu: + type: boolean + default: false ConsoleConfig: required: diff --git a/vmm/src/config.rs b/vmm/src/config.rs index 2bbcf3967..2fca21c72 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -448,6 +448,8 @@ impl FsConfig { pub struct PmemConfig { pub file: PathBuf, pub size: u64, + #[serde(default)] + pub iommu: bool, } impl PmemConfig { @@ -457,12 +459,15 @@ impl PmemConfig { let mut file_str: &str = ""; let mut size_str: &str = ""; + let mut iommu_str: &str = ""; for param in params_list.iter() { if param.starts_with("file=") { file_str = ¶m[5..]; } else if param.starts_with("size=") { size_str = ¶m[5..]; + } else if param.starts_with("iommu=") { + iommu_str = ¶m[6..]; } } @@ -473,6 +478,7 @@ impl PmemConfig { Ok(PmemConfig { file: PathBuf::from(file_str), size: parse_size(size_str)?, + iommu: parse_iommu(iommu_str)?, }) } } @@ -788,7 +794,11 @@ impl VmConfig { if let Some(pmem_list) = &vm_params.pmem { let mut pmem_config_list = Vec::new(); for item in pmem_list.iter() { - pmem_config_list.push(PmemConfig::parse(item)?); + let pmem_config = PmemConfig::parse(item)?; + if pmem_config.iommu { + iommu = true; + } + pmem_config_list.push(pmem_config); } pmem = Some(pmem_config_list); }