From 63869bde7551f5330648d8b25a2357aba1a84be7 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Fri, 4 Oct 2019 11:27:22 -0700 Subject: [PATCH] vmm: Add iommu=on|off option for --pmem Having the virtual IOMMU created with --iommu is one thing, but we also need a way to decide if a virtio-pmem device should be attached to this virtual IOMMU or not. That's why we introduce an extra option "iommu" with the value "on" or "off". By default, the device is not attached, which means "iommu=off". Signed-off-by: Sebastien Boeuf --- src/main.rs | 2 +- vmm/src/api/openapi/cloud-hypervisor.yaml | 3 +++ vmm/src/config.rs | 12 +++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) 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); }